@@ -96,42 +96,6 @@ func (h *mockPresignedHelper) getTxFeerate(tx *wire.MsgTx,
9696 return chainfee .NewSatPerKWeight (fee , weight )
9797}
9898
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-
13599// DestPkScript returns destination pkScript used in presigned tx sweeping
136100// these inputs.
137101func (h * mockPresignedHelper ) DestPkScript (ctx context.Context ,
@@ -164,6 +128,11 @@ func (h *mockPresignedHelper) SignTx(ctx context.Context,
164128 feeRate , minRelayFee )
165129 }
166130
131+ if ! hasInput (tx , primarySweepID ) {
132+ return nil , fmt .Errorf ("primarySweepID %v not in tx" ,
133+ primarySweepID )
134+ }
135+
167136 // If all the inputs are online and loadOnly is not set, sign this exact
168137 // transaction.
169138 if offline := h .offlineInputs (tx ); len (offline ) == 0 && ! loadOnly {
@@ -205,7 +174,8 @@ func (h *mockPresignedHelper) SignTx(ctx context.Context,
205174 }
206175
207176 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" )
209179 }
210180
211181 return bestTx .Copy (), nil
@@ -1025,7 +995,7 @@ func testPresigned_presigned_group(t *testing.T,
1025995
1026996 // An attempt to presign must fail.
1027997 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" )
1029999
10301000 // Enable both outpoints.
10311001 presignedHelper .SetOutpointOnline (op2 , true )
0 commit comments