@@ -75,7 +75,17 @@ 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 once it's
85
+ // confirmed.
86
+ //
87
+ // TODO(yy): Remove the above usage once we remove sweeping non-CPFP
88
+ // anchors.
79
89
TxFailed
80
90
81
91
// TxReplaced is sent when the original tx is replaced by a new one.
@@ -269,8 +279,10 @@ func (b *BumpResult) String() string {
269
279
270
280
// Validate validates the BumpResult so it's safe to use.
271
281
func (b * BumpResult ) Validate () error {
282
+ isFailureEvent := b .Event == TxFailed || b .Event == TxFatal
283
+
272
284
// Every result must have a tx except the fatal or failed case.
273
- if b .Tx == nil && b . Event != TxFatal {
285
+ if b .Tx == nil && ! isFailureEvent {
274
286
return fmt .Errorf ("%w: nil tx" , ErrInvalidBumpResult )
275
287
}
276
288
@@ -285,10 +297,8 @@ func (b *BumpResult) Validate() error {
285
297
}
286
298
287
299
// If it's a failed or fatal event, it must have an error.
288
- if b .Event == TxFatal || b .Event == TxFailed {
289
- if b .Err == nil {
290
- return fmt .Errorf ("%w: nil error" , ErrInvalidBumpResult )
291
- }
300
+ if isFailureEvent && b .Err == nil {
301
+ return fmt .Errorf ("%w: nil error" , ErrInvalidBumpResult )
292
302
}
293
303
294
304
// If it's a confirmed event, it must have a fee rate and fee.
0 commit comments