@@ -227,15 +227,18 @@ func (m *Manager) recoverWithdrawals(ctx context.Context) error {
227227 }
228228
229229 // 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 )
231232 for _ , d := range activeDeposits {
232233 withdrawalTx := d .FinalizedWithdrawalTx
233234 if withdrawalTx == nil {
234235 continue
235236 }
237+ txid := withdrawalTx .TxHash ()
238+ hash2tx [txid ] = withdrawalTx
236239
237- depositsByWithdrawalTx [withdrawalTx ] = append (
238- depositsByWithdrawalTx [withdrawalTx ], d ,
240+ depositsByWithdrawalTx [txid ] = append (
241+ depositsByWithdrawalTx [txid ], d ,
239242 )
240243 }
241244
@@ -244,7 +247,7 @@ func (m *Manager) recoverWithdrawals(ctx context.Context) error {
244247 eg := & errgroup.Group {}
245248
246249 // We can now reinstate each cluster of deposits for a withdrawal.
247- for tx , deposits := range depositsByWithdrawalTx {
250+ for txid , deposits := range depositsByWithdrawalTx {
248251 eg .Go (func () error {
249252 err := m .cfg .DepositManager .TransitionDeposits (
250253 ctx , deposits , deposit .OnWithdrawInitiated ,
@@ -254,6 +257,11 @@ func (m *Manager) recoverWithdrawals(ctx context.Context) error {
254257 return err
255258 }
256259
260+ tx , ok := hash2tx [txid ]
261+ if ! ok {
262+ return fmt .Errorf ("can't find tx %v" , txid )
263+ }
264+
257265 _ , err = m .publishFinalizedWithdrawalTx (ctx , tx )
258266 if err != nil {
259267 return err
0 commit comments