Documentation
¶
Index ¶
Constants ¶
const ( VersionPreOverwinter = 2 VersionOverwinter = 3 VersionSapling = 4 VersionNU5 = 5 MaxExpiryHeight = 499999999 // https://zips.z.cash/zip-0203 )
Variables ¶
var ( // Little-endian encoded CONSENSUS_BRANCH_IDs. // https://zcash.readthedocs.io/en/latest/rtd_pages/nu_dev_guide.html#canopy ConsensusBranchNU5 = [4]byte{0xB4, 0xD0, 0xD6, 0xC2} // 1687104, testnet: 1842420 ConsensusBranchSapling = [4]byte{0xBB, 0x09, 0xB8, 0x76} // Zclassic only ConsensusBranchButtercup = [4]byte{0x0d, 0x54, 0x0b, 0x93} )
Functions ¶
func CalcTxSize ¶
CalcTxSize calculates the size of a Zcash transparent transaction. CalcTxSize won't return accurate results for shielded or blended transactions.
Types ¶
type Block ¶
type Block struct { wire.MsgBlock // Transactions and MsgBlock.Transactions should both be populated. Each // *Tx.MsgTx will be the same as the *MsgTx in MsgBlock.Transactions. Transactions []*Tx HashBlockCommitments [32]byte // Using NU5 name Nonce [32]byte // Bitcoin uses uint32 Solution []byte // length 1344 on main and testnet, 36 on regtest }
Block extends a wire.MsgBlock to specify Zcash specific fields, or in the case of the Nonce, a type-variant.
func DeserializeBlock ¶
DeserializeBlock deserializes the Zcash-encoded block.
type JoinSplit ¶
type JoinSplit struct {
Old, New uint64
}
JoinSplit is only the new and old fields of a vJoinSplit.
type Tx ¶
type Tx struct { *wire.MsgTx ExpiryHeight uint32 NSpendsSapling uint64 NOutputsSapling uint64 ValueBalanceSapling int64 NActionsOrchard uint64 SizeProofsOrchard uint64 NJoinSplit uint64 VJoinSplit []*JoinSplit ValueBalanceOrchard int64 }
Tx is a Zcash-adapted MsgTx. Tx will decode any version transaction, but will not save most data for shielded transactions. Tx can only produce tx hashes for unshielded transactions. Tx can only create signature hashes for unshielded version 5 transactions.
func DeserializeTx ¶
see https://zips.z.cash/protocol/protocol.pdf section 7.1
func NewTxFromMsgTx ¶
NewTxFromMsgTx creates a Tx embedding the MsgTx, and adding Zcash-specific fields.
func (*Tx) Bytes ¶
Bytes encodes the receiver to w using the bitcoin protocol encoding. This is part of the Message interface implementation. See Serialize for encoding transactions to be stored to disk, such as in a database, as opposed to encoding transactions for the wire. msg.Version must be 4 or 5.
func (*Tx) SerializeSize ¶
SerializeSize is the size of the transaction when serialized.
func (*Tx) SignatureDigest ¶
func (tx *Tx) SignatureDigest( vin int, hashType txscript.SigHashType, script []byte, vals []int64, prevScripts [][]byte, ) (_ [32]byte, err error)
SignatureDigest produces a hash of tx data suitable for signing. SignatureDigest only works correctly for unshielded version 5 transactions.