From 8314f0a879a5bff2974f5181e9eedd3f19f4820c Mon Sep 17 00:00:00 2001 From: ziggie Date: Sat, 3 Jun 2023 14:05:16 +0200 Subject: [PATCH] contractcourt: handle mempool min fee error. In case the mempool backend signals that our transaction does not meet fee requirements when publishing it we will continue to start up now. The transaction will be rebroadcasted in the background and a specific log message will be printed to let the user know that he could increase his mempool size to at least have this transaction in his own mempool. --- contractcourt/channel_arbitrator.go | 13 ++++++++++--- contractcourt/utxonursery.go | 9 ++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/contractcourt/channel_arbitrator.go b/contractcourt/channel_arbitrator.go index eeb8850f7..b19bae7fe 100644 --- a/contractcourt/channel_arbitrator.go +++ b/contractcourt/channel_arbitrator.go @@ -553,7 +553,7 @@ func (c *ChannelArbitrator) Start(state *chanArbStartState) error { // StateWaitingFullResolution after we've transitioned from // StateContractClosed which can only be triggered by the local // or remote close trigger. This trigger is only fired when we - // receive a chain event from the chain watcher than the + // receive a chain event from the chain watcher that the // commitment has been confirmed on chain, and before we // advance our state step, we call InsertConfirmedCommitSet. err := c.relaunchResolvers(state.commitSet, triggerHeight) @@ -990,11 +990,18 @@ func (c *ChannelArbitrator) stateStep( label := labels.MakeLabel( labels.LabelTypeChannelClose, &c.cfg.ShortChanID, ) - if err := c.cfg.PublishTx(closeTx, label); err != nil { log.Errorf("ChannelArbitrator(%v): unable to broadcast "+ "close tx: %v", c.cfg.ChanPoint, err) - if err != lnwallet.ErrDoubleSpend { + + // This makes sure we don't fail at startup if the + // commitment transaction has too low fees to make it + // into mempool. The rebroadcaster makes sure this + // transaction is republished regularly until confirmed + // or replaced. + if !errors.Is(err, lnwallet.ErrDoubleSpend) && + !errors.Is(err, lnwallet.ErrMempoolFee) { + return StateError, closeTx, err } } diff --git a/contractcourt/utxonursery.go b/contractcourt/utxonursery.go index 3776a3546..a763679ed 100644 --- a/contractcourt/utxonursery.go +++ b/contractcourt/utxonursery.go @@ -3,6 +3,7 @@ package contractcourt import ( "bytes" "encoding/binary" + "errors" "fmt" "io" "sync" @@ -872,7 +873,13 @@ func (u *UtxoNursery) sweepCribOutput(classHeight uint32, baby *babyOutput) erro // confirmed before transitioning it to kindergarten. label := labels.MakeLabel(labels.LabelTypeSweepTransaction, nil) err := u.cfg.PublishTransaction(baby.timeoutTx, label) - if err != nil && err != lnwallet.ErrDoubleSpend { + + // In case the tx does not meet mempool fee requirements we continue + // because the tx is rebroadcasted in the background and there is + // nothing we can do to bump this transaction anyways. + if err != nil && !errors.Is(err, lnwallet.ErrDoubleSpend) && + !errors.Is(err, lnwallet.ErrMempoolFee) { + utxnLog.Errorf("Unable to broadcast baby tx: "+ "%v, %v", err, spew.Sdump(baby.timeoutTx)) return err