Skip to content

Commit 6ee4cf9

Browse files
committed
staticaddr: monitor tx id of expiry sweep
1 parent 70cf2d8 commit 6ee4cf9

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

staticaddr/deposit/actions.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"strings"
88

9+
"github.com/btcsuite/btcd/chaincfg/chainhash"
910
"github.com/btcsuite/btcd/wire"
1011
"github.com/lightninglabs/lndclient"
1112
"github.com/lightninglabs/loop/fsm"
@@ -103,20 +104,27 @@ func (f *FSM) PublishDepositExpirySweepAction(ctx context.Context,
103104
return fsm.OnError
104105
}
105106
} else {
106-
f.Debugf("published timeout sweep with txid: %v",
107-
msgTx.TxHash())
107+
txHash := msgTx.TxHash()
108+
f.deposit.ExpirySweepTxid = txHash
109+
f.Debugf("published timeout sweep with txid: %v", txHash)
108110
}
109111

110112
return OnExpiryPublished
111113
}
112114

113-
// WaitForExpirySweepAction waits for a sufficient number of confirmations
114-
// before a timeout sweep is considered successful.
115+
// WaitForExpirySweepAction waits for enough confirmations before a timeout
116+
// sweep is considered successful.
115117
func (f *FSM) WaitForExpirySweepAction(ctx context.Context,
116118
_ fsm.EventContext) fsm.EventType {
117119

120+
var txID *chainhash.Hash
121+
// Only pass the txid if we know it from our own publication.
122+
if f.deposit.ExpirySweepTxid != (chainhash.Hash{}) {
123+
txID = &f.deposit.ExpirySweepTxid
124+
}
125+
118126
spendChan, errSpendChan, err := f.cfg.ChainNotifier.RegisterConfirmationsNtfn( //nolint:lll
119-
ctx, nil, f.deposit.TimeOutSweepPkScript, DefaultConfTarget,
127+
ctx, txID, f.deposit.TimeOutSweepPkScript, DefaultConfTarget,
120128
int32(f.deposit.ConfirmationHeight),
121129
)
122130
if err != nil {

0 commit comments

Comments
 (0)