From f614e7aed97d037b440ad40814b80f991180ebcb Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Wed, 12 Feb 2025 19:10:25 +0800 Subject: [PATCH] sweep: add `createUnknownSpentBumpResult` A minor refactor to break the method `handleUnknownSpent` into two steps, which prepares the following commit where we start handling missing inputs. --- sweep/fee_bumper.go | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/sweep/fee_bumper.go b/sweep/fee_bumper.go index 38983f8fe..67a3663df 100644 --- a/sweep/fee_bumper.go +++ b/sweep/fee_bumper.go @@ -1170,6 +1170,19 @@ func (t *TxPublisher) handleUnknownSpent(r *monitorRecord) { "bumper, failing it now:\n%v", r.requestID, inputTypeSummary(r.req.Inputs)) + // Create a result that will be sent to the resultChan which is listened + // by the caller. + result := t.createUnknownSpentBumpResult(r) + + // Notify the sweeper about this result in the end. + t.handleResult(result) +} + +// createUnknownSpentBumpResult creates and returns a BumpResult given the +// monitored record has unknown spends. +func (t *TxPublisher) createUnknownSpentBumpResult( + r *monitorRecord) *BumpResult { + // Create a result that will be sent to the resultChan which is listened // by the caller. result := &BumpResult{ @@ -1208,10 +1221,7 @@ func (t *TxPublisher) handleUnknownSpent(r *monitorRecord) { result.Event = TxFatal result.Err = err - // Notify the sweeper about this result in the end. - t.handleResult(result) - - return + return result } feeFunc = f @@ -1234,8 +1244,7 @@ func (t *TxPublisher) handleUnknownSpent(r *monitorRecord) { // Attach the new fee rate to be used for the next sweeping attempt. result.FeeRate = feeFunc.FeeRate() - // Notify the sweeper about this result in the end. - t.handleResult(result) + return result } // createAndPublishTx creates a new tx with a higher fee rate and publishes it