types

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BoxPrefix           = 'b'
	AddressPrefixLength = 2
	FixBoxPrefix        = 0x13
	FixP2PKHPrefix      = 0x26
	FixSplitPrefix      = 0x28
	FixP2SHPrefix       = 0x2a
	FixContractPrefix   = 0x30

	AddressLength       = 26
	EncodeAddressLength = 35

	AddressUnkownType AddressType = iota
	AddressP2PKHType
	AddressSplitType
	AddressP2SHType
	AddressContractType
)

const

View Source
const (
	GeneralTx = iota
	RegisterCandidateTx
	VoteTx
)

Define const

View Source
const (
	VMVersion = 0

	ContractUnkownType   ContractType = "contract_unkown"
	ContractCreationType ContractType = "contract_creation"
	ContractCallType     ContractType = "contract_call"

	// BloomByteLength represents the number of bytes used in a header log bloom.
	BloomByteLength = 256
	// BloomBitLength represents the number of bits used in a header log bloom.
	BloomBitLength = 8 * BloomByteLength
	// BloomHashNum represents the number of hash functions.
	BloomHashNum = 3
)

Variables

View Source
var (
	AddressTypeP2PKHPrefix     = [2]byte{FixBoxPrefix, FixP2PKHPrefix} // p2pkh addresses start with b1
	AddrTypeP2PKHPrefix        = "b1"
	AddressTypeSplitAddrPrefix = [2]byte{FixBoxPrefix, FixSplitPrefix} // b2
	AddrTypeSplitAddrPrefix    = "b2"
	AddressTypeP2SHPrefix      = [2]byte{FixBoxPrefix, FixP2SHPrefix} // b3
	AddrTypeP2SHPrefix         = "b3"
	AddrTypeContractPrefix     = "b5"
	AddressTypeContractPrefix  = [2]byte{FixBoxPrefix, FixContractPrefix} // b5

	ZeroAddressHash = AddressHash{}
)

Functions

func CreateReceiptsBloom added in v0.5.0

func CreateReceiptsBloom(rcs Receipts) bloom.Filter

CreateReceiptsBloom create a bloom filter matches Receipts.

func IsCoinBaseTxIn added in v0.5.0

func IsCoinBaseTxIn(txIn *TxIn) bool

IsCoinBaseTxIn check whether tx in is coin base tx in

func NewTxOut

func NewTxOut(value uint64, scriptPubKey []byte) *corepb.TxOut

NewTxOut generates a new TxOut

func NormalizeAddressHash added in v0.5.0

func NormalizeAddressHash(addrHash *AddressHash) *crypto.HashType

NormalizeAddressHash converts AddressHash to common Hash

func ValidateAddr added in v0.3.1

func ValidateAddr(addrs ...string) error

ValidateAddr validetes addr

Types

type Address

type Address interface {
	Type() AddressType
	String() string
	SetString(string) error
	Hash() []byte
	Hash160() *AddressHash
}

Address is an interface type for any type of destination a transaction output may spend to.

func ParseAddress added in v0.3.1

func ParseAddress(in string) (Address, error)

ParseAddress parses address

type AddressContract added in v0.5.0

type AddressContract struct {
	// contains filtered or unexported fields
}

AddressContract is an Address for a contract

func MakeContractAddress added in v0.5.0

func MakeContractAddress(
	sender *AddressPubKeyHash, nonce uint64,
) (*AddressContract, error)

MakeContractAddress make a contract address from sender and tx hash

func NewContractAddress added in v0.5.0

func NewContractAddress(address string) (*AddressContract, error)

NewContractAddress returns a new contract address. pkHash mustbe 20 bytes.

func NewContractAddressFromHash added in v0.5.0

func NewContractAddressFromHash(hash []byte) (*AddressContract, error)

NewContractAddressFromHash creates an contract address from hash

func (*AddressContract) Hash added in v0.5.0

func (a *AddressContract) Hash() []byte

Hash returns the bytes to be included in a txout script to pay to contract

func (*AddressContract) Hash160 added in v0.5.0

func (a *AddressContract) Hash160() *AddressHash

Hash160 returns the underlying array of the contract hash.

