Merge pull request #179 from hermeznetwork/feature/api-exits

Impl exit edpoint and refactor pagination
This commit is contained in:
arnau
2020-10-14 11:16:03 +02:00
committed by GitHub
13 changed files with 1387 additions and 584 deletions

View File

@@ -3,8 +3,10 @@ package common
import (
"database/sql/driver"
"encoding/hex"
"errors"
"fmt"
"math/big"
"strings"
ethCommon "github.com/ethereum/go-ethereum/common"
"github.com/iden3/go-iden3-crypto/babyjub"
@@ -56,6 +58,21 @@ func (txid TxID) String() string {
return "0x" + hex.EncodeToString(txid[:])
}
// NewTxIDFromString returns a string hexadecimal representation of the TxID
func NewTxIDFromString(idStr string) (TxID, error) {
txid := TxID{}
idStr = strings.TrimPrefix(idStr, "0x")
decoded, err := hex.DecodeString(idStr)
if err != nil {
return TxID{}, err
}
if len(decoded) != TxIDLen {
return txid, errors.New("Invalid idStr")
}
copy(txid[:], decoded)
return txid, nil
}
// TxType is a string that represents the type of a Hermez network transaction
type TxType string