@@ -525,7 +525,7 @@ func (s *UtxoSweeper) SweepInput(inp input.Input,
525
525
}
526
526
527
527
absoluteTimeLock , _ := inp .RequiredLockTime ()
528
- log .Infof ("Sweep request received: out_point=%v, witness_type=%v, " +
528
+ log .Debugf ("Sweep request received: out_point=%v, witness_type=%v, " +
529
529
"relative_time_lock=%v, absolute_time_lock=%v, amount=%v, " +
530
530
"parent=(%v), params=(%v)" , inp .OutPoint (), inp .WitnessType (),
531
531
inp .BlocksToMaturity (), absoluteTimeLock ,
@@ -725,7 +725,17 @@ func (s *UtxoSweeper) collector(blockEpochs <-chan *chainntnfs.BlockEpoch) {
725
725
inputs := s .updateSweeperInputs ()
726
726
727
727
log .Debugf ("Received new block: height=%v, attempt " +
728
- "sweeping %d inputs" , epoch .Height , len (inputs ))
728
+ "sweeping %d inputs:\n %s" , epoch .Height ,
729
+ len (inputs ), newLogClosure (func () string {
730
+ inps := make (
731
+ []input.Input , 0 , len (inputs ),
732
+ )
733
+ for _ , in := range inputs {
734
+ inps = append (inps , in )
735
+ }
736
+
737
+ return inputTypeSummary (inps )
738
+ })())
729
739
730
740
// Attempt to sweep any pending inputs.
731
741
s .sweepPendingInputs (inputs )
@@ -1192,13 +1202,29 @@ func (s *UtxoSweeper) mempoolLookup(op wire.OutPoint) fn.Option[wire.MsgTx] {
1192
1202
return s .cfg .Mempool .LookupInputMempoolSpend (op )
1193
1203
}
1194
1204
1195
- // handleNewInput processes a new input by registering spend notification and
1196
- // scheduling sweeping for it .
1197
- func (s * UtxoSweeper ) handleNewInput ( input * sweepInputMessage ) error {
1205
+ // calculateDefaultDeadline calculates the default deadline height for a sweep
1206
+ // request that has no deadline height specified .
1207
+ func (s * UtxoSweeper ) calculateDefaultDeadline ( pi * SweeperInput ) int32 {
1198
1208
// Create a default deadline height, which will be used when there's no
1199
1209
// DeadlineHeight specified for a given input.
1200
1210
defaultDeadline := s .currentHeight + int32 (s .cfg .NoDeadlineConfTarget )
1201
1211
1212
+ // If the input is immature and has a locktime, we'll use the locktime
1213
+ // height as the starting height.
1214
+ matured , locktime := pi .isMature (uint32 (s .currentHeight ))
1215
+ if ! matured {
1216
+ defaultDeadline = int32 (locktime + s .cfg .NoDeadlineConfTarget )
1217
+ log .Debugf ("Input %v is immature, using locktime=%v instead " +
1218
+ "of current height=%d" , pi .OutPoint (), locktime ,
1219
+ s .currentHeight )
1220
+ }
1221
+
1222
+ return defaultDeadline
1223
+ }
1224
+
1225
+ // handleNewInput processes a new input by registering spend notification and
1226
+ // scheduling sweeping for it.
1227
+ func (s * UtxoSweeper ) handleNewInput (input * sweepInputMessage ) error {
1202
1228
outpoint := input .input .OutPoint ()
1203
1229
pi , pending := s .inputs [outpoint ]
1204
1230
if pending {
@@ -1223,15 +1249,22 @@ func (s *UtxoSweeper) handleNewInput(input *sweepInputMessage) error {
1223
1249
Input : input .input ,
1224
1250
params : input .params ,
1225
1251
rbf : rbfInfo ,
1226
- // Set the acutal deadline height.
1227
- DeadlineHeight : input .params .DeadlineHeight .UnwrapOr (
1228
- defaultDeadline ,
1229
- ),
1230
1252
}
1231
1253
1254
+ // Set the acutal deadline height.
1255
+ pi .DeadlineHeight = input .params .DeadlineHeight .UnwrapOr (
1256
+ s .calculateDefaultDeadline (pi ),
1257
+ )
1258
+
1232
1259
s .inputs [outpoint ] = pi
1233
1260
log .Tracef ("input %v, state=%v, added to inputs" , outpoint , pi .state )
1234
1261
1262
+ log .Infof ("Registered sweep request at block %d: out_point=%v, " +
1263
+ "witness_type=%v, amount=%v, deadline=%d, params=(%v)" ,
1264
+ s .currentHeight , pi .OutPoint (), pi .WitnessType (),
1265
+ btcutil .Amount (pi .SignDesc ().Output .Value ), pi .DeadlineHeight ,
1266
+ pi .params )
1267
+
1235
1268
// Start watching for spend of this input, either by us or the remote
1236
1269
// party.
1237
1270
cancel , err := s .monitorSpend (
@@ -1629,7 +1662,7 @@ func (s *UtxoSweeper) monitorFeeBumpResult(resultChan <-chan *BumpResult) {
1629
1662
func (s * UtxoSweeper ) handleBumpEventTxFailed (r * BumpResult ) error {
1630
1663
tx , err := r .Tx , r .Err
1631
1664
1632
- log .Errorf ("Fee bump attempt failed for tx=%v: %v" , tx .TxHash (), err )
1665
+ log .Warnf ("Fee bump attempt failed for tx=%v: %v" , tx .TxHash (), err )
1633
1666
1634
1667
outpoints := make ([]wire.OutPoint , 0 , len (tx .TxIn ))
1635
1668
for _ , inp := range tx .TxIn {
@@ -1639,7 +1672,7 @@ func (s *UtxoSweeper) handleBumpEventTxFailed(r *BumpResult) error {
1639
1672
// TODO(yy): should we also remove the failed tx from db?
1640
1673
s .markInputsPublishFailed (outpoints )
1641
1674
1642
- return err
1675
+ return nil
1643
1676
}
1644
1677
1645
1678
// handleBumpEventTxReplaced handles the case where the sweeping tx has been
0 commit comments