func (*AddressContract) SetString added in v0.5.0

func (a *AddressContract) SetString(in string) error

SetString sets the Address's internal byte array using byte array decoded from input base58 format string, returns error if input string is invalid

func (*AddressContract) String added in v0.5.0

func (a *AddressContract) String() string

String returns a human-readable string for the split address.

func (*AddressContract) Type added in v0.5.0

func (a *AddressContract) Type() AddressType

Type returns AddressContractType

type AddressHash

type AddressHash [ripemd160.Size]byte

AddressHash Alias for address hash

func BigToAddressHash added in v0.5.0

func BigToAddressHash(b *big.Int) AddressHash

BigToAddressHash returns Address with byte values of b.

func BytesToAddressHash added in v0.5.0

func BytesToAddressHash(b []byte) AddressHash

BytesToAddressHash converts bytes to addressHash.

func CreateAddress added in v0.5.0

func CreateAddress(b AddressHash, nonce uint64) *AddressHash

CreateAddress creates an ethereum address given the bytes and the nonce

 e.g.
	b: [0,0,0,0,0,0,0,0,0,0,120,117,106,105,110,103,115,104,105]
	nonce: 0

	data: [214,148,0,0,0,0,0,0,0,0,0,0,120,117,106,105,110,103,115,104,105,128]
		  0xd6(0xc0 + 22 data len) 0x94(0x80 + 20 b len) + b + 0x80(means 0)

func CreateAddress2 added in v0.5.0

func CreateAddress2(b AddressHash, salt [32]byte, inithash []byte) *AddressHash

CreateAddress2 creates an ethereum address given the address bytes, initial contract code hash and a salt.

func HexToAddressHash added in v0.5.0

func HexToAddressHash(s string) AddressHash

HexToAddressHash returns AddressHash with byte values of s. If s is larger than len(h), s will be cropped from the left.

func (AddressHash) Big added in v0.5.0

func (a AddressHash) Big() *big.Int

Big converts an address to a big integer.

func (*AddressHash) Bytes added in v0.5.0

func (a *AddressHash) Bytes() []byte

Bytes returns the bytes of a addressHash.

func (*AddressHash) SetBytes added in v0.5.0

func (a *AddressHash) SetBytes(b []byte)

SetBytes set bytes for a addressHash.

func (AddressHash) String added in v0.5.0

func (a AddressHash) String() string

String returns a human-readable string for the address hash.

type AddressPubKeyHash

type AddressPubKeyHash struct {
	// contains filtered or unexported fields
}

AddressPubKeyHash is an Address for a pay-to-pubkey-hash (P2PKH) transaction.

func NewAddress

func NewAddress(address string) (*AddressPubKeyHash, error)

NewAddress creates an address from string

func NewAddressFromPubKey

func NewAddressFromPubKey(pubKey *crypto.PublicKey) (*AddressPubKeyHash, error)

NewAddressFromPubKey returns a new AddressPubKeyHash derived from an ecdsa public key

func NewAddressPubKeyHash

func NewAddressPubKeyHash(pkHash []byte) (*AddressPubKeyHash, error)

NewAddressPubKeyHash returns a new AddressPubKeyHash. pkHash mustbe 20 bytes.

func (*AddressPubKeyHash) Hash

func (a *AddressPubKeyHash) Hash() []byte

Hash returns the bytes to be included in a txout script to pay to a pubkey hash.

func (*AddressPubKeyHash) Hash160

func (a *AddressPubKeyHash) Hash160() *AddressHash

Hash160 returns the underlying array of the pubkey hash.

func (*AddressPubKeyHash) SetString

func (a *AddressPubKeyHash) SetString(in string) error

SetString sets the Address's internal byte array using byte array decoded from input base58 format string, returns error if input string is invalid

func (*AddressPubKeyHash) String

func (a *AddressPubKeyHash) String() string

String returns a human-readable string for the pay-to-pubkey-hash address.

func (*AddressPubKeyHash) Type added in v0.3.1

func (a *AddressPubKeyHash) Type() AddressType

Type returns AddressP2PKHType

type AddressType added in v0.3.1

type AddressType int

