zec

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: Apache-2.0, ISC Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VersionPreOverwinter = 2
	VersionOverwinter    = 3
	VersionSapling       = 4
	VersionNU5           = 5
	MaxExpiryHeight      = 499999999 // https://zips.z.cash/zip-0203

)

Variables

View Source
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

func CalcTxSize(tx *wire.MsgTx) uint64

CalcTxSize calculates the size of a Zcash transparent transaction. CalcTxSize won't return accurate results for shielded or blended transactions.

Types

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

func DeserializeTx(b []byte) (*Tx, error)

see https://zips.z.cash/protocol/protocol.pdf section 7.1

func NewTxFromMsgTx

func NewTxFromMsgTx(tx *wire.MsgTx, expiryHeight uint32) *Tx

NewTxFromMsgTx creates a Tx embedding the MsgTx, and adding Zcash-specific fields.

func (*Tx) Bytes

func (tx *Tx) Bytes() (_ []byte, err error)

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

func (tx *Tx) SerializeSize() uint64

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.

func (*Tx) TxHash

func (tx *Tx) TxHash() chainhash.Hash

TxHash generates the Hash for the transaction.

func (*Tx) ZecDecode

func (tx *Tx) ZecDecode(r io.Reader) (err error)

ZecDecode reads the serialized transaction from the reader and populates the *Tx's fields.

Jump to

Keyboard shortcuts

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