@@ -227,15 +227,18 @@ func (m *Manager) recoverWithdrawals(ctx context.Context) error {
227
227
}
228
228
229
229
// Group the deposits by their finalized withdrawal transaction.
230
- depositsByWithdrawalTx := make (map [* wire.MsgTx ][]* deposit.Deposit )
230
+ depositsByWithdrawalTx := make (map [chainhash.Hash ][]* deposit.Deposit )
231
+ hash2tx := make (map [chainhash.Hash ]* wire.MsgTx )
231
232
for _ , d := range activeDeposits {
232
233
withdrawalTx := d .FinalizedWithdrawalTx
233
234
if withdrawalTx == nil {
234
235
continue
235
236
}
237
+ txid := withdrawalTx .TxHash ()
238
+ hash2tx [txid ] = withdrawalTx
236
239
237
- depositsByWithdrawalTx [withdrawalTx ] = append (
238
- depositsByWithdrawalTx [withdrawalTx ], d ,
240
+ depositsByWithdrawalTx [txid ] = append (
241
+ depositsByWithdrawalTx [txid ], d ,
239
242
)
240
243
}
241
244
@@ -244,7 +247,7 @@ func (m *Manager) recoverWithdrawals(ctx context.Context) error {
244
247
eg := & errgroup.Group {}
245
248
246
249
// We can now reinstate each cluster of deposits for a withdrawal.
247
- for tx , deposits := range depositsByWithdrawalTx {
250
+ for txid , deposits := range depositsByWithdrawalTx {
248
251
eg .Go (func () error {
249
252
err := m .cfg .DepositManager .TransitionDeposits (
250
253
ctx , deposits , deposit .OnWithdrawInitiated ,
@@ -254,6 +257,11 @@ func (m *Manager) recoverWithdrawals(ctx context.Context) error {
254
257
return err
255
258
}
256
259
260
+ tx , ok := hash2tx [txid ]
261
+ if ! ok {
262
+ return fmt .Errorf ("can't find tx %v" , txid )
263
+ }
264
+
257
265
_ , err = m .publishFinalizedWithdrawalTx (ctx , tx )
258
266
if err != nil {
259
267
return err
0 commit comments