AddressType defines address type

type AddressTypeSplit added in v0.3.0

type AddressTypeSplit struct {
	// contains filtered or unexported fields
}

AddressTypeSplit stands for split address

func NewSplitAddress added in v0.3.0

func NewSplitAddress(address string) (*AddressTypeSplit, error)

NewSplitAddress creates an address with a string prefixed by "b2"

func NewSplitAddressFromHash added in v0.3.0

func NewSplitAddressFromHash(hash []byte) (*AddressTypeSplit, error)

NewSplitAddressFromHash creates an address with byte array of size 20

func (*AddressTypeSplit) Hash added in v0.3.0

func (a *AddressTypeSplit) Hash() []byte

Hash returns the bytes to be included in a txout script to pay to a split addr.

func (*AddressTypeSplit) Hash160 added in v0.3.0

func (a *AddressTypeSplit) Hash160() *AddressHash

Hash160 returns the underlying array of the pubkey hash.

func (*AddressTypeSplit) SetString added in v0.3.0

func (a *AddressTypeSplit) SetString(in string) error

SetString sets the Address's internal byte array using byte array decoded from input base58 format string, returns error if input string is invalid

func (*AddressTypeSplit) String added in v0.3.0

func (a *AddressTypeSplit) String() string

String returns a human-readable string for the split address.

func (*AddressTypeSplit) Type added in v0.3.1

func (a *AddressTypeSplit) Type() AddressType

Type returns AddressSplitType

type Block

type Block struct {
	Hash             *crypto.HashType
	Header           *BlockHeader
	Txs              []*Transaction
	InternalTxs      []*Transaction
	Signature        []byte
	IrreversibleInfo *IrreversibleInfo
}

Block defines a block containing block and height that provides easier and more efficient manipulation of raw blocks. It also memoizes hashes for the block and its transactions on their first access so subsequent accesses don't have to repeat the relatively expensive hashing operations.

func NewBlock

func NewBlock(parent *Block) *Block

NewBlock new a block from parent.

func NewBlocks

func NewBlocks(prevBlockHash crypto.HashType, txsRoot crypto.HashType, timestamp int64, prevOutPoint OutPoint, value uint64, lockTime int64, height uint32) *Block

NewBlocks generates a new Block

func (*Block) AppendTx added in v0.3.0

func (block *Block) AppendTx(txs ...*Transaction) *Block

AppendTx appends tx to block

func (*Block) BlockHash

func (block *Block) BlockHash() *crypto.HashType

BlockHash returns the block identifier hash for the Block.

func (*Block) Copy added in v0.3.0

func (block *Block) Copy() *Block

Copy returns a deep copy: used only for splitBlockOutputs() Only copy needed fields to save efforts: height & vin & vout

func (*Block) FromProtoMessage

func (block *Block) FromProtoMessage(message proto.Message) error

FromProtoMessage converts proto message to block.

func (*Block) GetTx added in v0.5.0

func (block *Block) GetTx(hash *crypto.HashType) (*Transaction, int)

GetTx returns tx and index via tx hash

func (*Block) Marshal

func (block *Block) Marshal() (data []byte, err error)

Marshal method marshal Block object to binary

func (*Block) ToProtoMessage

func (block *Block) ToProtoMessage() (proto.Message, error)

ToProtoMessage converts block to proto message.

func (*Block) Unmarshal

func (block *Block) Unmarshal(data []byte) error

Unmarshal method unmarshal binary data to Block object

type BlockHeader

type BlockHeader struct {
	// Version of the block.  This is not the same as the protocol version.
	Version int32

	// Hash of the previous block header in the block chain.
	PrevBlockHash crypto.HashType

	// Merkle tree reference to hash of all transactions for the block.
	TxsRoot crypto.HashType

	// Merkle tree reference to hash of all internal transactions generated during contract execution for the block.
	InternalTxsRoot crypto.HashType

	// UtxoRoot reference to hash of all contract utxos.
	UtxoRoot crypto.HashType

	// ReceiptHash reference to hash of all receipt
	ReceiptHash crypto.HashType

	// Time the block was created.  This is, unfortunately, encoded as a
	// uint32 on the wire and therefore is limited to 2106.
	TimeStamp int64

	// Distinguish between mainnet and testnet.
	Magic uint32

	RootHash crypto.HashType

	PeriodHash crypto.HashType

	CandidatesHash crypto.HashType

	Height uint32

	GasUsed uint64

	BookKeeper AddressHash

	Bloom bloom.Filter
}

