mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
staticaddr: use tx hash not *wire.MsgTx as a key
Do not rely on GetActiveDepositsInState reusing the same *wire.MsgTx pointer for a unique transaction.
This commit is contained in:
parent
38aaa4d07a
commit
61542197f6
1 changed files with 12 additions and 4 deletions
|
|
@ -227,15 +227,18 @@ func (m *Manager) recoverWithdrawals(ctx context.Context) error {
|
|||
}
|
||||
|
||||
// Group the deposits by their finalized withdrawal transaction.
|
||||
depositsByWithdrawalTx := make(map[*wire.MsgTx][]*deposit.Deposit)
|
||||
depositsByWithdrawalTx := make(map[chainhash.Hash][]*deposit.Deposit)
|
||||
hash2tx := make(map[chainhash.Hash]*wire.MsgTx)
|
||||
for _, d := range activeDeposits {
|
||||
withdrawalTx := d.FinalizedWithdrawalTx
|
||||
if withdrawalTx == nil {
|
||||
continue
|
||||
}
|
||||
txid := withdrawalTx.TxHash()
|
||||
hash2tx[txid] = withdrawalTx
|
||||
|
||||
depositsByWithdrawalTx[withdrawalTx] = append(
|
||||
depositsByWithdrawalTx[withdrawalTx], d,
|
||||
depositsByWithdrawalTx[txid] = append(
|
||||
depositsByWithdrawalTx[txid], d,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -244,7 +247,7 @@ func (m *Manager) recoverWithdrawals(ctx context.Context) error {
|
|||
eg := &errgroup.Group{}
|
||||
|
||||
// We can now reinstate each cluster of deposits for a withdrawal.
|
||||
for tx, deposits := range depositsByWithdrawalTx {
|
||||
for txid, deposits := range depositsByWithdrawalTx {
|
||||
eg.Go(func() error {
|
||||
err := m.cfg.DepositManager.TransitionDeposits(
|
||||
ctx, deposits, deposit.OnWithdrawInitiated,
|
||||
|
|
@ -254,6 +257,11 @@ func (m *Manager) recoverWithdrawals(ctx context.Context) error {
|
|||
return err
|
||||
}
|
||||
|
||||
tx, ok := hash2tx[txid]
|
||||
if !ok {
|
||||
return fmt.Errorf("can't find tx %v", txid)
|
||||
}
|
||||
|
||||
_, err = m.publishFinalizedWithdrawalTx(ctx, tx)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue