@@ -14,6 +14,7 @@ import (
1414 "github.com/lightninglabs/taproot-assets/proof"
1515 "github.com/lightninglabs/taproot-assets/tapscript"
1616 "github.com/lightninglabs/taproot-assets/universe"
17+ "github.com/lightningnetwork/lnd/lnwallet/chainfee"
1718 "github.com/lightningnetwork/lnd/ticker"
1819 "golang.org/x/exp/maps"
1920)
@@ -227,9 +228,11 @@ func NewChainPlanter(cfg PlanterConfig) *ChainPlanter {
227228
228229// newCaretakerForBatch creates a new BatchCaretaker for a given batch and
229230// inserts it into the caretaker map.
230- func (c * ChainPlanter ) newCaretakerForBatch (batch * MintingBatch ) * BatchCaretaker {
231+ func (c * ChainPlanter ) newCaretakerForBatch (batch * MintingBatch ,
232+ feeRate * chainfee.SatPerKWeight ) * BatchCaretaker {
233+
231234 batchKey := asset .ToSerialized (batch .BatchKey .PubKey )
232- caretaker := NewBatchCaretaker ( & BatchCaretakerConfig {
235+ batchConfig := & BatchCaretakerConfig {
233236 Batch : batch ,
234237 GardenKit : c .cfg .GardenKit ,
235238 BroadcastCompleteChan : make (chan struct {}, 1 ),
@@ -241,7 +244,12 @@ func (c *ChainPlanter) newCaretakerForBatch(batch *MintingBatch) *BatchCaretaker
241244 CancelRespChan : make (chan CancelResp , 1 ),
242245 UpdateMintingProofs : c .updateMintingProofs ,
243246 ErrChan : c .cfg .ErrChan ,
244- })
247+ }
248+ if feeRate != nil {
249+ batchConfig .BatchFeeRate = feeRate
250+ }
251+
252+ caretaker := NewBatchCaretaker (batchConfig )
245253 c .caretakers [batchKey ] = caretaker
246254
247255 return caretaker
@@ -296,7 +304,8 @@ func (c *ChainPlanter) Start() error {
296304 batch .AssetMetas = make (AssetMetas )
297305 }
298306
299- caretaker := c .newCaretakerForBatch (batch )
307+ // TODO(jhb): Log manual fee rates?
308+ caretaker := c .newCaretakerForBatch (batch , nil )
300309 if err := caretaker .Start (); err != nil {
301310 startErr = err
302311 return
@@ -485,7 +494,7 @@ func (c *ChainPlanter) gardener() {
485494 continue
486495 }
487496
488- _ , err := c .finalizeBatch ()
497+ _ , err := c .finalizeBatch (nil )
489498 if err != nil {
490499 c .cfg .ErrChan <- fmt .Errorf ("unable to freeze " +
491500 "minting batch: %w" , err )
@@ -590,7 +599,15 @@ func (c *ChainPlanter) gardener() {
590599 log .Infof ("Finalizing batch %x" ,
591600 batchKey .SerializeCompressed ())
592601
593- caretaker , err := c .finalizeBatch ()
602+ feeRate , err :=
603+ typedParam [* chainfee.SatPerKWeight ](req )
604+ if err != nil {
605+ req .Error (fmt .Errorf ("bad fee rate: " +
606+ "%w" , err ))
607+ break
608+ }
609+
610+ caretaker , err := c .finalizeBatch (* feeRate )
594611 if err != nil {
595612 c .cfg .ErrChan <- fmt .Errorf ("unable " +
596613 "to freeze minting batch: %w" ,
@@ -643,10 +660,12 @@ func (c *ChainPlanter) gardener() {
643660}
644661
645662// finalizeBatch creates a new caretaker for the batch and starts it.
646- func (c * ChainPlanter ) finalizeBatch () (* BatchCaretaker , error ) {
663+ func (c * ChainPlanter ) finalizeBatch (
664+ feeRate * chainfee.SatPerKWeight ) (* BatchCaretaker , error ) {
665+
647666 // Prep the new care taker that'll be launched assuming the call below
648667 // to freeze the batch succeeds.
649- caretaker := c .newCaretakerForBatch (c .pendingBatch )
668+ caretaker := c .newCaretakerForBatch (c .pendingBatch , feeRate )
650669
651670 // At this point, we have a non-empty batch, so we'll first finalize it
652671 // on disk. This means no further seedlings can be added to this batch.
@@ -707,8 +726,10 @@ func (c *ChainPlanter) ListBatches(batchKey *btcec.PublicKey) ([]*MintingBatch,
707726}
708727
709728// FinalizeBatch sends a signal to the planter to finalize the current batch.
710- func (c * ChainPlanter ) FinalizeBatch () (* MintingBatch , error ) {
711- req := newStateReq [* MintingBatch ](reqTypeFinalizeBatch )
729+ func (c * ChainPlanter ) FinalizeBatch (
730+ feeRate * chainfee.SatPerKWeight ) (* MintingBatch , error ) {
731+
732+ req := newStateParamReq [* MintingBatch ](reqTypeFinalizeBatch , feeRate )
712733
713734 if ! fn .SendOrQuit [stateRequest ](c .stateReqs , req , c .Quit ) {
714735 return nil , fmt .Errorf ("chain planter shutting down" )
0 commit comments