BlockHeader defines information about a block and is used in the block (Block) and headers (MsgHeaders) messages.

func NewBlockHeader

func NewBlockHeader(prevBlockHash crypto.HashType, txsRoot crypto.HashType, timestamp int64, height uint32) *BlockHeader

NewBlockHeader generates a new BlockHeader

func (*BlockHeader) FromProtoMessage

func (header *BlockHeader) FromProtoMessage(message proto.Message) error

FromProtoMessage converts proto message to block header.

func (*BlockHeader) Marshal

func (header *BlockHeader) Marshal() (data []byte, err error)

Marshal method marshal BlockHeader object to binary

func (*BlockHeader) ToProtoMessage

func (header *BlockHeader) ToProtoMessage() (proto.Message, error)

ToProtoMessage converts block header to proto message.

func (*BlockHeader) Unmarshal

func (header *BlockHeader) Unmarshal(data []byte) error

Unmarshal method unmarshal binary data to BlockHeader object

type ContractType added in v0.5.0

type ContractType string

ContractType defines script contract type

type IrreversibleInfo added in v0.3.0

type IrreversibleInfo struct {
	Hash       crypto.HashType
	Signatures [][]byte
}

IrreversibleInfo defines information about irreversible blocks

func (*IrreversibleInfo) FromProtoMessage added in v0.3.0

func (ii *IrreversibleInfo) FromProtoMessage(message proto.Message) error

FromProtoMessage converts proto message to IrreversibleInfo.

func (*IrreversibleInfo) Marshal added in v0.3.0

func (ii *IrreversibleInfo) Marshal() (data []byte, err error)

Marshal method marshal IrreversibleInfo object to binary

func (*IrreversibleInfo) ToProtoMessage added in v0.3.0

func (ii *IrreversibleInfo) ToProtoMessage() (proto.Message, error)

ToProtoMessage converts IrreversibleInfo to proto message.

func (*IrreversibleInfo) Unmarshal added in v0.3.0

func (ii *IrreversibleInfo) Unmarshal(data []byte) error

Unmarshal method unmarshal binary data to IrreversibleInfo object

type Log added in v0.5.0

type Log struct {
	// Consensus fields:
	// address of the contract that generated the event
	Address AddressHash `json:"address" gencodec:"required"`
	// list of topics provided by the contract.
	Topics []crypto.HashType `json:"topics" gencodec:"required"`
	// supplied by the contract, usually ABI-encoded
	Data []byte `json:"data" gencodec:"required"`

	// Derived fields. These fields are filled in by the node
	// but not secured by consensus.
	// block in which the transaction was included
	BlockNumber uint64 `json:"blockNumber"`
	// hash of the transaction
	TxHash crypto.HashType `json:"transactionHash" gencodec:"required"`
	// index of the transaction in the block
	TxIndex uint32 `json:"transactionIndex" gencodec:"required"`
	// hash of the block in which the transaction was included
	BlockHash crypto.HashType `json:"blockHash"`
	// index of the log in the block
	Index uint32 `json:"logIndex" gencodec:"required"`

	// The Removed field is true if this log was reverted due to a chain reorganisation.
	// You must pay attention to this field if you receive logs through a filter query.
	Removed bool `json:"removed"`
}

Log represents a contract log event. These events are generated by the LOG opcode and stored/indexed by the node.

func (*Log) FromProtoMessage added in v0.5.0

func (log *Log) FromProtoMessage(message proto.Message) error

FromProtoMessage converts proto message to Receipt.

func (*Log) Marshal added in v0.5.0

func (log *Log) Marshal() (data []byte, err error)

Marshal method marshal Receipt object to binary

func (*Log) ToProtoMessage added in v0.5.0

func (log *Log) ToProtoMessage() (proto.Message, error)

