@@ -96,42 +96,6 @@ func (h *mockPresignedHelper) getTxFeerate(tx *wire.MsgTx,
96
96
return chainfee .NewSatPerKWeight (fee , weight )
97
97
}
98
98
99
- // Presign tries to presign the transaction. It succeeds if all the inputs
100
- // are online. In case of success it adds the transaction to presignedBatches.
101
- func (h * mockPresignedHelper ) Presign (ctx context.Context ,
102
- primarySweepID wire.OutPoint , tx * wire.MsgTx ,
103
- inputAmt btcutil.Amount ) error {
104
-
105
- h .mu .Lock ()
106
- defer h .mu .Unlock ()
107
-
108
- // Check if such a transaction already exists. This is not only an
109
- // optimization, but also enables re-adding multiple groups if sweeps
110
- // are offline.
111
- wantTxHash := tx .TxHash ()
112
- for _ , candidate := range h .presignedBatches [primarySweepID ] {
113
- if candidate .TxHash () == wantTxHash {
114
- return nil
115
- }
116
- }
117
-
118
- if ! hasInput (tx , primarySweepID ) {
119
- return fmt .Errorf ("primarySweepID %v not in tx" , primarySweepID )
120
- }
121
-
122
- if offline := h .offlineInputs (tx ); len (offline ) != 0 {
123
- return fmt .Errorf ("some inputs of tx are offline: %v" , offline )
124
- }
125
-
126
- tx = tx .Copy ()
127
- h .sign (tx )
128
- h .presignedBatches [primarySweepID ] = append (
129
- h .presignedBatches [primarySweepID ], tx ,
130
- )
131
-
132
- return nil
133
- }
134
-
135
99
// DestPkScript returns destination pkScript used in presigned tx sweeping
136
100
// these inputs.
137
101
func (h * mockPresignedHelper ) DestPkScript (ctx context.Context ,
@@ -164,6 +128,11 @@ func (h *mockPresignedHelper) SignTx(ctx context.Context,
164
128
feeRate , minRelayFee )
165
129
}
166
130
131
+ if ! hasInput (tx , primarySweepID ) {
132
+ return nil , fmt .Errorf ("primarySweepID %v not in tx" ,
133
+ primarySweepID )
134
+ }
135
+
167
136
// If all the inputs are online and loadOnly is not set, sign this exact
168
137
// transaction.
169
138
if offline := h .offlineInputs (tx ); len (offline ) == 0 && ! loadOnly {
@@ -205,7 +174,8 @@ func (h *mockPresignedHelper) SignTx(ctx context.Context,
205
174
}
206
175
207
176
if bestTx == nil {
208
- return nil , fmt .Errorf ("no such presigned tx found" )
177
+ return nil , fmt .Errorf ("some outpoint is offline and no " +
178
+ "suitable presigned tx found" )
209
179
}
210
180
211
181
return bestTx .Copy (), nil
@@ -1025,7 +995,7 @@ func testPresigned_presigned_group(t *testing.T,
1025
995
1026
996
// An attempt to presign must fail.
1027
997
err = batcher .PresignSweepsGroup (ctx , group1 , sweepTimeout , destAddr )
1028
- require .ErrorContains (t , err , "some inputs of tx are offline" )
998
+ require .ErrorContains (t , err , "some outpoint is offline" )
1029
999
1030
1000
// Enable both outpoints.
1031
1001
presignedHelper .SetOutpointOnline (op2 , true )
0 commit comments