@@ -21,22 +21,20 @@ import (
2121 "github.com/lightninglabs/taproot-assets/commitment"
2222 "github.com/lightninglabs/taproot-assets/fn"
2323 "github.com/lightninglabs/taproot-assets/proof"
24+ "github.com/lightninglabs/taproot-assets/tapscript"
2425 "github.com/lightninglabs/taproot-assets/universe"
2526 "github.com/lightningnetwork/lnd/chainntnfs"
27+ "github.com/lightningnetwork/lnd/lnwallet/chainfee"
2628 "golang.org/x/exp/maps"
2729 "golang.org/x/sync/errgroup"
2830)
2931
3032var (
31- // GenesisDummyScript is a dummy script that we'll use to fund the
32- // initial PSBT packet that'll create initial set of assets. It's the
33- // same size as a encoded P2TR output.
34- GenesisDummyScript [34 ]byte
3533
3634 // DummyGenesisTxOut is the dummy TxOut we'll place in the PSBt funding
3735 // request to make sure we leave enough room for change and fees.
3836 DummyGenesisTxOut = wire.TxOut {
39- PkScript : GenesisDummyScript [:],
37+ PkScript : tapscript . GenesisDummyScript [:],
4038 Value : int64 (GenesisAmtSats ),
4139 }
4240
@@ -72,6 +70,10 @@ type BatchCaretakerConfig struct {
7270 // Batch is the minting batch that this caretaker is responsible for?
7371 Batch * MintingBatch
7472
73+ // BatchFeeRate is an optional manually-set feerate specified when
74+ // finalizing a batch.
75+ BatchFeeRate * chainfee.SatPerKWeight
76+
7577 GardenKit
7678
7779 // BroadcastCompleteChan is used to signal back to the caller that the
@@ -386,13 +388,26 @@ func (b *BatchCaretaker) fundGenesisPsbt(ctx context.Context) (*FundedPsbt, erro
386388 log .Infof ("BatchCaretaker(%x): creating skeleton PSBT" , b .batchKey [:])
387389 log .Tracef ("PSBT: %v" , spew .Sdump (genesisPkt ))
388390
389- feeRate , err := b .cfg .ChainBridge .EstimateFee (
390- ctx , GenesisConfTarget ,
391- )
392- if err != nil {
393- return nil , fmt .Errorf ("unable to estimate fee: %w" , err )
391+ // If a fee rate was manually assigned for this batch, use that instead
392+ // of a fee rate estimate.
393+ var feeRate chainfee.SatPerKWeight
394+ switch {
395+ case b .cfg .BatchFeeRate != nil :
396+ feeRate = * b .cfg .BatchFeeRate
397+ log .Infof ("BatchCaretaker(%x): using manual fee rate" )
398+
399+ default :
400+ feeRate , err = b .cfg .ChainBridge .EstimateFee (
401+ ctx , GenesisConfTarget ,
402+ )
403+ if err != nil {
404+ return nil , fmt .Errorf ("unable to estimate fee: %w" , err )
405+ }
394406 }
395407
408+ log .Infof ("BatchCaretaker(%x): using fee rate: %v" ,
409+ feeRate .FeePerKVByte ().String ())
410+
396411 fundedGenesisPkt , err := b .cfg .Wallet .FundPsbt (
397412 ctx , genesisPkt , 1 , feeRate ,
398413 )
@@ -723,6 +738,8 @@ func (b *BatchCaretaker) stateStep(currentState BatchState) (BatchState, error)
723738 }
724739 b .cfg .Batch .GenesisPacket .ChainFees = chainFees
725740
741+ log .Infof ("BatchCaretaker(%x): GenesisPacket absolute fee: " +
742+ "%d sats" , chainFees )
726743 log .Infof ("BatchCaretaker(%x): GenesisPacket finalized" ,
727744 b .batchKey [:])
728745 log .Tracef ("GenesisPacket: %v" , spew .Sdump (signedPkt ))
0 commit comments