ToProtoMessage converts Receipt to proto message.

func (*Log) Unmarshal added in v0.5.0

func (log *Log) Unmarshal(data []byte) error

Unmarshal method unmarshal binary data to Receipt object

type Message added in v0.5.0

type Message interface {
	From() *AddressHash
	To() *AddressHash

	GasPrice() *big.Int
	Gas() uint64
	Value() *big.Int

	Type() ContractType

	Nonce() uint64
	Data() []byte
	String() string
}

Message represents a message sent to a contract.

type OutPoint

type OutPoint struct {
	Hash  crypto.HashType
	Index uint32
}

OutPoint defines a data type that is used to track previous transaction outputs.

func NewOutPoint

func NewOutPoint(hash *crypto.HashType, index uint32) *OutPoint

NewOutPoint constructs a OutPoint

func (*OutPoint) FromProtoMessage

func (op *OutPoint) FromProtoMessage(message proto.Message) error

FromProtoMessage converts proto message to out point.

func (OutPoint) IsContractType added in v0.5.0

func (op OutPoint) IsContractType() bool

IsContractType tells if the OutPoint is an OutPoint pointing to contract

func (*OutPoint) Marshal

func (op *OutPoint) Marshal() (data []byte, err error)

Marshal method marshal OutPoint object to binary

func (OutPoint) String added in v0.3.0

func (op OutPoint) String() string

func (*OutPoint) ToProtoMessage

func (op *OutPoint) ToProtoMessage() (proto.Message, error)

ToProtoMessage converts out point to proto message.

func (*OutPoint) Unmarshal

func (op *OutPoint) Unmarshal(data []byte) error

Unmarshal method unmarshal binary data to OutPoint object

type Receipt added in v0.5.0

type Receipt struct {
	TxHash          crypto.HashType
	TxIndex         uint32
	ContractAddress AddressHash
	Failed          bool
	GasUsed         uint64
	BlockHash       crypto.HashType
	BlockHeight     uint32

	Logs  []*Log
	Bloom bloom.Filter
}

Receipt represents the result of a transaction.

func NewReceipt added in v0.5.0

func NewReceipt(
	txHash *crypto.HashType, contractAddr *AddressHash, failed bool, gasUsed uint64, logs []*Log,
) *Receipt

NewReceipt news a Receipt

func (*Receipt) FromProtoMessage added in v0.5.0

func (rc *Receipt) FromProtoMessage(message proto.Message) error

FromProtoMessage converts proto message to Receipt.

func (*Receipt) Marshal added in v0.5.0

func (rc *Receipt) Marshal() (data []byte, err error)

Marshal method marshal Receipt object to binary

func (*Receipt) ToProtoMessage added in v0.5.0

func (rc *Receipt) ToProtoMessage() (proto.Message, error)

ToProtoMessage converts Receipt to proto message.

func (*Receipt) Unmarshal added in v0.5.0

func (rc *Receipt) Unmarshal(data []byte) error

Unmarshal method unmarshal binary data to Receipt object

func (*Receipt) WithBlockHash added in v0.5.0

func (rc *Receipt) WithBlockHash(hash *crypto.HashType) *Receipt

WithBlockHash sets BlockHash field

func (*Receipt) WithBlockHeight added in v0.5.0

func (rc *Receipt) WithBlockHeight(h uint32) *Receipt

WithBlockHeight sets BlockHeight field

func (*Receipt) WithTxIndex added in v0.5.0

func (rc *Receipt) WithTxIndex(i uint32) *Receipt

WithTxIndex sets TxIndex field

type Receipts added in v0.5.0

type Receipts []*Receipt

Receipts represents multiple receipts in a block

func (*Receipts) Append added in v0.5.0

func (rcs *Receipts) Append(rc ...*Receipt) *Receipts

Append appends receipts

func (*Receipts) FromProtoMessage added in v0.5.0

func (rcs *Receipts) FromProtoMessage(message proto.Message) error

FromProtoMessage converts proto message to Receipt.

func (*Receipts) GetTxReceipt added in v0.5.0

func (rcs *Receipts) GetTxReceipt(hash *crypto.HashType) *Receipt

