@@ -544,7 +544,7 @@ func (t *TxPublisher) createRBFCompliantTx(
544
544
for {
545
545
// Create a new tx with the given fee rate and check its
546
546
// mempool acceptance.
547
- sweepCtx , err := t .createAndCheckTx (r . req , f )
547
+ sweepCtx , err := t .createAndCheckTx (r )
548
548
549
549
switch {
550
550
case err == nil :
@@ -607,8 +607,9 @@ func (t *TxPublisher) createRBFCompliantTx(
607
607
// script, and the fee rate. In addition, it validates the tx's mempool
608
608
// acceptance before returning a tx that can be published directly, along with
609
609
// its fee.
610
- func (t * TxPublisher ) createAndCheckTx (req * BumpRequest ,
611
- f FeeFunction ) (* sweepTxCtx , error ) {
610
+ func (t * TxPublisher ) createAndCheckTx (r * monitorRecord ) (* sweepTxCtx , error ) {
611
+ req := r .req
612
+ f := r .feeFunction
612
613
613
614
// Create the sweep tx with max fee rate of 0 as the fee function
614
615
// guarantees the fee rate used here won't exceed the max fee rate.
@@ -1025,27 +1026,31 @@ func (t *TxPublisher) handleTxConfirmed(r *monitorRecord) {
1025
1026
1026
1027
// handleInitialTxError takes the error from `initializeTx` and decides the
1027
1028
// bump event. It will construct a BumpResult and handles it.
1028
- func (t * TxPublisher ) handleInitialTxError (requestID uint64 , err error ) {
1029
- // We now decide what type of event to send.
1030
- var event BumpEvent
1029
+ func (t * TxPublisher ) handleInitialTxError (r * monitorRecord , err error ) {
1030
+ // Create a bump result to be sent to the sweeper.
1031
+ result := & BumpResult {
1032
+ Err : err ,
1033
+ requestID : r .requestID ,
1034
+ }
1031
1035
1036
+ // We now decide what type of event to send.
1032
1037
switch {
1033
1038
// When the error is due to a dust output, we'll send a TxFailed so
1034
1039
// these inputs can be retried with a different group in the next
1035
1040
// block.
1036
1041
case errors .Is (err , ErrTxNoOutput ):
1037
- event = TxFailed
1042
+ result . Event = TxFailed
1038
1043
1039
1044
// When the error is due to budget being used up, we'll send a TxFailed
1040
1045
// so these inputs can be retried with a different group in the next
1041
1046
// block.
1042
1047
case errors .Is (err , ErrMaxPosition ):
1043
- event = TxFailed
1048
+ result . Event = TxFailed
1044
1049
1045
1050
// When the error is due to zero fee rate delta, we'll send a TxFailed
1046
1051
// so these inputs can be retried in the next block.
1047
1052
case errors .Is (err , ErrZeroFeeRateDelta ):
1048
- event = TxFailed
1053
+ result . Event = TxFailed
1049
1054
1050
1055
// Otherwise this is not a fee-related error and the tx cannot be
1051
1056
// retried. In that case we will fail ALL the inputs in this tx, which
@@ -1055,13 +1060,7 @@ func (t *TxPublisher) handleInitialTxError(requestID uint64, err error) {
1055
1060
// TODO(yy): Find out which input is causing the failure and fail that
1056
1061
// one only.
1057
1062
default :
1058
- event = TxFatal
1059
- }
1060
-
1061
- result := & BumpResult {
1062
- Event : event ,
1063
- Err : err ,
1064
- requestID : requestID ,
1063
+ result .Event = TxFatal
1065
1064
}
1066
1065
1067
1066
t .handleResult (result )
@@ -1089,7 +1088,7 @@ func (t *TxPublisher) handleInitialBroadcast(r *monitorRecord) {
1089
1088
log .Errorf ("Initial broadcast failed: %v" , err )
1090
1089
1091
1090
// We now handle the initialization error and exit.
1092
- t .handleInitialTxError (r . requestID , err )
1091
+ t .handleInitialTxError (r , err )
1093
1092
1094
1093
return
1095
1094
}
@@ -1261,7 +1260,7 @@ func (t *TxPublisher) createAndPublishTx(
1261
1260
// NOTE: The fee function is expected to have increased its returned
1262
1261
// fee rate after calling the SkipFeeBump method. So we can use it
1263
1262
// directly here.
1264
- sweepCtx , err := t .createAndCheckTx (r . req , r . feeFunction )
1263
+ sweepCtx , err := t .createAndCheckTx (r )
1265
1264
1266
1265
// If there's an error creating the replacement tx, we need to abort the
1267
1266
// flow and handle it.
0 commit comments