hermez-node/common/tx.go
common/tx.goRaw
1package common
2
3import (
4 "math/big"
5)
6
7// TxID is the identifier of a Hermez network transaction
8type TxID Hash // Hash is a guess
9
10// TxType is a string that represents the type of a Hermez network transaction
11type TxType string
12
13const (
14 // TxTypeExit represents L2->L1 token transfer. A leaf for this account appears in the exit tree of the block
15 TxTypeExit TxType = "Exit"
16 // TxTypeWithdrawn represents the balance that was moved from L2->L1 has been widthrawn from the smart contract
17 TxTypeWithdrawn TxType = "Withdrawn"
18 // TxTypeTransfer represents L2->L2 token transfer
19 TxTypeTransfer TxType = "Transfer"
20 // TxTypeDeposit represents L1->L2 transfer
21 TxTypeDeposit TxType = "Deposit"
22 // TxTypeCreateAccountDeposit represents creation of a new leaf in the state tree (newAcconut) + L1->L2 transfer
23 TxTypeCreateAccountDeposit TxType = "CreateAccountDeposit"
24 // TxTypeCreateAccountDepositTransfer represents L1->L2 transfer + L2->L2 transfer
25 TxTypeCreateAccountDepositTransfer TxType = "CreateAccountDepositTransfer"
26 // TxTypeDepositTransfer TBD
27 TxTypeDepositTransfer TxType = "TxTypeDepositTransfer"
28 // TxTypeForceTransfer TBD
29 TxTypeForceTransfer TxType = "TxTypeForceTransfer"
30 // TxTypeForceExit TBD
31 TxTypeForceExit TxType = "TxTypeForceExit"
32 // TxTypeTransferToEthAddr TBD
33 TxTypeTransferToEthAddr TxType = "TxTypeTransferToEthAddr"
34 // TxTypeTransferToBJJ TBD
35 TxTypeTransferToBJJ TxType = "TxTypeTransferToBJJ"
36)
37
38// Tx is a struct used by the TxSelector & BatchBuilder as a generic type generated from L1Tx & PoolL2Tx
39type Tx struct {
40 TxID TxID
41 FromIdx Idx // FromIdx is used by L1Tx/Deposit to indicate the Idx receiver of the L1Tx.LoadAmount (deposit)
42 ToIdx Idx // ToIdx is ignored in L1Tx/Deposit, but used in the L1Tx/DepositTransfer
43 Amount *big.Int
44 Nonce Nonce // effective 40 bits used
45 Fee FeeSelector
46 Type TxType // optional, descrives which kind of tx it's
47 BatchNum BatchNum // batchNum in which this tx was forged. Presence indicates "forged" state.
48}