GetTxReceipt returns a tx receipt in receipts

func (*Receipts) Hash added in v0.5.0

func (rcs *Receipts) Hash() *crypto.HashType

Hash calculates and returns receipts' hash

func (*Receipts) Marshal added in v0.5.0

func (rcs *Receipts) Marshal() (data []byte, err error)

Marshal method marshal Receipt object to binary

func (*Receipts) ToProtoMessage added in v0.5.0

func (rcs *Receipts) ToProtoMessage() (proto.Message, error)

ToProtoMessage converts Receipt to proto message.

func (*Receipts) Unmarshal added in v0.5.0

func (rcs *Receipts) Unmarshal(data []byte) error

Unmarshal method unmarshal binary data to Receipt object

type RegisterCandidateContent added in v0.3.0

type RegisterCandidateContent struct {
	// contains filtered or unexported fields
}

RegisterCandidateContent identify the tx of RegisterCandidate type

func (*RegisterCandidateContent) Addr added in v0.3.0

Addr returns addr in registerCandidateContent.

func (*RegisterCandidateContent) Marshal added in v0.3.0

func (sc *RegisterCandidateContent) Marshal() (data []byte, err error)

Marshal marshals the RegisterCandidateContent to a binary representation of it.

func (*RegisterCandidateContent) Unmarshal added in v0.3.0

func (sc *RegisterCandidateContent) Unmarshal(data []byte) error

Unmarshal unmarshals RegisterCandidateContent from binary data.

type TokenID added in v0.5.0

type TokenID OutPoint

TokenID defines token id

type Transaction

type Transaction struct {
	Version  int32
	Vin      []*TxIn
	Vout     []*corepb.TxOut
	Data     *corepb.Data
	Magic    uint32
	LockTime int64
	// contains filtered or unexported fields
}

Transaction defines a transaction.

func ConvPbTx added in v0.3.0

func ConvPbTx(orig *corepb.Transaction) (*Transaction, error)

ConvPbTx convert a pb tx to types tx

func NewTransaction

func NewTransaction(prevOutPoint OutPoint, value uint64, lockTime int64) *Transaction

NewTransaction generates a new Transaction

func NewTx added in v0.3.0

func NewTx(ver int32, magic uint32, lockTime int64) *Transaction

NewTx generates a new Transaction

func (*Transaction) AppendVin added in v0.3.0

func (tx *Transaction) AppendVin(in ...*TxIn) *Transaction

AppendVin appends a tx in to tx

func (*Transaction) AppendVout added in v0.3.0

func (tx *Transaction) AppendVout(out ...*corepb.TxOut) *Transaction

AppendVout appends a tx out to tx

func (*Transaction) CalcTxHash

func (tx *Transaction) CalcTxHash() (*crypto.HashType, error)

CalcTxHash calculates tx hash

func (*Transaction) ConvToPbTx added in v0.3.0

func (tx *Transaction) ConvToPbTx() (*corepb.Transaction, error)

ConvToPbTx convert a types tx to corepb tx

func (*Transaction) Copy added in v0.3.0

func (tx *Transaction) Copy() *Transaction

Copy returns a deep copy, mostly for parallel script verification Do not copy hash since it will be updated anyway in script verification

func (*Transaction) FromProtoMessage

func (tx *Transaction) FromProtoMessage(message proto.Message) error

FromProtoMessage converts proto message to transaction.

func (*Transaction) Marshal

func (tx *Transaction) Marshal() (data []byte, err error)

Marshal method marshal tx object to binary

func (*Transaction) OutputAmount added in v0.3.0

func (tx *Transaction) OutputAmount() uint64

OutputAmount returns total amount from tx's outputs

func (*Transaction) ResetTxHash added in v0.3.0

func (tx *Transaction) ResetTxHash()

ResetTxHash reset txhash

func (*Transaction) SerializeSize

func (tx *Transaction) SerializeSize() (int, error)

SerializeSize return tx size.

func (*Transaction) ToProtoMessage

func (tx *Transaction) ToProtoMessage() (proto.Message, error)

ToProtoMessage converts transaction to proto message.

func (*Transaction) TxHash

