@@ -12,6 +12,7 @@ import (
1212 "github.com/btcsuite/btcd/btcec/v2"
1313 "github.com/btcsuite/btcd/btcec/v2/schnorr"
1414 "github.com/btcsuite/btcd/btcutil"
15+ "github.com/btcsuite/btcd/btcutil/psbt"
1516 "github.com/btcsuite/btcd/chaincfg/chainhash"
1617 "github.com/btcsuite/btcd/txscript"
1718 "github.com/lightninglabs/taproot-assets/address"
@@ -147,6 +148,15 @@ type Allocation struct {
147148 // output.
148149 InternalKey * btcec.PublicKey
149150
151+ // Bip32Derivation is the BIP32 derivation info for the internal key.
152+ // This is used to preserve the key derivation through the allocation
153+ // flow so that PSBTs can be properly signed.
154+ Bip32Derivation []* psbt.Bip32Derivation
155+
156+ // TaprootBip32Derivation is the taproot BIP32 derivation info for the
157+ // internal key.
158+ TaprootBip32Derivation []* psbt.TaprootBip32Derivation
159+
150160 // NonAssetLeaves is the full list of TapLeaf nodes that aren't any
151161 // asset commitments. This is used to construct the tapscript sibling
152162 // for the asset commitment. This is mutually exclusive to the
@@ -616,17 +626,19 @@ func allocatePiece(p piece, a Allocation, toFill uint64,
616626
617627 deliveryAddr := a .ProofDeliveryAddress
618628 vOut := & tappsbt.VOutput {
619- AssetVersion : a .AssetVersion ,
620- Interactive : interactive ,
621- AnchorOutputIndex : a .OutputIndex ,
622- AnchorOutputInternalKey : a .InternalKey ,
623- AnchorOutputTapscriptSibling : sibling ,
624- ScriptKey : scriptKey ,
625- ProofDeliveryAddress : deliveryAddr ,
626- LockTime : a .LockTime ,
627- RelativeLockTime : uint64 (a .Sequence ),
628- AltLeaves : a .AltLeaves ,
629- Address : a .Address ,
629+ AssetVersion : a .AssetVersion ,
630+ Interactive : interactive ,
631+ AnchorOutputIndex : a .OutputIndex ,
632+ AnchorOutputInternalKey : a .InternalKey ,
633+ AnchorOutputBip32Derivation : a .Bip32Derivation ,
634+ AnchorOutputTaprootBip32Derivation : a .TaprootBip32Derivation ,
635+ AnchorOutputTapscriptSibling : sibling ,
636+ ScriptKey : scriptKey ,
637+ ProofDeliveryAddress : deliveryAddr ,
638+ LockTime : a .LockTime ,
639+ RelativeLockTime : uint64 (a .Sequence ),
640+ AltLeaves : a .AltLeaves ,
641+ Address : a .Address ,
630642 }
631643
632644 // If we've allocated all pieces, or we don't need to allocate anything
@@ -845,6 +857,8 @@ func setAllocationFieldsFromOutput(alloc *Allocation, vOut *tappsbt.VOutput) {
845857 alloc .AssetVersion = vOut .AssetVersion
846858 alloc .OutputIndex = vOut .AnchorOutputIndex
847859 alloc .InternalKey = vOut .AnchorOutputInternalKey
860+ alloc .Bip32Derivation = vOut .AnchorOutputBip32Derivation
861+ alloc .TaprootBip32Derivation = vOut .AnchorOutputTaprootBip32Derivation
848862 alloc .GenScriptKey = StaticScriptKeyGen (vOut .ScriptKey )
849863 alloc .Sequence = uint32 (vOut .RelativeLockTime )
850864 alloc .LockTime = vOut .LockTime
0 commit comments