Documentation
¶
Index ¶
- Constants
- func ComputeOutputID(sc *SpendCommitment) (h bc.Hash, err error)
- func MapBlock(old *Block) *bc.Block
- func MapTx(oldTx *TxData) *bc.Tx
- type Block
- type BlockCommitment
- type BlockHeader
- func (bh *BlockHeader) Hash() bc.Hash
- func (bh *BlockHeader) MarshalText() ([]byte, error)
- func (bh *BlockHeader) Scan(val interface{}) error
- func (bh *BlockHeader) Time() time.Time
- func (bh *BlockHeader) UnmarshalText(text []byte) error
- func (bh *BlockHeader) Value() (driver.Value, error)
- func (bh *BlockHeader) WriteTo(w io.Writer) (int64, error)
- type BlockWitness
- type IssuanceInput
- type IssuanceWitness
- type OutputCommitment
- type SpendCommitment
- type SpendInput
- type Tx
- type TxData
- type TxInput
- func (t *TxInput) Amount() uint64
- func (t *TxInput) Arguments() [][]byte
- func (t *TxInput) AssetAmount() bc.AssetAmount
- func (t *TxInput) AssetID() bc.AssetID
- func (t *TxInput) ControlProgram() []byte
- func (t *TxInput) IssuanceProgram() []byte
- func (t *TxInput) SetArguments(args [][]byte)
- func (t *TxInput) SpentOutputID() (o bc.Hash, err error)
- func (t *TxInput) WriteInputCommitment(w io.Writer, serflags uint8) error
- type TxOutput
- type TypedInput
Constants ¶
const ( SerBlockWitness = 1 SerBlockTransactions = 2 SerBlockSigHash = 0 SerBlockHeader = SerBlockWitness SerBlockFull = SerBlockWitness | SerBlockTransactions )
const ( SerWitness uint8 = 1 << iota SerPrevout SerMetadata // Bit mask for accepted serialization flags. // All other flag bits must be 0. SerTxHash = 0x0 // this is used only for computing transaction hash - prevout and refdata are replaced with their hashes SerValid = 0x7 )
These flags are part of the wire protocol; they must not change.
const CurrentTransactionVersion = 1
CurrentTransactionVersion is the current latest supported transaction version.
Variables ¶
This section is empty.
Functions ¶
func ComputeOutputID ¶
func ComputeOutputID(sc *SpendCommitment) (h bc.Hash, err error)
ComputeOutputID assembles an output entry given a spend commitment and computes and returns its corresponding entry ID.
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) 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
// AssetsMerkleRoot is the root hash of the Merkle Patricia Tree of
// the set of unspent outputs with asset version 1 after applying
// the block.
AssetsMerkleRoot bc.Hash
// ConsensusProgram is the predicate for validating the next block.
ConsensusProgram []byte
}
type BlockHeader ¶
type BlockHeader struct {
// Version of the block.
Version uint64
// Height of the block in the block chain.
// Initial block has height 1.
Height uint64
// Hash of the previous block in the block chain.
PreviousBlockHash bc.Hash
// Time of the block in milliseconds.
// Must grow monotonically and can be equal
// to the time in the previous block.
TimestampMS uint64
BlockCommitment
CommitmentSuffix []byte
BlockWitness
WitnessSuffix []byte
}
BlockHeader describes necessary data of the block.
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) Scan ¶
func (bh *BlockHeader) Scan(val interface{}) error
func (*BlockHeader) Time ¶
func (bh *BlockHeader) Time() time.Time
Time returns the time represented by the Timestamp in bh.
func (*BlockHeader) UnmarshalText ¶
func (bh *BlockHeader) UnmarshalText(text []byte) error
UnmarshalText fulfills the encoding.TextUnmarshaler interface.
type BlockWitness ¶
type BlockWitness struct {
// Witness is a vector of arguments to the previous block's
// ConsensusProgram for validating this block.
Witness [][]byte
}
type IssuanceInput ¶
type IssuanceInput struct {
// Commitment
Nonce []byte
Amount uint64
// Witness
IssuanceWitness
}
func (*IssuanceInput) AssetDefinitionHash ¶
func (ii *IssuanceInput) AssetDefinitionHash() (defhash bc.Hash)
func (*IssuanceInput) AssetID ¶
func (ii *IssuanceInput) AssetID() bc.AssetID
func (*IssuanceInput) IsIssuance ¶
func (ii *IssuanceInput) IsIssuance() bool
type IssuanceWitness ¶
type OutputCommitment ¶
type OutputCommitment struct {
bc.AssetAmount
VMVersion uint64
ControlProgram []byte
}
OutputCommitment contains the commitment data for a transaction output (which also appears in the spend input of that output).
type SpendCommitment ¶
type SpendCommitment struct {
bc.AssetAmount
SourceID bc.Hash
SourcePosition uint64
VMVersion uint64
ControlProgram []byte
RefDataHash bc.Hash
}
SpendCommitment contains the commitment data for a transaction output (which also appears in the spend input of that output).
type SpendInput ¶
type SpendInput struct {
// Commitment
SpendCommitment
// The unconsumed suffix of the output commitment
SpendCommitmentSuffix []byte
// Witness
Arguments [][]byte
}
SpendInput satisfies the TypedInput interface and represents a spend transaction.
func (*SpendInput) IsIssuance ¶
func (si *SpendInput) IsIssuance() bool
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 ¶
type TxData ¶
type TxData struct {
Version uint64
Inputs []*TxInput
Outputs []*TxOutput
// Common fields
MinTime uint64
MaxTime uint64
// The unconsumed suffix of the common fields extensible string
CommonFieldsSuffix []byte
// The unconsumed suffix of the common witness extensible string
CommonWitnessSuffix []byte
ReferenceData []byte
}
TxData encodes a transaction in the blockchain. Most users will want to use Tx instead; it includes the hash.
func (*TxData) HasIssuance ¶
HasIssuance returns true if this transaction has an issuance input.
func (*TxData) MarshalText ¶
func (*TxData) UnmarshalText ¶
type TxInput ¶
type TxInput struct {
AssetVersion uint64
ReferenceData []byte
TypedInput
// Unconsumed suffixes of the commitment and witness extensible
// strings.
CommitmentSuffix []byte
WitnessSuffix []byte
}
func NewIssuanceInput ¶
func NewSpendInput ¶
func (*TxInput) AssetAmount ¶
func (t *TxInput) AssetAmount() bc.AssetAmount
func (*TxInput) ControlProgram ¶
func (*TxInput) IssuanceProgram ¶
func (*TxInput) SetArguments ¶
type TxOutput ¶
type TxOutput struct {
AssetVersion uint64
OutputCommitment
// Unconsumed suffixes of the commitment and witness extensible strings.
CommitmentSuffix []byte
WitnessSuffix []byte
ReferenceData []byte
}
func NewTxOutput ¶
func (*TxOutput) CommitmentHash ¶
type TypedInput ¶
type TypedInput interface {
IsIssuance() bool
}