Documentation ¶
Index ¶
- Constants
- func ComputeOutputID(sc *SpendCommitment, inputType uint8, vote []byte) (h bc.Hash, err error)
- func GetTxMerkleTreeProof(txs []*Tx, relatedTxs []*Tx) ([]*bc.Hash, []uint8)
- func MapBlock(old *Block) *bc.Block
- func MapTx(txData *TxData) *bc.Tx
- func TxMerkleRoot(transactions []*bc.Tx) (root bc.Hash, err error)
- func ValidateTxMerkleTreeProof(hashes []*bc.Hash, flags []uint8, relatedHashes []*bc.Hash, merkleRoot bc.Hash) bool
- type Block
- type BlockCommitment
- type BlockHeader
- type BlockWitness
- type CoinbaseInput
- type IssuanceInput
- type OutputCommitment
- type SpendCommitment
- type SpendInput
- type SupLink
- type SupLinks
- type Tx
- type TxData
- type TxInput
- func NewCoinbaseInput(arbitrary []byte) *TxInput
- func NewIssuanceInput(nonce []byte, amount uint64, issuanceProgram []byte, arguments [][]byte, ...) *TxInput
- func NewSpendInput(arguments [][]byte, sourceID bc.Hash, assetID bc.AssetID, ...) *TxInput
- func NewVetoInput(arguments [][]byte, sourceID bc.Hash, assetID bc.AssetID, ...) *TxInput
- type TxOutput
- type TypedInput
- type TypedOutput
- type VetoInput
- type VoteOutput
Constants ¶
const ( SerBlockHeader SerBlockTransactions SerBlockFull )
serflag variables, start with 1
const ( // FlagAssist represent assist node FlagAssist = iota // FlagTxParent represent the parent of transaction of node FlagTxParent // FlagTxLeaf represent transaction of node FlagTxLeaf )
merkleFlag represent the type of merkle tree node, it's used to generate the structure of merkle tree Bitcoin has only two flags, which zero means the hash of assist node. And one means the hash of the related transaction node or it's parents, which distinguish them according to the height of the tree. But in the janeta, the height of transaction node is not fixed, so we need three flags to distinguish these nodes.
const ( IssuanceInputType uint8 = iota SpendInputType CoinbaseInputType VetoInputType )
serflag variables for input types.
const ( // OriginalOutputType represent the type of original output OriginalOutputType uint8 = iota // VoteOutputType represent the type of vote output VoteOutputType )
Variables ¶
This section is empty.
Functions ¶
func ComputeOutputID ¶
ComputeOutputID assembles an output entry given a spend commitment and computes and returns its corresponding entry ID.
func GetTxMerkleTreeProof ¶
GetTxMerkleTreeProof return a proof of merkle tree, which used to proof the transaction does exist in the merkle tree
func TxMerkleRoot ¶
TxMerkleRoot creates a merkle tree from a slice of transactions and returns the root hash of the tree.
Types ¶
type Block ¶
type Block struct { BlockHeader Transactions []*Tx }
Block describes a complete block, including its header and the transactions it contains.
func (*Block) MarshalText ¶
MarshalText fulfills the json.Marshaler interface. This guarantees that blocks will get deserialized correctly when being parsed from HTTP requests.
func (*Block) MarshalTextForBlockHeader ¶
MarshalTextForBlockHeader fulfills the json.Marshaler interface.
func (*Block) MarshalTextForTransactions ¶
MarshalTextForTransactions fulfills the json.Marshaler interface.
func (*Block) UnmarshalText ¶
UnmarshalText fulfills the encoding.TextUnmarshaler interface.
type BlockCommitment ¶
type BlockCommitment struct { // TransactionsMerkleRoot is the root hash of the Merkle binary hash tree // formed by the hashes of all transactions included in the block. TransactionsMerkleRoot bc.Hash `json:"transaction_merkle_root"` }
BlockCommitment store the TransactionsMerkleRoot
type BlockHeader ¶
type BlockHeader struct { Version uint64 // The version of the block. Height uint64 // The height of the block. PreviousBlockHash bc.Hash // The hash of the previous block. Timestamp uint64 // The time of the block in seconds. BlockWitness SupLinks BlockCommitment }
BlockHeader defines information about a block and is used in the janeta
func (*BlockHeader) Hash ¶
func (bh *BlockHeader) Hash() bc.Hash
Hash returns complete hash of the block header.
func (*BlockHeader) MarshalText ¶
func (bh *BlockHeader) MarshalText() ([]byte, error)
MarshalText fulfills the json.Marshaler interface. This guarantees that block headers will get deserialized correctly when being parsed from HTTP requests.
func (*BlockHeader) Time ¶
func (bh *BlockHeader) Time() time.Time
Time returns the time represented by the Timestamp in block header.
func (*BlockHeader) UnmarshalText ¶
func (bh *BlockHeader) UnmarshalText(text []byte) error
UnmarshalText fulfills the encoding.TextUnmarshaler interface.
type BlockWitness ¶
type BlockWitness []byte
BlockWitness save the consensus node sign
func (*BlockWitness) Set ¶
func (bw *BlockWitness) Set(data []byte)
Set write the sign data to BlockWitness
type CoinbaseInput ¶
type CoinbaseInput struct {
Arbitrary []byte
}
CoinbaseInput records the coinbase message
func (*CoinbaseInput) AssetID ¶
func (cb *CoinbaseInput) AssetID() bc.AssetID
AssetID implement the TypedInput.
func (*CoinbaseInput) InputType ¶
func (cb *CoinbaseInput) InputType() uint8
InputType is the interface function for return the input type
type IssuanceInput ¶
type IssuanceInput struct { Nonce []byte Amount uint64 AssetDefinition []byte VMVersion uint64 IssuanceProgram []byte Arguments [][]byte // contains filtered or unexported fields }
IssuanceInput satisfies the TypedInput interface and represents a issuance.
func (*IssuanceInput) AssetDefinitionHash ¶
func (ii *IssuanceInput) AssetDefinitionHash() (defhash bc.Hash)
AssetDefinitionHash return the hash of the issuance asset definition.
func (*IssuanceInput) AssetID ¶
func (ii *IssuanceInput) AssetID() bc.AssetID
AssetID calculate the assetID of the issuance input.
func (*IssuanceInput) InputType ¶
func (ii *IssuanceInput) InputType() uint8
InputType is the interface function for return the input type.
func (*IssuanceInput) NonceHash ¶
func (ii *IssuanceInput) NonceHash() (hash bc.Hash)
NonceHash return the hash of the issuance asset definition.
type OutputCommitment ¶
type OutputCommitment struct { bc.AssetAmount VMVersion uint64 ControlProgram []byte StateData [][]byte }
OutputCommitment contains the commitment data for a transaction output.
type SpendCommitment ¶
type SpendCommitment struct { bc.AssetAmount SourceID bc.Hash SourcePosition uint64 VMVersion uint64 ControlProgram []byte StateData [][]byte }
SpendCommitment contains the commitment data for a transaction output.
type SpendInput ¶
type SpendInput struct { SpendCommitmentSuffix []byte // The unconsumed suffix of the output commitment Arguments [][]byte // Witness SpendCommitment }
SpendInput satisfies the TypedInput interface and represents a spend transaction.
func (*SpendInput) AssetID ¶
func (si *SpendInput) AssetID() bc.AssetID
AssetID implement the TypedInput.
func (*SpendInput) InputType ¶
func (si *SpendInput) InputType() uint8
InputType is the interface function for return the input type.
type SupLink ¶
type SupLink struct { SourceHeight uint64 SourceHash bc.Hash Signatures [consensus.MaxNumOfValidators][]byte }
SupLink is an ordered pair of checkpoints (a, b), also written a → b the validators will sign it once considered as legal
func (*SupLink) IsMajority ¶
IsMajority if at least 2/3 of validators have published votes with sup link
type Tx ¶
Tx holds a transaction along with its hash.
func NewTx ¶
NewTx returns a new Tx containing data and its hash. If you have already computed the hash, use struct literal notation to make a Tx object directly.
func (*Tx) SetInputArguments ¶
SetInputArguments sets the Arguments field in input n.
func (*Tx) UnmarshalText ¶
UnmarshalText fulfills the encoding.TextUnmarshaler interface.
type TxData ¶
type TxData struct { Version uint64 SerializedSize uint64 TimeRange uint64 Inputs []*TxInput Outputs []*TxOutput }
TxData encodes a transaction in the blockchain.
func (*TxData) MarshalText ¶
MarshalText fulfills the json.Marshaler interface.
func (*TxData) UnmarshalText ¶
UnmarshalText fulfills the encoding.TextUnmarshaler interface.
type TxInput ¶
type TxInput struct { AssetVersion uint64 TypedInput CommitmentSuffix []byte WitnessSuffix []byte }
TxInput is the top level struct of tx input.
func NewCoinbaseInput ¶
NewCoinbaseInput creates a new coinbase input struct
func NewIssuanceInput ¶
func NewIssuanceInput(nonce []byte, amount uint64, issuanceProgram []byte, arguments [][]byte, assetDefinition []byte) *TxInput
NewIssuanceInput create a new IssuanceInput struct.
func NewSpendInput ¶
func NewSpendInput(arguments [][]byte, sourceID bc.Hash, assetID bc.AssetID, amount, sourcePos uint64, controlProgram []byte, stateData [][]byte) *TxInput
NewSpendInput create a new SpendInput struct.
func NewVetoInput ¶
func NewVetoInput(arguments [][]byte, sourceID bc.Hash, assetID bc.AssetID, amount, sourcePos uint64, controlProgram []byte, vote []byte, stateData [][]byte) *TxInput
NewVetoInput create a new VetoInput struct.
func (*TxInput) ControlProgram ¶
ControlProgram return the control program of the spend input
func (*TxInput) SetArguments ¶
SetArguments set the args for the input
type TxOutput ¶
type TxOutput struct { AssetVersion uint64 OutputCommitment // Unconsumed suffixes of the commitment and witness extensible strings. CommitmentSuffix []byte TypedOutput }
TxOutput is the top level struct of tx output.
type TypedInput ¶
type TypedInput interface { InputType() uint8 AssetID() bc.AssetID // contains filtered or unexported methods }
TypedInput return the txinput type.
type TypedOutput ¶
type TypedOutput interface { OutputType() uint8 // contains filtered or unexported methods }
TypedOutput return the txoutput type.
type VetoInput ¶
type VetoInput struct { VetoCommitmentSuffix []byte // The unconsumed suffix of the output commitment Arguments [][]byte // Witness Vote []byte // voter xpub SpendCommitment }
VetoInput satisfies the TypedInput interface and represents a veto transaction.
type VoteOutput ¶
type VoteOutput struct {
Vote []byte
}
VoteOutput satisfies the TypedOutput interface and represents a vote transaction.
func (*VoteOutput) OutputType ¶
func (v *VoteOutput) OutputType() uint8
OutputType implement the txout interface