@@ -22,6 +22,7 @@ import (
2222 "github.com/btcsuite/btcd/wire"
2323 "github.com/btcsuite/btcwallet/waddrmgr"
2424 "github.com/lightninglabs/lndclient"
25+ "github.com/lightninglabs/taproot-assets/address"
2526 "github.com/lightninglabs/taproot-assets/asset"
2627 "github.com/lightninglabs/taproot-assets/fn"
2728 "github.com/lightninglabs/taproot-assets/internal/test"
@@ -163,6 +164,9 @@ type MintBatchOptions struct {
163164 // universeCommitments specifies whether to generate universe
164165 // commitments for the asset groups in this minting batch.
165166 universeCommitments bool
167+
168+ // skipFunding specifies whether to skip funding the genesis PSBT.
169+ skipFunding bool
166170}
167171
168172// MintBatchOption is a functional option for creating a new minting batch.
@@ -198,6 +202,13 @@ func WithUniverseCommitments(enabled bool) MintBatchOption {
198202 }
199203}
200204
205+ // WithSkipFunding specifies whether to skip funding the genesis PSBT.
206+ func WithSkipFunding () MintBatchOption {
207+ return func (options * MintBatchOptions ) {
208+ options .skipFunding = true
209+ }
210+ }
211+
201212// RandMintingBatch creates a new minting batch with only random seedlings
202213// populated for testing.
203214func RandMintingBatch (t testing.TB , opts ... MintBatchOption ) * MintingBatch {
@@ -259,6 +270,32 @@ func RandMintingBatch(t testing.TB, opts ...MintBatchOption) *MintingBatch {
259270 // requested amount. This check might help debug flakes in tests.
260271 require .Equal (t , options .totalSeedlings , len (batch .Seedlings ))
261272
273+ // Return early if funding is to be skipped.
274+ if options .skipFunding {
275+ return batch
276+ }
277+
278+ walletFundPsbt := func (ctx context.Context ,
279+ anchorPkt psbt.Packet ) (tapsend.FundedPsbt , error ) {
280+
281+ changeOutputIdx := FundGenesisTx (
282+ & anchorPkt , chainfee .FeePerKwFloor ,
283+ )
284+
285+ return tapsend.FundedPsbt {
286+ Pkt : & anchorPkt ,
287+ ChangeOutputIndex : int32 (changeOutputIdx ),
288+ }, nil
289+ }
290+
291+ // Fund genesis packet.
292+ ctx := context .Background ()
293+ fundedPsbt , err := fundGenesisPsbt (
294+ ctx , address .TestNet3Tap , batch , walletFundPsbt ,
295+ )
296+ require .NoError (t , err )
297+ batch .GenesisPacket = & fundedPsbt
298+
262299 return batch
263300}
264301
0 commit comments