func (tx *Transaction) TxHash() (*crypto.HashType, error)

TxHash returns tx hash; return cached hash if it exists

func (*Transaction) Unmarshal

func (tx *Transaction) Unmarshal(data []byte) error

Unmarshal method unmarshal binary data to tx object

func (*Transaction) WithData added in v0.3.0

func (tx *Transaction) WithData(data *corepb.Data) *Transaction

WithData sets Data to tx

type TxIn

type TxIn struct {
	PrevOutPoint OutPoint
	ScriptSig    []byte
	Sequence     uint32
}

TxIn defines a transaction input.

func NewCoinBaseTxIn added in v0.5.0

func NewCoinBaseTxIn() *TxIn

NewCoinBaseTxIn new a coinbase tx in

func NewTxIn

func NewTxIn(prevOutPoint *OutPoint, scriptSig []byte, seq uint32) *TxIn

NewTxIn generates a new TxIn

func (*TxIn) FromProtoMessage

func (txin *TxIn) FromProtoMessage(message proto.Message) error

FromProtoMessage converts proto message to txin.

func (*TxIn) Marshal

func (txin *TxIn) Marshal() (data []byte, err error)

Marshal method marshal TxIn object to binary

func (*TxIn) String added in v0.3.0

func (txin *TxIn) String() string

func (*TxIn) ToProtoMessage

func (txin *TxIn) ToProtoMessage() (proto.Message, error)

ToProtoMessage converts txin to proto message.

func (*TxIn) Unmarshal

func (txin *TxIn) Unmarshal(data []byte) error

Unmarshal method unmarshal binary data to TxIn object

type TxWrap added in v0.3.0

type TxWrap struct {
	Tx             *Transaction
	AddedTimestamp int64
	Height         uint32
	GasPrice       uint64
	IsScriptValid  bool
}

TxWrap wrap transaction

func (*TxWrap) GetTx added in v0.5.0

func (w *TxWrap) GetTx() *Transaction

GetTx return tx in TxWrap

func (*TxWrap) String added in v0.5.0

func (w *TxWrap) String() string

String prints TxWrap

type UtxoMap added in v0.3.0

type UtxoMap map[OutPoint]*UtxoWrap

UtxoMap defines a map type with OutPoint to UtxoWrap

type UtxoType added in v0.5.0

type UtxoType string

UtxoType descript utxo type

const (
	PayToPubkeyUtxo   UtxoType = "pay_to_pubkey_utxo"
	TokenIssueUtxo    UtxoType = "token_issue_utxo"
	TokenTransferUtxo UtxoType = "token_transfer_utxo"
	SplitAddrUtxo     UtxoType = "split_addr_utxo"
)

type UtxoWrap

type UtxoWrap struct {
	// contains filtered or unexported fields
}

UtxoWrap contains info about utxo

func NewUtxoWrap added in v0.3.0

func NewUtxoWrap(value uint64, script []byte, height uint32) *UtxoWrap

NewUtxoWrap returns new utxoWrap.

func (*UtxoWrap) Height added in v0.3.0

func (utxoWrap *UtxoWrap) Height() uint32

Height returns the height of the block containing the output.

func (*UtxoWrap) IsCoinBase

func (utxoWrap *UtxoWrap) IsCoinBase() bool

IsCoinBase returns whether or not the output was contained in a coinbase transaction.

func (*UtxoWrap) IsModified

func (utxoWrap *UtxoWrap) IsModified() bool

IsModified returns whether or not the output ismodified.

func (*UtxoWrap) IsSpent

func (utxoWrap *UtxoWrap) IsSpent() bool

IsSpent returns whether or not the output has been spent.

func (*UtxoWrap) Modified added in v0.3.0

func (utxoWrap *UtxoWrap) Modified()

Modified marks the output as modified.

func (*UtxoWrap) Script added in v0.3.0

func (utxoWrap *UtxoWrap) Script() []byte

Script returns the pubkey script of the output.

func (*UtxoWrap) SetCoinBase added in v0.3.0

func (utxoWrap *UtxoWrap) SetCoinBase()

SetCoinBase marks the output as coinBase.

