File tree 3 files changed +34
-11
lines changed
3 files changed +34
-11
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,16 @@ const (
75
75
// TxPublished is sent when the broadcast attempt is finished.
76
76
TxPublished BumpEvent = iota
77
77
78
- // TxFailed is sent when the broadcast attempt fails.
78
+ // TxFailed is sent when the tx has encountered a fee-related error
79
+ // during its creation or broadcast, or an internal error from the fee
80
+ // bumper. In either case the inputs in this tx should be retried with
81
+ // either a different grouping strategy or an increased budget.
82
+ //
83
+ // NOTE: We also send this event when there's a third party spend
84
+ // event, and the sweeper will handle cleaning this up.
85
+ //
86
+ // TODO(yy): Remove the above usage once we remove sweeping non-CPFP
87
+ // anchors.
79
88
TxFailed
80
89
81
90
// TxReplaced is sent when the original tx is replaced by a new one.
@@ -270,8 +279,11 @@ func (b *BumpResult) String() string {
270
279
// Validate validates the BumpResult so it's safe to use.
271
280
func (b * BumpResult ) Validate () error {
272
281
// Every result must have a tx except the error or fail case.
273
- if b .Tx == nil && b .Event != TxFatal {
274
- return fmt .Errorf ("%w: nil tx" , ErrInvalidBumpResult )
282
+ if b .Tx == nil {
283
+ isFail := b .Event == TxFailed || b .Event == TxFatal
284
+ if ! isFail {
285
+ return fmt .Errorf ("%w: nil tx" , ErrInvalidBumpResult )
286
+ }
275
287
}
276
288
277
289
// Every result must have a known event.
Original file line number Diff line number Diff line change @@ -91,13 +91,6 @@ func TestBumpResultValidate(t *testing.T) {
91
91
}
92
92
require .ErrorIs (t , b .Validate (), ErrInvalidBumpResult )
93
93
94
- // A failed event without a tx will give an error.
95
- b = BumpResult {
96
- Event : TxFailed ,
97
- Err : errDummy ,
98
- }
99
- require .ErrorIs (t , b .Validate (), ErrInvalidBumpResult )
100
-
101
94
// A fatal event without a failure reason will give an error.
102
95
b = BumpResult {
103
96
Event : TxFailed ,
@@ -118,6 +111,13 @@ func TestBumpResultValidate(t *testing.T) {
118
111
}
119
112
require .NoError (t , b .Validate ())
120
113
114
+ // Tx is allowed to be nil in a TxFailed event.
115
+ b = BumpResult {
116
+ Event : TxFailed ,
117
+ Err : errDummy ,
118
+ }
119
+ require .NoError (t , b .Validate ())
120
+
121
121
// Tx is allowed to be nil in a TxFatal event.
122
122
b = BumpResult {
123
123
Event : TxFatal ,
Original file line number Diff line number Diff line change @@ -1665,6 +1665,14 @@ func (s *UtxoSweeper) monitorFeeBumpResult(set InputSet,
1665
1665
// in sweeper and rely solely on this event to mark
1666
1666
// inputs as Swept?
1667
1667
if r .Event == TxConfirmed || r .Event == TxFailed {
1668
+ // Exit if the tx is failed to be created.
1669
+ if r .Tx == nil {
1670
+ log .Debugf ("Received %v for nil tx, " +
1671
+ "exit monitor" , r .Event )
1672
+
1673
+ return
1674
+ }
1675
+
1668
1676
log .Debugf ("Received %v for sweep tx %v, exit " +
1669
1677
"fee bump monitor" , r .Event ,
1670
1678
r .Tx .TxHash ())
@@ -1690,7 +1698,10 @@ func (s *UtxoSweeper) handleBumpEventTxFailed(resp *bumpResp) {
1690
1698
r := resp .result
1691
1699
tx , err := r .Tx , r .Err
1692
1700
1693
- log .Warnf ("Fee bump attempt failed for tx=%v: %v" , tx .TxHash (), err )
1701
+ if tx != nil {
1702
+ log .Warnf ("Fee bump attempt failed for tx=%v: %v" , tx .TxHash (),
1703
+ err )
1704
+ }
1694
1705
1695
1706
// NOTE: When marking the inputs as failed, we are using the input set
1696
1707
// instead of the inputs found in the tx. This is fine for current
You can’t perform that action at this time.
0 commit comments