Documentation ¶
Index ¶
- Variables
- func AddBip32Derivation(derivations []*psbt.Bip32Derivation, target *psbt.Bip32Derivation) []*psbt.Bip32Derivation
- func AddCustomField(unknowns []*psbt.Unknown, key, value []byte) []*psbt.Unknown
- func AddOutput(pkt *VPacket, amount uint64, scriptAddr asset.ScriptKey, outputIndex uint32, ...)
- func AddTaprootBip32Derivation(derivations []*psbt.TaprootBip32Derivation, ...) []*psbt.TaprootBip32Derivation
- func Bip32DerivationFromKeyDesc(keyDesc keychain.KeyDescriptor, coinType uint32) (*psbt.Bip32Derivation, *psbt.TaprootBip32Derivation)
- func CommitmentVersion(vers VPacketVersion) (*commitment.TapCommitmentVersion, error)
- func Encode(vPkt *VPacket) ([]byte, error)
- func ExtractCustomField(unknowns []*psbt.Unknown, key []byte) []byte
- func KeyDescFromBip32Derivation(bip32Derivation *psbt.Bip32Derivation) (keychain.KeyDescriptor, error)
- type Anchor
- type ErrorTestCase
- type InputCommitments
- type OutputCommitments
- type TestAnchor
- type TestBip32Derivation
- type TestTrBip32Derivation
- type TestVInput
- type TestVOutput
- type TestVPacket
- type TestVectors
- type VInput
- type VOutPredicate
- type VOutput
- func (o *VOutput) AnchorKeyToDesc() (keychain.KeyDescriptor, error)
- func (o *VOutput) Copy() *VOutput
- func (o *VOutput) PrevWitnesses() ([]asset.Witness, error)
- func (o *VOutput) SetAnchorInternalKey(keyDesc keychain.KeyDescriptor, coinType uint32)
- func (o *VOutput) SplitLocator(assetID asset.ID) commitment.SplitLocator
- func (o *VOutput) TapCommitmentVersion() (*commitment.TapCommitmentVersion, error)
- type VOutputType
- type VPacket
- func Decode(encoded []byte) (*VPacket, error)
- func ForInteractiveSend(id asset.ID, amount uint64, scriptAddr asset.ScriptKey, lockTime uint64, ...) *VPacket
- func FromAddresses(receiverAddrs []*address.Tap, firstOutputIndex uint32) (*VPacket, error)
- func FromProofs(proofs []*proof.Proof, params *address.ChainParams) (*VPacket, error)
- func NewFromPsbt(packet *psbt.Packet) (*VPacket, error)
- func NewFromRawBytes(r io.Reader, b64 bool) (*VPacket, error)
- func OwnershipProofPacket(ownedAsset *asset.Asset, chainParams *address.ChainParams) *VPacket
- func RandPacket(t testing.TB, setVersion bool) *VPacket
- func (p *VPacket) AssetID() (asset.ID, error)
- func (p *VPacket) B64Encode() (string, error)
- func (p *VPacket) Copy() *VPacket
- func (p *VPacket) EncodeAsPsbt() (*psbt.Packet, error)
- func (p *VPacket) FirstInteractiveOutput() (*VOutput, error)
- func (p *VPacket) FirstNonSplitRootOutput() (*VOutput, error)
- func (p *VPacket) HasInteractiveOutput() bool
- func (p *VPacket) HasSplitCommitment() (bool, error)
- func (p *VPacket) HasSplitRootOutput() bool
- func (p *VPacket) Serialize(w io.Writer) error
- func (p *VPacket) SetInputAsset(index int, a *asset.Asset)
- func (p *VPacket) SplitRootOutput() (*VOutput, error)
- type VPacketVersion
- type ValidTestCase
Constants ¶
This section is empty.
Variables ¶
var ( PsbtKeyTypeGlobalTapIsVirtualTx = []byte{0x70} PsbtKeyTypeGlobalTapChainParamsHRP = []byte{0x71} PsbtKeyTypeGlobalTapPsbtVersion = []byte{0x72} PsbtKeyTypeInputTapPrevID = []byte{0x70} PsbtKeyTypeInputTapAnchorValue = []byte{0x71} PsbtKeyTypeInputTapAnchorPkScript = []byte{0x72} PsbtKeyTypeInputTapAnchorSigHashType = []byte{0x73} PsbtKeyTypeInputTapAnchorInternalKey = []byte{0x74} PsbtKeyTypeInputTapAnchorMerkleRoot = []byte{0x75} PsbtKeyTypeInputTapAnchorOutputBip32Derivation = []byte{0x76} PsbtKeyTypeInputTapAnchorOutputTaprootBip32Derivation = []byte{0x77} PsbtKeyTypeInputTapAnchorTapscriptSibling = []byte{0x78} PsbtKeyTypeInputTapAsset = []byte{0x79} PsbtKeyTypeInputTapAssetProof = []byte{0x7a} PsbtKeyTypeOutputTapType = []byte{0x70} PsbtKeyTypeOutputTapIsInteractive = []byte{0x71} PsbtKeyTypeOutputTapAnchorOutputIndex = []byte{0x72} PsbtKeyTypeOutputTapAnchorOutputInternalKey = []byte{0x73} PsbtKeyTypeOutputTapAnchorOutputBip32Derivation = []byte{0x74} PsbtKeyTypeOutputTapAnchorOutputTaprootBip32Derivation = []byte{0x75} PsbtKeyTypeOutputTapAsset = []byte{0x76} PsbtKeyTypeOutputTapSplitAsset = []byte{0x77} PsbtKeyTypeOutputTapAnchorTapscriptSibling = []byte{0x78} PsbtKeyTypeOutputTapAssetVersion = []byte{0x79} PsbtKeyTypeOutputTapProofDeliveryAddress = []byte{0x7a} PsbtKeyTypeOutputTapAssetProofSuffix = []byte{0x7b} PsbtKeyTypeOutputTapAssetLockTime = []byte{0x7c} PsbtKeyTypeOutputTapAssetRelativeLockTime = []byte{0x7d} )
We define a set of Taproot Asset (TAP) specific global, input and output PSBT key types here that correspond to the custom types defined in the VPacket below. We start at 0x70 because that is sufficiently high to not conflict with any of the keys specified in BIP-0174. Also, 7 is leet speak for "t" as in Taproot Assets. It would perhaps make sense to wrap these values in the BIP-0174 defined proprietary types to make 100% sure that no parser removes them. But the BIP also mentions to not remove unknown keys, so we should be fine like this as well.
var ( // PsbtKeyTypeOutputTaprootMerkleRoot is the key used to store the // Taproot Merkle root in the BTC level anchor transaction PSBT. This // is the top level Merkle root, meaning that it combines the Taproot // Asset commitment root below and tapscript sibling (if present). If // this is equal to the asset root then that means there is no tapscript // sibling. PsbtKeyTypeOutputTaprootMerkleRoot = []byte{0x70} // PsbtKeyTypeOutputAssetRoot is the key used to store the Taproot Asset // commitment root hash in the BTC level anchor transaction PSBT. PsbtKeyTypeOutputAssetRoot = []byte{0x71} // ErrInvalidVPacketVersion is an error returned when a VPacket version // is invalid. ErrInvalidVPacketVersion = fmt.Errorf("tappsbt: invalid version") )
The following keys are used as custom fields on the BTC level anchor transaction PSBTs only. They are defined here for completeness' sake but are not directly used by the tappsbt package.
var ( // VOutIsSplitRoot is a predicate that returns true if the virtual // output is a split root output. VOutIsSplitRoot = func(o *VOutput) bool { return o.Type.IsSplitRoot() } // VOutIsNotSplitRoot is a predicate that returns true if the virtual // output is NOT a split root output. VOutIsNotSplitRoot = func(o *VOutput) bool { return !o.Type.IsSplitRoot() } // VOutIsInteractive is a predicate that returns true if the virtual // transaction is interactive. VOutIsInteractive = func(o *VOutput) bool { return o.Interactive } )
var ( // ErrKeyNotFound is returned when a key is not found among the unknown // fields of a packet. ErrKeyNotFound = errors.New("tappsbt: key not found") )
Functions ¶
func AddBip32Derivation ¶
func AddBip32Derivation(derivations []*psbt.Bip32Derivation, target *psbt.Bip32Derivation) []*psbt.Bip32Derivation
AddBip32Derivation adds the given target BIP-0032 derivation to the list of derivations if it is not already present.
func AddCustomField ¶ added in v0.4.0
AddCustomField adds a custom field to the given unknown values. If the key is already present, the value is updated.
func AddOutput ¶
func AddOutput(pkt *VPacket, amount uint64, scriptAddr asset.ScriptKey, outputIndex uint32, anchorInternalKey keychain.KeyDescriptor, assetVersion asset.Version)
AddOutput adds an interactive output to the given packet.
func AddTaprootBip32Derivation ¶
func AddTaprootBip32Derivation(derivations []*psbt.TaprootBip32Derivation, target *psbt.TaprootBip32Derivation) []*psbt.TaprootBip32Derivation
AddTaprootBip32Derivation adds the given target Taproot BIP-0032 derivation to the list of derivations if it is not already present.
func Bip32DerivationFromKeyDesc ¶
func Bip32DerivationFromKeyDesc(keyDesc keychain.KeyDescriptor, coinType uint32) (*psbt.Bip32Derivation, *psbt.TaprootBip32Derivation)
Bip32DerivationFromKeyDesc returns the default and Taproot BIP-0032 key derivation information from the given key descriptor information.
func CommitmentVersion ¶ added in v0.4.0
func CommitmentVersion(vers VPacketVersion) (*commitment.TapCommitmentVersion, error)
CommitmentVersion returns the Taproot Asset commitment version that matches the VPacket version.
func ExtractCustomField ¶ added in v0.4.0
ExtractCustomField returns the value of a custom field in the given unknown values by key. If the key is not found, nil is returned.
func KeyDescFromBip32Derivation ¶
func KeyDescFromBip32Derivation( bip32Derivation *psbt.Bip32Derivation) (keychain.KeyDescriptor, error)
KeyDescFromBip32Derivation attempts to extract the key descriptor from the given public key and BIP-0032 derivation information.
Types ¶
type Anchor ¶
type Anchor struct { // Value is output value of the anchor output. Value btcutil.Amount // PkScript is the output script of the anchor output. PkScript []byte // SigHashType is the signature hash type that should be used to sign // the anchor output spend. SigHashType txscript.SigHashType // InternalKey is the internal key of the anchor output that the input // is spending the asset from. InternalKey *btcec.PublicKey // MerkleRoot is the root of the tap script merkle tree that also // contains the Taproot Asset commitment of the anchor output. MerkleRoot []byte // TapscriptSibling is the tapscript sibling of the Taproot Asset // commitment. TapscriptSibling []byte // Bip32Derivation is the BIP-0032 derivation of the anchor output's // internal key. Bip32Derivation []*psbt.Bip32Derivation // TrBip32Derivation is the Taproot BIP-0032 derivation of the anchor // output's internal key. TrBip32Derivation []*psbt.TaprootBip32Derivation }
Anchor is a struct that contains all the information about an anchor output.
type ErrorTestCase ¶ added in v0.3.0
type ErrorTestCase struct { Packet *TestVPacket `json:"packet"` Error string `json:"error"` Comment string `json:"comment"` }
type InputCommitments ¶
type InputCommitments = map[asset.PrevID]*commitment.TapCommitment
InputCommitments is a map from virtual package input prevID to its associated Taproot Asset commitment.
type OutputCommitments ¶ added in v0.4.0
type OutputCommitments = map[uint32]*commitment.TapCommitment
OutputCommitments is a map from anchor transaction output index to its associated Taproot Asset commitment.
type TestAnchor ¶ added in v0.3.0
type TestAnchor struct { Value int64 `json:"value"` PkScript string `json:"pk_script"` SigHashType uint32 `json:"sig_hash_type"` InternalKey string `json:"internal_key"` MerkleRoot string `json:"merkle_root"` TapscriptSibling string `json:"tapscript_sibling"` Bip32Derivation []*TestBip32Derivation `json:"bip32_derivation"` TrBip32Derivation []*TestTrBip32Derivation `json:"tr_bip32_derivation"` }
func NewTestFromAnchor ¶ added in v0.3.0
func NewTestFromAnchor(a *Anchor) *TestAnchor
type TestBip32Derivation ¶ added in v0.3.0
type TestBip32Derivation struct { PubKey string `json:"pub_key"` Fingerprint uint32 `json:"fingerprint"` Bip32Path []uint32 `json:"bip32_path"` }
func NewTestFromBip32Derivation ¶ added in v0.3.0
func NewTestFromBip32Derivation(b *psbt.Bip32Derivation) *TestBip32Derivation
func (*TestBip32Derivation) ToBip32Derivation ¶ added in v0.3.0
func (td *TestBip32Derivation) ToBip32Derivation( t testing.TB) *psbt.Bip32Derivation
type TestTrBip32Derivation ¶ added in v0.3.0
type TestTrBip32Derivation struct { XOnlyPubKey string `json:"pub_key"` LeafHashes []string `json:"leaf_hashes"` Fingerprint uint32 `json:"fingerprint"` Bip32Path []uint32 `json:"bip32_path"` }
func NewTestFromTrBip32Derivation ¶ added in v0.3.0
func NewTestFromTrBip32Derivation( b *psbt.TaprootBip32Derivation) *TestTrBip32Derivation
func (*TestTrBip32Derivation) ToTrBip32Derivation ¶ added in v0.3.0
func (td *TestTrBip32Derivation) ToTrBip32Derivation( t testing.TB) *psbt.TaprootBip32Derivation
type TestVInput ¶ added in v0.3.0
type TestVInput struct { Bip32Derivation []*TestBip32Derivation `json:"bip32_derivation"` TrBip32Derivation []*TestTrBip32Derivation `json:"tr_bip32_derivation"` TrInternalKey string `json:"tr_internal_key"` TrMerkleRoot string `json:"tr_merkle_root"` PrevID *asset.TestPrevID `json:"prev_id"` Anchor *TestAnchor `json:"anchor"` Asset *asset.TestAsset `json:"asset"` Proof *proof.TestProof `json:"proof"` }
func NewTestFromVInput ¶ added in v0.3.0
func NewTestFromVInput(t testing.TB, i *VInput) *TestVInput
type TestVOutput ¶ added in v0.3.0
type TestVOutput struct { Amount uint64 `json:"amount"` Type uint8 `json:"type"` AssetVersion uint32 `json:"asset_version"` Interactive bool `json:"interactive"` AnchorOutputIndex uint32 `json:"anchor_output_index"` AnchorOutputInternalKey string `json:"anchor_output_internal_key"` AnchorOutputBip32Derivation []*TestBip32Derivation `json:"anchor_output_bip32_derivation"` AnchorOutputTrBip32Derivation []*TestTrBip32Derivation `json:"anchor_output_tr_bip32_derivation"` AnchorOutputTapscriptSibling string `json:"anchor_output_tapscript_sibling"` Asset *asset.TestAsset `json:"asset"` SplitAsset *asset.TestAsset `json:"split_asset"` PkScript string `json:"pk_script"` Bip32Derivation []*TestBip32Derivation `json:"bip32_derivation"` TrBip32Derivation []*TestTrBip32Derivation `json:"tr_bip32_derivation"` TrInternalKey string `json:"tr_internal_key"` TrMerkleRoot string `json:"tr_merkle_root"` ProofDeliveryAddress string `json:"proof_delivery_address"` ProofSuffix *proof.TestProof `json:"proof_suffix"` RelativeLockTime uint64 `json:"relative_lock_time"` LockTime uint64 `json:"lock_time"` }
func NewTestFromVOutput ¶ added in v0.3.0
func NewTestFromVOutput(t testing.TB, v *VOutput, coinType uint32) *TestVOutput
type TestVPacket ¶ added in v0.3.0
type TestVPacket struct { Inputs []*TestVInput `json:"inputs"` Outputs []*TestVOutput `json:"outputs"` Version uint8 `json:"version"` ChainParamsHRP string `json:"chain_params_hrp"` }
func NewTestFromVPacket ¶ added in v0.3.0
func NewTestFromVPacket(t testing.TB, p *VPacket) *TestVPacket
type TestVectors ¶ added in v0.3.0
type TestVectors struct { ValidTestCases []*ValidTestCase `json:"valid_test_cases"` ErrorTestCases []*ErrorTestCase `json:"error_test_cases"` }
type VInput ¶
type VInput struct { // PInput is the embedded default PSBT input struct that is used for // asset related input data. psbt.PInput // PrevID is the asset previous ID of the asset being spent. PrevID asset.PrevID // Anchor contains the information about the BTC level anchor // transaction that committed to the asset being spent. Anchor Anchor // Proof is a transition proof that proves the asset being spent was // committed to in the anchor transaction above. Proof *proof.Proof // contains filtered or unexported fields }
VInput represents an input to a virtual asset state transition transaction.
type VOutPredicate ¶
VOutPredicate is a function that can be used to filter virtual outputs.
type VOutput ¶
type VOutput struct { // Amount is the amount of units of the asset that this output is // creating. This can be zero in case of an asset tombstone in a // non-interactive full value send scenario. When serialized, this will // be stored as the value of the wire.TxOut of the PSBT's unsigned TX. Amount uint64 // AssetVersion is the version of the asset that this output should // create. AssetVersion asset.Version // Type indicates what type of output this is, which has an influence on // whether the asset is set or what witness type is expected to be // generated for the asset. Type VOutputType // Interactive, when set to true, indicates that the receiver of the // output is aware of the asset transfer and can therefore receive a // full value send directly and without a tombstone in the change // output. Interactive bool // AnchorOutputIndex indicates in which output index of the BTC // transaction this asset output should be committed to. Multiple asset // outputs can be committed to within the same BTC transaction output. AnchorOutputIndex uint32 // AnchorOutputInternalKey is the internal key of the anchor output that // will be used to create the anchor Taproot output key to which this // asset output will be committed to. AnchorOutputInternalKey *btcec.PublicKey // AnchorOutputBip32Derivation is the BIP-0032 derivation of the anchor // output's internal key. AnchorOutputBip32Derivation []*psbt.Bip32Derivation // AnchorOutputTaprootBip32Derivation is the Taproot BIP-0032 derivation // of the anchor output's internal key. AnchorOutputTaprootBip32Derivation []*psbt.TaprootBip32Derivation // AnchorOutputTapscriptSibling is the preimage of the tapscript sibling // of the Taproot Asset commitment. AnchorOutputTapscriptSibling *commitment.TapscriptPreimage // Asset is the actual asset (including witness or split commitment // data) that this output will commit to on chain. This asset will be // included in the proof sent to the recipient of this output. Asset *asset.Asset // SplitAsset is the original split asset that was created when creating // the split commitment. // // NOTE: This is only set if the above Asset is the root asset of a // split. Compared to the root asset, this does not have a split // commitment root and no TX witness, but instead has the split // commitment set. SplitAsset *asset.Asset // ScriptKey is the new script key of the recipient of the asset. When // serialized, this will be stored in the TaprootInternalKey and // TaprootDerivationPath fields of the PSBT output. ScriptKey asset.ScriptKey // RelativeLockTime is the relative lock time of the output asset. This // needs to be set on the root asset if the transaction witness is for // a spend of a CSV script path. RelativeLockTime uint64 // LockTime is the relative lock time of the output asset. This needs to // be set on the root asset if the transaction witness is for a spend of // a CLTV script path. LockTime uint64 // ProofDeliveryAddress is the address to which the proof of the asset // transfer should be delivered. ProofDeliveryAddress *url.URL // ProofSuffix is the optional new transition proof blob that is created // once the asset output was successfully committed to the anchor // transaction referenced above. The proof suffix is not yet complete // since the header information needs to be added once the anchor // transaction was confirmed in a block. ProofSuffix *proof.Proof }
VOutput represents an output of a virtual asset state transition.
func (*VOutput) AnchorKeyToDesc ¶
func (o *VOutput) AnchorKeyToDesc() (keychain.KeyDescriptor, error)
AnchorKeyToDesc attempts to extract the key descriptor of the anchor output from the anchor output BIP-0032 derivation information.
func (*VOutput) PrevWitnesses ¶ added in v0.4.0
PrevWitnesses returns the previous witnesses of the asset output. If the asset is a split root, the witness of the root asset is returned. If the output asset is nil an error is returned.
func (*VOutput) SetAnchorInternalKey ¶
func (o *VOutput) SetAnchorInternalKey(keyDesc keychain.KeyDescriptor, coinType uint32)
SetAnchorInternalKey sets the internal key and derivation path of the anchor output based on the given key descriptor and coin type.
func (*VOutput) SplitLocator ¶
func (o *VOutput) SplitLocator(assetID asset.ID) commitment.SplitLocator
SplitLocator creates a split locator from the output. The asset ID is passed in for cases in which the asset is not yet set on the output.
func (*VOutput) TapCommitmentVersion ¶ added in v0.4.0
func (o *VOutput) TapCommitmentVersion() (*commitment.TapCommitmentVersion, error)
TapCommitmentVersion returns the taproot asset commitment version of a vOutput with a populated proof suffix.
type VOutputType ¶
type VOutputType uint8
VOutputType represents the type of virtual output.
const ( // TypeSimple is a plain full-value or split output that is not a split // root and does not carry passive assets. In case of a split, the asset // of this output has a split commitment. TypeSimple VOutputType = 0 // TypeSplitRoot is a split root output that carries the change from a // split or a tombstone from a non-interactive full value send output. // In either case, the asset of this output has a tx witness. TypeSplitRoot VOutputType = 1 )
func (VOutputType) IsSplitRoot ¶
func (t VOutputType) IsSplitRoot() bool
IsSplitRoot returns true if the output type is a split root, indicating that the asset has a tx witness instead of a split witness.
func (VOutputType) String ¶
func (t VOutputType) String() string
String returns a human-readable string representation of the output type.
type VPacket ¶
type VPacket struct { // Inputs is the list of asset inputs that are being spent. Inputs []*VInput // Outputs is the list of new asset outputs that are created by the // virtual transaction. Outputs []*VOutput // ChainParams are the Taproot Asset chain parameters that are used to // encode and decode certain contents of the virtual packet. ChainParams *address.ChainParams // Version is the version of the virtual transaction. Version VPacketVersion }
VPacket is a PSBT extension packet for a virtual transaction. It represents the virtual asset state transition as it will be validated by the Taproot Asset VM. Some elements within the virtual packet may refer to on-chain elements (such as the anchor BTC transaction that was used to anchor the input that is spent). But in general a virtual transaction does NOT directly map onto a BTC transaction. It is entirely possible that multiple virtual transactions will be merged into a single BTC transaction. Thus, each asset state transfer is represented in a virtual TX and multiple asset state transfers can be anchored within a single BTC transaction.
NOTE: A virtual transaction only carries the asset state transition for a single asset ID. If multiple inputs are given, they must all belong to the same asset ID (which means those asset UTXOs are being merged and possibly split again in this virtual transaction). Therefore, if an anchor output carries commitments for multiple assets, a virtual transaction needs to be created, signed and then anchored for each asset ID separately.
TODO(guggero): Actually support merging multiple virtual transactions into a single BTC transaction.
func ForInteractiveSend ¶
func ForInteractiveSend(id asset.ID, amount uint64, scriptAddr asset.ScriptKey, lockTime uint64, relativeLockTime uint64, outputIndex uint32, anchorInternalKey keychain.KeyDescriptor, assetVersion asset.Version, chainParams *address.ChainParams) *VPacket
ForInteractiveSend creates a virtual transaction packet for sending an output to a receiver in an interactive manner. Only one, interactive output is created. If the amount is not the full input amount, a change output will be added by the funding API.
func FromAddresses ¶
FromAddresses creates an empty virtual transaction packet from the given addresses. Because sending to an address is always non-interactive, a change output is also added to the packet.
func FromProofs ¶ added in v0.4.0
FromProofs creates a packet from the given proofs that adds them as inputs to the packet.
func NewFromPsbt ¶
NewFromPsbt returns a new instance of a VPacket struct created by reading the custom fields on the given PSBT packet.
func NewFromRawBytes ¶
NewFromRawBytes returns a new instance of a VPacket struct created by reading from a byte slice. If the format is invalid, an error is returned. If the argument b64 is true, the passed byte slice is decoded from base64 encoding before processing.
func OwnershipProofPacket ¶
func OwnershipProofPacket(ownedAsset *asset.Asset, chainParams *address.ChainParams) *VPacket
OwnershipProofPacket creates a virtual transaction packet that is used to prove ownership of an asset. It creates a 1-in-1-out transaction that spends the owned asset to the NUMS key. The witness is created over an empty previous outpoint, so it can never be used in an actual state transition.
func RandPacket ¶
RandPacket generates a random virtual packet for testing purposes.
func (*VPacket) AssetID ¶ added in v0.4.0
AssetID returns the asset ID of the virtual transaction. It returns an error if the virtual transaction has no inputs or if the inputs have different asset IDs.
func (*VPacket) B64Encode ¶
B64Encode returns the base64 encoding of the serialization of the current virtual packet, or an error if the encoding fails.
func (*VPacket) EncodeAsPsbt ¶
EncodeAsPsbt returns the PSBT encoding of the current virtual packet, or an error if the encoding fails.
func (*VPacket) FirstInteractiveOutput ¶
FirstInteractiveOutput returns the first interactive output in the virtual transaction.
func (*VPacket) FirstNonSplitRootOutput ¶
FirstNonSplitRootOutput returns the first non-change output in the virtual transaction.
func (*VPacket) HasInteractiveOutput ¶
HasInteractiveOutput determines if this virtual transaction has an interactive output.
func (*VPacket) HasSplitCommitment ¶
HasSplitCommitment determines if this transaction results in an asset split. This is either the case if the value of the input asset is split or if one of the outputs is non-interactive (in which case we need to have a zero value tombstone asset in the change output).
func (*VPacket) HasSplitRootOutput ¶
HasSplitRootOutput determines if this virtual transaction has a split root output.
func (*VPacket) Serialize ¶
Serialize creates a binary serialization of the referenced VPacket struct with lexicographical ordering (by key) of the subsections.
func (*VPacket) SetInputAsset ¶
SetInputAsset sets the input asset that is being spent.
func (*VPacket) SplitRootOutput ¶
SplitRootOutput returns the split root output in the virtual transaction, or an error if there is none or more than one.
type VPacketVersion ¶ added in v0.4.0
type VPacketVersion uint8
VPacketVersion is the version of the virtual transaction. This can signal a new virtual PSBT format, or other version-specific behavior.
const ( // V0 is the initial VPacket version. All VInputs and VOutputs use // TapCommitments with version V0 or V1. V0 VPacketVersion = 0 // V1 VPackets require V2 TapCommitments for all VOutputs. V1 VPacketVersion = 1 )
type ValidTestCase ¶ added in v0.3.0
type ValidTestCase struct { Packet *TestVPacket `json:"packet"` Expected string `json:"expected"` Comment string `json:"comment"` }