func (*UtxoWrap) SetScript added in v0.5.0

func (utxoWrap *UtxoWrap) SetScript(s []byte)

SetScript sets the pubkey script of the output.

func (*UtxoWrap) SetValue added in v0.5.0

func (utxoWrap *UtxoWrap) SetValue(value uint64)

SetValue set utxoWrap value.

func (*UtxoWrap) Spend added in v0.3.0

func (utxoWrap *UtxoWrap) Spend()

Spend marks the output as spent.

func (*UtxoWrap) UnSpend added in v0.3.0

func (utxoWrap *UtxoWrap) UnSpend()

UnSpend marks the output as unspent.

func (*UtxoWrap) Value

func (utxoWrap *UtxoWrap) Value() uint64

Value returns the value of the output.

type VMTransaction added in v0.5.0

type VMTransaction struct {
	// contains filtered or unexported fields
}

VMTransaction defines the transaction used to interact with vm

func NewVMTransaction added in v0.5.0

func NewVMTransaction(
	value, gasPrice *big.Int, gas, nonce uint64, hash *crypto.HashType, typ ContractType,
	code []byte,
) *VMTransaction

NewVMTransaction new a VMTransaction instance with given parameters

func (*VMTransaction) Data added in v0.5.0

func (tx *VMTransaction) Data() []byte

Data returns the code of the tx.

func (*VMTransaction) From added in v0.5.0

func (tx *VMTransaction) From() *AddressHash

From returns the tx from addressHash.

func (*VMTransaction) Gas added in v0.5.0

func (tx *VMTransaction) Gas() uint64

Gas returns the gaslimit of the tx.

func (*VMTransaction) GasPrice added in v0.5.0

func (tx *VMTransaction) GasPrice() *big.Int

GasPrice returns the gasprice of the tx.

func (*VMTransaction) Nonce added in v0.5.0

func (tx *VMTransaction) Nonce() uint64

Nonce returns the nonce of the tx from origin tx assigned by client user.

func (*VMTransaction) OriginTxHash added in v0.5.0

func (tx *VMTransaction) OriginTxHash() *crypto.HashType

OriginTxHash returns the origin tx hash of the contract tx.

func (*VMTransaction) String added in v0.5.0

func (tx *VMTransaction) String() string

String returns the content of vm transaction to print

func (*VMTransaction) To added in v0.5.0

func (tx *VMTransaction) To() *AddressHash

To returns the tx to addressHash.

func (*VMTransaction) Type added in v0.5.0

func (tx *VMTransaction) Type() ContractType

Type returns the type of the contract tx.

func (*VMTransaction) Value added in v0.5.0

func (tx *VMTransaction) Value() *big.Int

Value returns the transfer value of the tx.

func (*VMTransaction) Version added in v0.5.0

func (tx *VMTransaction) Version() int32

Version returns the version of the tx.

func (*VMTransaction) WithFrom added in v0.5.0

func (tx *VMTransaction) WithFrom(from *AddressHash) *VMTransaction

WithFrom sets from

func (*VMTransaction) WithTo added in v0.5.0

func (tx *VMTransaction) WithTo(to *AddressHash) *VMTransaction

WithTo sets to

type VMTxParams added in v0.5.0

type VMTxParams struct {
	GasPrice uint64
	GasLimit uint64
	Nonce    uint64
	Version  int32
	Code     []byte
	From     *AddressHash
	To       *AddressHash
}

VMTxParams defines BoxTx params parsed from script pubkey

type VoteContent

type VoteContent struct {
	// contains filtered or unexported fields
}

VoteContent identify the tx of vote type

func (*VoteContent) Addr

func (vc *VoteContent) Addr() AddressHash

Addr returns addr in voteContent.

func (*VoteContent) Marshal

func (vc *VoteContent) Marshal() (data []byte, err error)

Marshal marshals the VoteContent to a binary representation of it.

func (*VoteContent) Unmarshal

func (vc *VoteContent) Unmarshal(data []byte) error

Unmarshal unmarshals VoteContent from binary data.

func (*VoteContent) Votes

func (vc *VoteContent) Votes() int64

Votes returns votes in voteContent.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL