Documentation
¶
Index ¶
- Constants
- Variables
- func AnchorOutputScript(internalKey *btcec.PublicKey, siblingPreimage *commitment.TapscriptPreimage, ...) ([]byte, chainhash.Hash, chainhash.Hash, error)
- func AssertAnchorTimeLocks(btcPkt *psbt.Packet, vPkt *tappsbt.VPacket)
- func AssertInputAnchorsEqual(packets []*tappsbt.VPacket) error
- func AssertInputsUnique(packets []*tappsbt.VPacket) error
- func AssertOutputAltLeavesValid(vPackets []*tappsbt.VPacket) error
- func AssertOutputAnchorsEqual(packets []*tappsbt.VPacket) error
- func AssetSortForInputs(i, j asset.Asset) int
- func AssignOutputCommitments(allocations []*Allocation, outCommitments tappsbt.OutputCommitments) error
- func CreateAnchorTx(vPackets []*tappsbt.VPacket) (*psbt.Packet, error)
- func CreateDummyOutput() *wire.TxOut
- func CreateOutputCommitments(packets []*tappsbt.VPacket, opts ...OutputCommitmentOption) (tappsbt.OutputCommitments, error)
- func CreateProofSuffix(chainTx *wire.MsgTx, finalTxPacketOutputs []psbt.POutput, ...) (*proof.Proof, error)
- func CreateProofSuffixCustom(finalTx *wire.MsgTx, vPacket *tappsbt.VPacket, ...) (*proof.Proof, error)
- func CreateTaprootSignature(vIn *tappsbt.VInput, virtualTx *wire.MsgTx, idx int, txSigner tapscript.Signer) (wire.TxWitness, error)
- func DisableLog()
- func DistributeCoins(inputs []*proof.Proof, allocations []*Allocation, ...) ([]*tappsbt.VPacket, error)
- func ExtractUnSpendable(c *commitment.TapCommitment) []*asset.Asset
- func FilterByType(allocType AllocationType) func(a *Allocation) bool
- func FilterByTypeExclude(excludeAllocType AllocationType) func(a *Allocation) bool
- func GroupProofsByAssetID(proofs []*proof.Proof) map[asset.ID][]*proof.Proof
- func HasInput(tx *wire.MsgTx, outpoint wire.OutPoint) bool
- func InPlaceAllocationSort(allocations []*Allocation)
- func LogCommitment(prefix string, idx int, tapCommitment *commitment.TapCommitment, ...)
- func PrepareAnchoringTemplate(vPackets []*tappsbt.VPacket) (*psbt.Packet, error)
- func PrepareOutputAssets(ctx context.Context, vPkt *tappsbt.VPacket) error
- func RemoveAssetsFromCommitment(c *commitment.TapCommitment, assets []*asset.Asset) (*commitment.TapCommitment, error)
- func RemovePacketsFromCommitment(c *commitment.TapCommitment, packets []*tappsbt.VPacket) (*commitment.TapCommitment, error)
- func SignVirtualTransaction(vPkt *tappsbt.VPacket, signer tapscript.Signer, ...) error
- func UpdateTaprootOutputKeys(btcPacket *psbt.Packet, vPkt *tappsbt.VPacket, ...) error
- func UseLogger(logger btclog.Logger)
- func ValidateAnchorInputs(anchorPacket *psbt.Packet, packets []*tappsbt.VPacket, ...) error
- func ValidateAnchorOutputs(anchorPacket *psbt.Packet, packets []*tappsbt.VPacket, ...) error
- func ValidateCommitmentKeysUnique(packets []*tappsbt.VPacket) error
- func ValidateVPacketVersions(vPackets []*tappsbt.VPacket) error
- type Allocation
- type AllocationType
- type AnchorTransaction
- type AssetGroupQuerier
- type ExclusionProofGenerator
- type FundedPsbt
- type FundingDescriptor
- type IsAnchor
- type OutputCommitmentConfig
- type OutputCommitmentOption
- type ScriptKeyGen
Constants ¶
const ( // DummyAmtSats is the default amount of sats we'll use in Bitcoin // outputs embedding Taproot Asset commitments. This value just needs to // be greater than dust, and we assume that this value is updated to // match the input asset bearing UTXOs before finalizing the transfer // TX. DummyAmtSats = btcutil.Amount(1_000) // SendConfTarget is the confirmation target we'll use to query for // a fee estimate. SendConfTarget = 6 )
const Subsystem = "SEND"
Subsystem defines the logging code for this subsystem.
Variables ¶
var ( // ErrMissingInputs is an error that is returned if no inputs were // provided. ErrMissingInputs = fmt.Errorf("no inputs provided") // ErrMissingAllocations is an error that is returned if no allocations // were provided. ErrMissingAllocations = fmt.Errorf("no allocations provided") // ErrInputTypesNotEqual is an error that is returned if the input types // are not all the same. ErrInputTypesNotEqual = fmt.Errorf("input types not all equal") // ErrInputGroupMismatch is an error that is returned if the input // assets don't all belong to the same asset group. ErrInputGroupMismatch = fmt.Errorf("input assets not all of same group") // ErrInputOutputSumMismatch is an error that is returned if the sum of // the input asset proofs does not match the sum of the output // allocations. ErrInputOutputSumMismatch = fmt.Errorf("input and output sum mismatch") // ErrCommitmentNotSet is an error that is returned if the output // commitment is not set for an allocation. ErrCommitmentNotSet = fmt.Errorf("output commitment not set") // ErrInvalidSibling is an error that is returned if both non-asset // leaves and sibling preimage are set for an allocation. ErrInvalidSibling = errors.New( "both non-asset leaves and sibling preimage set", ) // ErrScriptKeyGenMissing is an error that is returned if the script key // generator function is not set. ErrScriptKeyGenMissing = errors.New( "script key generator function not set for asset allocation", ) // ErrNoSplitRoot is returned if a non-interactive send doesn't specify // which output should house the split root asset. ErrNoSplitRoot = errors.New( "non-interactive transfers must specify which output should " + "house the split root asset", ) )
var ( // ErrInvalidCollectibleSplit is returned when a collectible is split // into more than two outputs. ErrInvalidCollectibleSplit = errors.New( "fund: invalid collectible split", ) // ErrInvalidChangeOutputLocation is returned when the change output is // not at the expected location (index 0). ErrInvalidChangeOutputLocation = errors.New( "fund: invalid change output location, should be index 0", ) // ErrInvalidSplitAmounts is returned when the split amounts don't add // up to the amount of the asset being spent. ErrInvalidSplitAmounts = errors.New( "fund: invalid split amounts, sum doesn't match input", ) // ErrMissingInputAsset is an error returned when we attempt to spend // to a Taproot Asset address from an input that does not contain // the matching asset. ErrMissingInputAsset = errors.New( "send: Input does not contain requested asset", ) // ErrInsufficientInputAssets is an error returned when we attempt // to spend to a Taproot Asset address from a set of inputs which // contain an insufficient amount of total funds. ErrInsufficientInputAssets = errors.New( "send: Input assets total funds is insufficient", ) // ErrInvalidOutputIndexes is an error returned when we attempt to spend // to Bitcoin output indexes that do not start at 0 or // are not continuous. ErrInvalidOutputIndexes = errors.New( "send: Output indexes not starting at 0 and continuous", ) // ErrMissingSplitAsset is an error returned when we attempt to look up // a split asset in a map and the specified asset is not found. ErrMissingSplitAsset = errors.New( "send: split asset not found", ) // ErrMissingAssetCommitment is an error returned when we attempt to // look up an Asset commitment in a map and the specified commitment // is not found. ErrMissingAssetCommitment = errors.New( "send: Asset commitment not found", ) // ErrMissingTapCommitment is an error returned when we attempt to look // up a Taproot Asset commitment in a map and the specified commitment // is not found. ErrMissingTapCommitment = errors.New( "send: Taproot Asset commitment not found", ) // ErrInvalidAnchorOutputInfo is an error returned when the anchor output // information on a virtual transaction output is invalid. ErrInvalidAnchorOutputInfo = errors.New( "send: invalid anchor output info", ) // ErrInvalidAnchorInputInfo is an error returned when the anchor input // information on a virtual transaction input is invalid. ErrInvalidAnchorInputInfo = errors.New( "send: invalid anchor input info", ) // ErrAssetMissing is an error returned when an asset is missing from a // virtual transaction. ErrAssetMissing = errors.New("asset missing") // ErrAssetNotSigned is an error returned when an asset is not signed // in a virtual transaction that was already committed to an anchor // output. ErrAssetNotSigned = errors.New("asset not signed") // ErrNoRootLocator is an error that is returned when a split commitment // is created without a split root output. ErrNoRootLocator = errors.New( "cannot create split commitment without split root output", ) // ErrDuplicateScriptKeys is an error that is returned when the outputs // of a virtual packet contain duplicate script keys. ErrDuplicateScriptKeys = errors.New( "send: duplicate script keys in outputs - cannot re-use same " + "script key in same transaction (e.g. cannot send to " + "same address more than once)", ) )
var ( // GenesisDummyScript is a dummy script that we'll use to fund the // initial PSBT packet that'll create initial set of assets. It's the // same size as an encoded P2TR output and has a valid P2TR prefix. GenesisDummyScript = append( []byte{txscript.OP_1, txscript.OP_DATA_32}, bytes.Repeat([]byte{0x00}, 32)..., ) )
Functions ¶
func AnchorOutputScript ¶
func AnchorOutputScript(internalKey *btcec.PublicKey, siblingPreimage *commitment.TapscriptPreimage, anchorCommitment *commitment.TapCommitment) ([]byte, chainhash.Hash, chainhash.Hash, error)
AnchorOutputScript creates the anchor output script given an internal key, tapscript sibling and the TapCommitment. It also returns the merkle root and taproot asset root for the commitment.
func AssertAnchorTimeLocks ¶
AssertAnchorTimeLocks makes sure the anchor transaction and its inputs have the correct lock time and sequence set, according to the assets being spent.
func AssertInputAnchorsEqual ¶
AssertInputAnchorsEqual makes sure that the anchor input information for each input of the virtual packets that anchors to the same BTC level input is identical.
func AssertInputsUnique ¶ added in v0.5.0
AssertInputsUnique makes sure that every input across all virtual packets is referencing a unique input asset, which is identified by the input PrevID.
func AssertOutputAltLeavesValid ¶ added in v0.5.0
AssertOutputAltLeavesValid checks that, for each anchor output, the AltLeaves carried by all packets assigned to that output can be used to construct an AltCommitment.
func AssertOutputAnchorsEqual ¶
AssertOutputAnchorsEqual makes sure that the anchor output information for each output of the virtual packets that anchors to the same BTC level output is identical.
func AssetSortForInputs ¶ added in v0.6.0
AssetSortForInputs is a comparison function that should be used to sort asset inputs by amount (in reverse order) and then by script key. Using this function everywhere we sort inputs will ensure that the inputs are always in a predictable and stable order.
func AssignOutputCommitments ¶ added in v0.6.0
func AssignOutputCommitments(allocations []*Allocation, outCommitments tappsbt.OutputCommitments) error
AssignOutputCommitments assigns the output commitments keyed by the output index to the corresponding allocations.
func CreateAnchorTx ¶
CreateAnchorTx creates a template BTC anchor TX with dummy outputs.
func CreateDummyOutput ¶
CreateDummyOutput creates a new Bitcoin transaction output that is later used to embed a Taproot Asset commitment.
func CreateOutputCommitments ¶
func CreateOutputCommitments(packets []*tappsbt.VPacket, opts ...OutputCommitmentOption) (tappsbt.OutputCommitments, error)
CreateOutputCommitments creates the final set of Taproot asset commitments representing the asset sends of the given packets of active and passive assets.
func CreateProofSuffix ¶
func CreateProofSuffix(chainTx *wire.MsgTx, finalTxPacketOutputs []psbt.POutput, vPacket *tappsbt.VPacket, outputCommitments tappsbt.OutputCommitments, outIndex int, allAnchoredVPackets []*tappsbt.VPacket, opts ...proof.GenOption) (*proof.Proof, error)
CreateProofSuffix creates a new proof for the given virtual transaction output indicated with outIndex within vPacket. This is the final state transition that will be added to the proofs of the receiver. The proof returned will have all the Taproot Asset level proof information, but contains dummy data for the on-chain part and potentially the anchor transaction itself, if chainTx is not yet fully final. Only the outputs of chainTx need to be final and correspond to the PSBT outputs given as finalTxPacketOutputs.
func CreateProofSuffixCustom ¶
func CreateProofSuffixCustom(finalTx *wire.MsgTx, vPacket *tappsbt.VPacket, outputCommitments tappsbt.OutputCommitments, outIndex int, allAnchoredVPackets []*tappsbt.VPacket, genExclusionProofs ExclusionProofGenerator, opts ...proof.GenOption) (*proof.Proof, error)
CreateProofSuffixCustom creates the new proof for the given virtual transaction output indicated with outIndex within vPacket. This is the final state transition that will be added to the proofs of the receiver. The proof returned will have all the Taproot Asset level proof information, but contains dummy data for the on-chain part and potentially the anchor transaction itself, if chainTx is not yet fully final or even nil. If chainTx is nil, it must be set on the proof later manually to make the proof valid. The exclusion proof generator function must add an exclusion proof for each P2TR on-chain output that is NOT an asset commitment (e.g. P2TR change outputs or other pure BTC P2TR outputs).
func CreateTaprootSignature ¶
func CreateTaprootSignature(vIn *tappsbt.VInput, virtualTx *wire.MsgTx, idx int, txSigner tapscript.Signer) (wire.TxWitness, error)
CreateTaprootSignature creates a Taproot signature for the given asset input. Depending on the fields set in the input, this will either create a key path spend or a script path spend.
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.
func DistributeCoins ¶ added in v0.6.0
func DistributeCoins(inputs []*proof.Proof, allocations []*Allocation, chainParams *address.ChainParams, interactive bool, vPktVersion tappsbt.VPacketVersion) ([]*tappsbt.VPacket, error)
DistributeCoins allocates a set of inputs (extracted from the given input proofs) to virtual outputs as specified by the allocations given. It returns a list of virtual packets (one for each distinct asset ID) with virtual outputs that sum up to the amounts specified in the allocations. The main purpose of this function is to deterministically re-distribute heterogeneous asset outputs (asset UTXOs of different sizes from different tranches/asset IDs) according to the distribution rules provided as "allocations".
func ExtractUnSpendable ¶
func ExtractUnSpendable(c *commitment.TapCommitment) []*asset.Asset
ExtractUnSpendable extracts all tombstones and burns from the active input commitment.
func FilterByType ¶ added in v0.6.0
func FilterByType(allocType AllocationType) func(a *Allocation) bool
FilterByType returns a filter function that can be used to filter a list of allocations by the given allocation type.
func FilterByTypeExclude ¶ added in v0.6.0
func FilterByTypeExclude( excludeAllocType AllocationType) func(a *Allocation) bool
FilterByTypeExclude returns a filter function that can be used to filter a list of allocations by excluding the given allocation type.
func GroupProofsByAssetID ¶ added in v0.6.0
GroupProofsByAssetID groups the given proofs by their asset ID.
func HasInput ¶
HasInput returns true if the given transaction has an input that spends the given outpoint.
func InPlaceAllocationSort ¶ added in v0.6.0
func InPlaceAllocationSort(allocations []*Allocation)
InPlaceAllocationSort performs an in-place sort of output allocations.
The sort applied is a modified BIP69 sort, that uses the CLTV values of HTLCs as a tiebreaker in case two HTLC outputs have an identical amount and pkScript. The pkScripts can be the same if they share the same payment hash, but since the CLTV is enforced via the nLockTime of the second-layer transactions, the script does not directly commit to them. Instead, the CLTVs must be supplied separately to act as a tie-breaker, otherwise we may produce invalid HTLC signatures if the receiver produces an alternative ordering during verification. Because multiple shards of the same MPP payment can be identical in all other fields, we also use the HtlcIndex as a final tie-breaker.
NOTE: Commitment and commitment anchor outputs should have a 0 CLTV and HtlcIndex value.
func LogCommitment ¶
func LogCommitment(prefix string, idx int, tapCommitment *commitment.TapCommitment, internalKey *btcec.PublicKey, pkScript, trimmedMerkleRoot []byte)
LogCommitment logs the given Taproot Asset commitment to the log as a trace message. This is a no-op if the log level is not set to trace.
func PrepareAnchoringTemplate ¶
PrepareAnchoringTemplate creates a BTC level PSBT packet that can be used to anchor the given virtual packets. The PSBT packet is created with the necessary inputs and outputs to anchor the virtual packets, but without any signatures. The main difference to CreateAnchorTx is that this function populates the inputs with the witness UTXO and derivation path information.
func PrepareOutputAssets ¶
PrepareOutputAssets prepares the assets of the given outputs depending on the amounts set on the transaction. If a split is necessary (non-interactive or partial amount send) it computes a split commitment with the given inputs and spend information. The inputs MUST be checked as valid beforehand and the change output is expected to be declared as such (and be at index 0).
func RemoveAssetsFromCommitment ¶
func RemoveAssetsFromCommitment(c *commitment.TapCommitment, assets []*asset.Asset) (*commitment.TapCommitment, error)
RemoveAssetsFromCommitment removes all assets from the given commitment and only returns a tree of the remaining commitments.
func RemovePacketsFromCommitment ¶
func RemovePacketsFromCommitment(c *commitment.TapCommitment, packets []*tappsbt.VPacket) (*commitment.TapCommitment, error)
RemovePacketsFromCommitment removes all assets within the virtual transactions from the given commitment.
func SignVirtualTransaction ¶
func SignVirtualTransaction(vPkt *tappsbt.VPacket, signer tapscript.Signer, validator tapscript.WitnessValidator) error
SignVirtualTransaction updates the new asset (the root asset located at the change output in case of a non-interactive or partial amount send or the full asset in case of an interactive full amount send) by creating a signature over the asset transfer, verifying the transfer with the Taproot Asset VM, and attaching that signature to the new Asset.
func UpdateTaprootOutputKeys ¶
func UpdateTaprootOutputKeys(btcPacket *psbt.Packet, vPkt *tappsbt.VPacket, outputCommitments tappsbt.OutputCommitments) error
UpdateTaprootOutputKeys updates a PSBT with outputs embedding TapCommitments involved in an asset send. The sender must attach the Bitcoin input holding the corresponding Taproot Asset input asset to this PSBT before finalizing the TX. Locators MUST be checked beforehand. Since this is called when the anchor transaction and all assets are final, we also make sure any time locks from the assets are properly bubbled up to the BTC level.
func UseLogger ¶
func UseLogger(logger btclog.Logger)
UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.
func ValidateAnchorInputs ¶
func ValidateAnchorInputs(anchorPacket *psbt.Packet, packets []*tappsbt.VPacket, prunedAssets map[wire.OutPoint][]*asset.Asset) error
ValidateAnchorInputs checks that the anchor inputs of the virtual packets are valid and consistent with the provided BTC level PSBT packet.
func ValidateAnchorOutputs ¶
func ValidateAnchorOutputs(anchorPacket *psbt.Packet, packets []*tappsbt.VPacket, updateDatabaseHints bool) error
ValidateAnchorOutputs checks that the anchor outputs of the virtual packets are valid and consistent with the provided BTC level PSBT packet. When calling this function, everything must be ready to be signed on the BTC level, meaning all asset level information must be final (including the asset signatures for ASSET_VERSION_V0 assets). If the updateDatabaseHints flag is set, the function will also make sure the extra information (merkle root and taproot asset root) is set in the PSBT packet's outputs. That info is required to create the transfer output database entry.
func ValidateCommitmentKeysUnique ¶ added in v0.5.0
ValidateCommitmentKeysUnique makes sure the outputs of a set of virtual packets don't lead to collisions in and of the trees (e.g. two asset outputs with the same asset ID and script key in the same anchor output) or with exclusion proofs (e.g. two asset outputs with the same asset ID and script key in different anchor outputs).
func ValidateVPacketVersions ¶
ValidateVPacketVersions checks that all virtual packets are the same version.
Types ¶
type Allocation ¶ added in v0.6.0
type Allocation struct { // Type is the type of the asset allocation. Type AllocationType // OutputIndex is the output index of the on-chain transaction which // the asset allocation is meant for. OutputIndex uint32 // SplitRoot indicates whether the virtual output(s) created for the // allocation should house the split root asset. SplitRoot bool // InternalKey is the internal key used for the on-chain transaction // output. InternalKey *btcec.PublicKey // NonAssetLeaves is the full list of TapLeaf nodes that aren't any // asset commitments. This is used to construct the tapscript sibling // for the asset commitment. This is mutually exclusive to the // SiblingPreimage field below, only one of them (or none) should be // set. If this is a non-asset allocation and both NonAssetLeaves is // empty and no SiblingPreimage is set, then we assume a BIP-0086 // output. NonAssetLeaves []txscript.TapLeaf // SiblingPreimage is the tapscript sibling preimage that is used to // create the tapscript sibling for the asset commitment. This is // mutually exclusive to the NonAssetLeaves above, only one of them (or // none) should be set. If this is a non-asset allocation and both // NonAssetLeaves is empty and no SiblingPreimage is set, then we assume // a BIP-0086 output. SiblingPreimage *commitment.TapscriptPreimage // GenScriptKey is a function that returns the Taproot tweaked key // encoding the different spend conditions possible for the asset // allocation for a certain asset ID. GenScriptKey ScriptKeyGen // Amount is the amount of units that should be allocated in total. // Available units from different UTXOs are distributed up to this total // amount in a deterministic way. Amount uint64 // AssetVersion is the version that the asset allocation should use. AssetVersion asset.Version // BtcAmount is the amount of BTC that should be sent to the output // address of the anchor transaction. BtcAmount btcutil.Amount // SortTaprootKeyBytes is the Schnorr serialized Taproot output key of // the on-chain P2TR output that would be created if there was no asset // commitment present. This field should be used for sorting purposes. SortTaprootKeyBytes []byte // SortCLTV is the SortCLTV timeout for the asset allocation. This is // only relevant for sorting purposes and is expected to be zero for any // non-HTLC allocation. SortCLTV uint32 // Sequence is the CSV value for the asset allocation. This is only // relevant for HTLC second level transactions. This value will be set // as the relative time lock on the virtual output. Sequence uint32 // LockTime is the actual CLTV value that will be set on the output. LockTime uint64 // HtlcIndex is the index of the HTLC that the allocation is for. This // is only relevant for HTLC allocations. HtlcIndex input.HtlcIndex // OutputCommitment is the taproot output commitment that is set after // fully distributing the coins and creating the asset and TAP trees. OutputCommitment *commitment.TapCommitment // ProofDeliveryAddress is the address the proof courier should use to // upload the proof for this allocation. ProofDeliveryAddress *url.URL // AltLeaves represent data used to construct an Asset commitment, that // will be inserted in the output anchor Tap commitment. These // data-carrying leaves are used for a purpose distinct from // representing individual Taproot Assets. AltLeaves []asset.AltLeaf[asset.Asset] }
Allocation is a struct that tracks how many units of assets should be allocated to a specific output of an on-chain transaction. An allocation can be seen as a recipe/instruction to distribute a certain number of asset units to a specific output of an on-chain transaction. The output is mainly identified by its output index but also carries along additional information that is required for making sure the resulting on-chain outputs can be sorted in a deterministic way (that is almost but not exactly following the BIP-69 rules for sorting transaction outputs).
func AllocationsFromTemplate ¶ added in v0.6.0
AllocationsFromTemplate creates a list of allocations from a spend template. If there is no split output present in the template, one is created to carry potential change or a zero-value tombstone output in case of a non-interactive transfer. The script key for those change/tombstone outputs are set to the NUMS script key and need to be replaced with an actual script key (if the change is non-zero) after the coin distribution has been performed.
func (*Allocation) AuxLeaf ¶ added in v0.6.0
func (a *Allocation) AuxLeaf() (txscript.TapLeaf, error)
AuxLeaf returns the auxiliary leaf for the allocation. If the output commitment is not set, ErrCommitmentNotSet is returned.
func (*Allocation) FinalPkScript ¶ added in v0.6.0
func (a *Allocation) FinalPkScript() ([]byte, error)
FinalPkScript returns the pkScript calculated from the internal key, tapscript sibling and merkle root of the output commitment. If the output commitment is not set, ErrCommitmentNotSet is returned.
func (*Allocation) MatchesOutput ¶ added in v0.6.0
func (a *Allocation) MatchesOutput(pkScript []byte, value int64, cltv uint32, htlcIndex input.HtlcIndex) (bool, error)
MatchesOutput returns true if the unique identifying characteristics of an on-chain commitment output match this allocation. The pkScript is calculated from the internal key, tapscript sibling and merkle root of the output commitment. If the output commitment is not set an error is returned.
func (*Allocation) Validate ¶ added in v0.6.0
func (a *Allocation) Validate() error
Validate checks that the allocation is correctly set up and that the fields are consistent with each other.
type AllocationType ¶ added in v0.6.0
type AllocationType uint8
AllocationType is an enum that defines the different types of asset allocations that can be created.
const ( // AllocationTypeNoAssets is the default allocation type that is used // when the allocation type is not important or the allocation does not // carry any assets. AllocationTypeNoAssets AllocationType = 0 // CommitAllocationToLocal is an allocation type that is used for // allocating assets to the local party. CommitAllocationToLocal AllocationType = 1 // CommitAllocationToRemote is an allocation type that is used for // allocating assets to the remote party. CommitAllocationToRemote AllocationType = 2 // CommitAllocationHtlcIncoming is an allocation type that is used for // allocating assets to an incoming HTLC output. CommitAllocationHtlcIncoming AllocationType = 3 // CommitAllocationHtlcOutgoing is an allocation type that is used for // allocating assets to an outgoing HTLC output. CommitAllocationHtlcOutgoing AllocationType = 4 // SecondLevelHtlcAllocation is an allocation type that is used for // allocating assets to a second level HTLC output (HTLC-success for // HTLCs accepted by the local node, HTLC-timeout for HTLCs offered by // the local node). SecondLevelHtlcAllocation AllocationType = 5 )
type AnchorTransaction ¶
type AnchorTransaction struct { // FundedPsbt is the funded anchor TX at the state before it was signed, // with all the UTXO information intact for later exclusion proof // creation. FundedPsbt *FundedPsbt // FinalTx is the fully signed and finalized anchor TX that can be // broadcast to the network. FinalTx *wire.MsgTx // TargetFeeRate is the fee rate that was used to fund the anchor TX. TargetFeeRate chainfee.SatPerKWeight // ChainFees is the actual, total amount of sats paid in chain fees by // the anchor TX. ChainFees int64 }
AnchorTransaction is a type that holds all information about a BTC level anchor transaction that anchors multiple virtual asset transfer transactions.
func (*AnchorTransaction) Copy ¶
func (a *AnchorTransaction) Copy() *AnchorTransaction
Copy creates a deep copy of the AnchorTransaction.
type AssetGroupQuerier ¶
type AssetGroupQuerier interface { // QueryAssetGroup attempts to locate the asset group information // (genesis + group key) associated with a given asset. QueryAssetGroup(context.Context, asset.ID) (*asset.AssetGroup, error) }
AssetGroupQuerier is an interface that allows us to query for asset groups by asset ID.
type ExclusionProofGenerator ¶
type ExclusionProofGenerator func(target *proof.BaseProofParams, isAnchor IsAnchor) error
ExclusionProofGenerator is a function type that can be used to generate exclusion proofs for any BTC transaction outputs that don't carry any assets. The function should add the exclusion proofs to the given target proof parameters.
func NonAssetExclusionProofs ¶ added in v0.6.0
func NonAssetExclusionProofs( allocations []*Allocation) ExclusionProofGenerator
NonAssetExclusionProofs returns an exclusion proof generator that creates exclusion proofs for non-asset P2TR outputs in the given allocations.
type FundedPsbt ¶
type FundedPsbt struct { // Pkt is the PSBT packet itself. Pkt *psbt.Packet // ChangeOutputIndex denotes which output in the PSBT packet is the // change output. We use this to figure out which output will store our // Taproot Asset commitment (the non-change output). ChangeOutputIndex int32 // ChainFees is the amount in sats paid in on-chain fees for this // transaction. ChainFees int64 // LockedUTXOs is the set of UTXOs that were locked to create the PSBT // packet. LockedUTXOs []wire.OutPoint }
FundedPsbt represents a fully funded PSBT transaction.
func (*FundedPsbt) Copy ¶
func (f *FundedPsbt) Copy() *FundedPsbt
Copy creates a deep copy of the FundedPsbt.
type FundingDescriptor ¶
type FundingDescriptor struct { // AssetSpecifier is the asset specifier. AssetSpecifier asset.Specifier // Amount is the amount of the asset to transfer. Amount uint64 // PrevIDs is the set of inputs that can be used to fund the transfer. PrevIDs []asset.PrevID // DistinctSpecifier indicates whether we _only_ look at either the // group key _or_ the asset ID but not both. That means, if the group // key is set, we ignore the asset ID and allow multiple inputs of the // same group to be selected. DistinctSpecifier bool // ScriptKeyType is the type of script key the assets are expected to // have. If this is fn.None, then any script key type is allowed. ScriptKeyType fn.Option[asset.ScriptKeyType] }
FundingDescriptor describes the information that is needed to select and verify input assets in order to send to a specific recipient. It is a subset of the information contained in a Taproot Asset address.
func DescribeAddrs ¶
func DescribeAddrs(addrs []*address.Tap) (*FundingDescriptor, error)
DescribeAddrs extracts the recipient descriptors from a list of Taproot Asset addresses.
func DescribeRecipients ¶
func DescribeRecipients(ctx context.Context, vPkt *tappsbt.VPacket, groupQuerier AssetGroupQuerier) (*FundingDescriptor, error)
DescribeRecipients extracts the recipient descriptors from a Taproot Asset PSBT.
func (*FundingDescriptor) TapCommitmentKey ¶
func (r *FundingDescriptor) TapCommitmentKey() [32]byte
TapCommitmentKey is the key that maps to the root commitment for the asset group specified by a recipient descriptor.
type IsAnchor ¶
IsAnchor is a function type that can be used to determine if a given BTC transaction output at the given index is an anchor for committing assets.
type OutputCommitmentConfig ¶ added in v0.6.0
type OutputCommitmentConfig struct {
// contains filtered or unexported fields
}
OutputCommitmentConfig is a struct that holds the configuration for the output commitment creation process.
type OutputCommitmentOption ¶ added in v0.6.0
type OutputCommitmentOption func(*OutputCommitmentConfig)
OutputCommitmentOption is a functional option that can be used to configure the output commitment creation process.
func WithNoSTXOProofs ¶ added in v0.6.0
func WithNoSTXOProofs() OutputCommitmentOption
WithNoSTXOProofs is an option that can be used to skip the generation of STXO proofs. This should only be done for asset channels to preserve the backward compatibility with older peers.
type ScriptKeyGen ¶ added in v0.6.0
ScriptKeyGen is a function type that is used for generating a script key for an asset specific script key.
func StaticScriptKeyGen ¶ added in v0.6.0
func StaticScriptKeyGen(scriptKey asset.ScriptKey) ScriptKeyGen
StaticScriptKeyGen is a helper function that returns a script key generator function that always returns the same script key.
func StaticScriptPubKeyGen ¶ added in v0.6.0
func StaticScriptPubKeyGen(scriptPubKey *btcec.PublicKey) ScriptKeyGen
StaticScriptPubKeyGen is a helper function that returns a script key generator function that always returns the same script key, provided as a public key.