Documentation ¶
Index ¶
- Constants
- Variables
- func ParseTxInPosition(pos Position) (uint64, uint64, uint64)
- func ParseTxOutPosition(pos Position) (uint64, uint64, uint64)
- func ParseTxPosition(pos Position) (blkNum, txIndex uint64)
- func PositionToBytes(pos Position) []byte
- type Account
- type Block
- func (blk *Block) AddTx(tx *Tx) error
- func (blk *Block) Encode() ([]byte, error)
- func (blk *Block) GetTx(txIndex uint64) *Tx
- func (blk *Block) Hash() (common.Hash, error)
- func (blk *Block) IsExistTx(txIndex uint64) bool
- func (blk *Block) MerkleTree() (*merkle.Tree, error)
- func (blk *Block) Root() (common.Hash, error)
- func (blk *Block) Sign(signer *Account) error
- func (blk *Block) SignerAddress() (common.Address, error)
- type BlockHeader
- type Exit
- type Position
- type Signature
- type Tx
- func (tx *Tx) Confirm(inIndex uint64, signer *Account) error
- func (tx *Tx) ConfirmationHash() (common.Hash, error)
- func (tx *Tx) ConfirmationSignaturesBytes() ([]byte, error)
- func (tx *Tx) ConfirmationSignerAddress(inIndex uint64) (common.Address, error)
- func (tx *Tx) Encode() ([]byte, error)
- func (tx *Tx) ExitOutput(outIndex uint64) error
- func (tx *Tx) GetInput(inIndex uint64) *TxIn
- func (tx *Tx) GetOutput(outIndex uint64) *TxOut
- func (tx *Tx) Hash() (common.Hash, error)
- func (tx *Tx) IsExistInput(inIndex uint64) bool
- func (tx *Tx) IsExistOutput(outIndex uint64) bool
- func (tx *Tx) MerkleLeaf() ([]byte, error)
- func (tx *Tx) RestoreOutput(outIndex uint64) error
- func (tx *Tx) SetConfirmationSignature(inIndex uint64, confSig Signature) error
- func (tx *Tx) SetInput(inIndex uint64, txIn *TxIn) error
- func (tx *Tx) SetOutput(outIndex uint64, txOut *TxOut) error
- func (tx *Tx) Sign(inIndex uint64, signer *Account) error
- func (tx *Tx) SignaturesBytes() ([]byte, error)
- func (tx *Tx) SignerAddress(inIndex uint64) (common.Address, error)
- func (tx *Tx) SpendOutput(outIndex uint64) error
- type TxIn
- type TxInCore
- type TxOut
- type TxOutCore
Constants ¶
View Source
const ( MaxBlockTxesNum = 99999 TxMerkleTreeDepth = 10 )
View Source
const ( BlockPositionOffset = 100000 // must be greater than MaxBlockTxesNum TxPositionOffset = 10000 // must be greater than TxElementsNum )
View Source
const (
SignatureLength = 65 // bytes
)
View Source
const (
TxElementsNum = 2
)
Variables ¶
View Source
var ( ErrInvalidTxIndex = errors.New("tx index is invalid") ErrBlockTxesNumExceedsLimit = errors.New("block txes num exceeds the limit") )
View Source
var ( ErrInvalidTxInIndex = fmt.Errorf("txin index must be less than %d", TxElementsNum) ErrInvalidTxOutIndex = fmt.Errorf("txout index must be less than %d", TxElementsNum) )
View Source
var (
ErrInvalidSignatureLength = fmt.Errorf("signature must be %d bytes", SignatureLength)
)
View Source
var (
NullAddress = common.Address{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}
)
View Source
var (
NullHash = common.Hash{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
}
)
View Source
var (
NullSignature = Signature{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
}
)
Functions ¶
func ParseTxPosition ¶
func PositionToBytes ¶
Types ¶
type Account ¶
type Account struct {
// contains filtered or unexported fields
}
func NewAccount ¶
func NewAccount(privKey *ecdsa.PrivateKey) *Account
func (*Account) TransactOpts ¶
func (a *Account) TransactOpts() *bind.TransactOpts
type Block ¶
type Block struct { *BlockHeader Txes []*Tx `json:"txes"` }
type BlockHeader ¶
type Position ¶
type Position uint64
func BytesToPosition ¶
func NewTxInPosition ¶
func NewTxOutPosition ¶
func NewTxPosition ¶
func StrToPosition ¶
type Signature ¶
type Signature [SignatureLength]byte
func BytesToSignature ¶
func HexToSignature ¶
func (Signature) MarshalText ¶
type Tx ¶
type Tx struct { Inputs [TxElementsNum]*TxIn `json:"ins"` Outputs [TxElementsNum]*TxOut `json:"outs"` }
func (*Tx) ConfirmationSignaturesBytes ¶
func (*Tx) ConfirmationSignerAddress ¶
func (*Tx) ExitOutput ¶ added in v0.2.0
func (*Tx) IsExistInput ¶
func (*Tx) IsExistOutput ¶
func (*Tx) MerkleLeaf ¶
func (*Tx) RestoreOutput ¶ added in v0.4.0
func (*Tx) SetConfirmationSignature ¶
func (*Tx) SignaturesBytes ¶
func (*Tx) SpendOutput ¶
type TxIn ¶
Click to show internal directories.
Click to hide internal directories.