Skip to content

Commit 94c5f92

Browse files
committed
staticaddr: use deposit conf heigh for reorg safety
1 parent 5cc2f95 commit 94c5f92

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

loopd/daemon.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error {
617617
Signer: d.lnd.Signer,
618618
Store: withdrawalStore,
619619
}
620-
withdrawalManager = withdraw.NewManager(withdrawalCfg, blockHeight)
620+
withdrawalManager = withdraw.NewManager(withdrawalCfg)
621621

622622
// Static address loop-in manager setup.
623623
staticAddressLoopInStore := loopin.NewSqlStore(

staticaddr/withdraw/manager.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"fmt"
88
"strings"
99
"sync"
10-
"sync/atomic"
1110

1211
"github.com/btcsuite/btcd/btcec/v2/schnorr"
1312
"github.com/btcsuite/btcd/btcec/v2/schnorr/musig2"
@@ -133,24 +132,20 @@ type Manager struct {
133132
// errChan forwards errors from the withdrawal manager to the server.
134133
errChan chan error
135134

136-
// initiationHeight stores the currently best known block height.
137-
initiationHeight atomic.Uint32
138-
139135
// finalizedWithdrawalTx are the finalized withdrawal transactions that
140136
// are published to the network and re-published on block arrivals.
141137
finalizedWithdrawalTxns map[chainhash.Hash]*wire.MsgTx
142138
}
143139

144140
// NewManager creates a new deposit withdrawal manager.
145-
func NewManager(cfg *ManagerConfig, currentHeight uint32) *Manager {
141+
func NewManager(cfg *ManagerConfig) *Manager {
146142
m := &Manager{
147143
cfg: cfg,
148144
finalizedWithdrawalTxns: make(map[chainhash.Hash]*wire.MsgTx),
149145
exitChan: make(chan struct{}),
150146
newWithdrawalRequestChan: make(chan newWithdrawalRequest),
151147
errChan: make(chan error),
152148
}
153-
m.initiationHeight.Store(currentHeight)
154149

155150
return m
156151
}
@@ -669,7 +664,7 @@ func (m *Manager) handleWithdrawal(ctx context.Context,
669664
m.cfg.ChainNotifier.RegisterConfirmationsNtfn(
670665
ctx, spentTx.SpenderTxHash,
671666
withdrawalPkscript, MinConfs,
672-
int32(m.initiationHeight.Load()),
667+
int32(d.ConfirmationHeight),
673668
)
674669
select {
675670
case tx := <-confChan:

0 commit comments

Comments
 (0)