mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 03:16:45 +01:00
Impls exit endpoints and change pagination to cursor
This commit is contained in:
17
common/tx.go
17
common/tx.go
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user