Skip to content

Commit d5ac7d0

Browse files
committed
tapgarden: refactor fundGenesisPsbt to pass in pending batch
Pass the pending batch into fundGenesisPsbt and convert it into a standalone function rather than a method on ChainPlanter. This change makes it easier to call fundGenesisPsbt from unit tests.
1 parent fbc9e29 commit d5ac7d0

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tapgarden/planter.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -937,8 +937,8 @@ type WalletFundPsbt = func(ctx context.Context,
937937
// (all outputs need to hold some BTC to not be dust), and with a dummy script.
938938
// We need to use a dummy script as we can't know the actual script key since
939939
// that's dependent on the genesis outpoint.
940-
func (c *ChainPlanter) fundGenesisPsbt(ctx context.Context,
941-
batchKey asset.SerializedKey,
940+
func fundGenesisPsbt(ctx context.Context,
941+
pendingBatch *MintingBatch, batchKey asset.SerializedKey,
942942
walletFundPsbt WalletFundPsbt) (FundedMintAnchorPsbt, error) {
943943

944944
var zero FundedMintAnchorPsbt
@@ -947,8 +947,8 @@ func (c *ChainPlanter) fundGenesisPsbt(ctx context.Context,
947947
// If universe commitments are enabled, we formulate a pre-commitment
948948
// output. This output is spent by the universe commitment transaction.
949949
var preCommitmentOut fn.Option[PreCommitmentOutput]
950-
if c.pendingBatch != nil && c.pendingBatch.UniverseCommitments {
951-
out, err := preCommitmentOutput(c.pendingBatch)
950+
if pendingBatch != nil && pendingBatch.UniverseCommitments {
951+
out, err := preCommitmentOutput(pendingBatch)
952952
if err != nil {
953953
return zero, fmt.Errorf("unable to create "+
954954
"pre-commitment output: %w", err)
@@ -2044,8 +2044,8 @@ func (c *ChainPlanter) fundBatch(ctx context.Context, params FundParams,
20442044
return *fundedPkt, nil
20452045
}
20462046

2047-
mintAnchorTx, err := c.fundGenesisPsbt(
2048-
ctx, batchKey, walletFundPsbt,
2047+
mintAnchorTx, err := fundGenesisPsbt(
2048+
ctx, c.pendingBatch, batchKey, walletFundPsbt,
20492049
)
20502050
if err != nil {
20512051
return fmt.Errorf("unable to fund minting PSBT for "+

0 commit comments

Comments
 (0)