Skip to content

Commit 6f968f2

Browse files
committed
supplycommit: add PSBT input for spending previous supply commit output
When creating a supply commitment transaction, there are two types of inputs that can be spent: * Pre-commitment outputs from mint anchor transactions * Outputs from previous supply commitment transactions This commit adds support for a PSBT input to handle the latter case, allowing spending of a previous supply commitment transaction output.
1 parent 2c47a9f commit 6f968f2

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

universe/supplycommit/transitions.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,26 @@ func newRootCommitment(ctx context.Context,
394394
// as an input to the new transaction. Pre-commitments are only present
395395
// on mint transactions where as the old commitment is the last
396396
// commitment that was broadcast.
397-
//
398-
// TODO(ffranr): Do we have everything we need to fund a PSBT here?
399397
oldCommitment.WhenSome(func(r RootCommitment) {
400398
newCommitTx.AddTxIn(r.TxIn())
399+
400+
bip32Derivation, trBip32Derivation :=
401+
tappsbt.Bip32DerivationFromKeyDesc(
402+
r.InternalKey, chainParams.HDCoinType,
403+
)
404+
405+
witnessUtxo := r.Txn.TxOut[r.TxOutIdx]
406+
407+
packetPInputs = append(packetPInputs, psbt.PInput{
408+
WitnessUtxo: witnessUtxo,
409+
Bip32Derivation: []*psbt.Bip32Derivation{
410+
bip32Derivation,
411+
},
412+
TaprootBip32Derivation: []*psbt.TaprootBip32Derivation{
413+
trBip32Derivation,
414+
},
415+
TaprootInternalKey: trBip32Derivation.XOnlyPubKey,
416+
})
401417
})
402418

403419
// With the inputs available, derive the supply commitment output.

0 commit comments

Comments
 (0)