From 0807ce61a138a072f18656c576f50bf9db77ce68 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Thu, 17 Apr 2025 06:05:40 +0800 Subject: [PATCH] sweep: return all inputs from `PendingSweeps` Previously we'd skip returning immature inputs to stay backwards compatible. This has the downside as the node operator cannot take actions on this input, like some customized batching strategy via `bumpfee` RPC. After this change, it means when calling `bumpfee` RPC, it will now update the params for the immature input instead of returning an error saying `output does not belong to wallet`. We also add a `MaturityHeight` field so the user knows when this input will be swept. --- sweep/sweeper.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sweep/sweeper.go b/sweep/sweeper.go index d240f5b34..fdaecbefb 100644 --- a/sweep/sweeper.go +++ b/sweep/sweeper.go @@ -305,6 +305,10 @@ type PendingInputResponse struct { // DeadlineHeight records the deadline height of this input. DeadlineHeight uint32 + + // MaturityHeight is the block height that this input's locktime will + // be expired at. For inputs with no locktime this value is zero. + MaturityHeight uint32 } // updateReq is an internal message we'll use to represent an external caller's @@ -1068,11 +1072,7 @@ func (s *UtxoSweeper) handlePendingSweepsReq( resps := make(map[wire.OutPoint]*PendingInputResponse, len(s.inputs)) for _, inp := range s.inputs { - // Skip immature inputs for compatibility. - mature, _ := inp.isMature(uint32(s.currentHeight)) - if !mature { - continue - } + _, maturityHeight := inp.isMature(uint32(s.currentHeight)) // Only the exported fields are set, as we expect the response // to only be consumed externally. @@ -1087,6 +1087,7 @@ func (s *UtxoSweeper) handlePendingSweepsReq( BroadcastAttempts: inp.publishAttempts, Params: inp.params, DeadlineHeight: uint32(inp.DeadlineHeight), + MaturityHeight: maturityHeight, } }