|
6 | 6 | "fmt" |
7 | 7 | "strings" |
8 | 8 |
|
| 9 | + "github.com/btcsuite/btcd/chaincfg/chainhash" |
9 | 10 | "github.com/btcsuite/btcd/wire" |
10 | 11 | "github.com/lightninglabs/lndclient" |
11 | 12 | "github.com/lightninglabs/loop/fsm" |
@@ -103,20 +104,27 @@ func (f *FSM) PublishDepositExpirySweepAction(ctx context.Context, |
103 | 104 | return fsm.OnError |
104 | 105 | } |
105 | 106 | } 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) |
108 | 110 | } |
109 | 111 |
|
110 | 112 | return OnExpiryPublished |
111 | 113 | } |
112 | 114 |
|
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. |
115 | 117 | func (f *FSM) WaitForExpirySweepAction(ctx context.Context, |
116 | 118 | _ fsm.EventContext) fsm.EventType { |
117 | 119 |
|
| 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 | + |
118 | 126 | spendChan, errSpendChan, err := f.cfg.ChainNotifier.RegisterConfirmationsNtfn( //nolint:lll |
119 | | - ctx, nil, f.deposit.TimeOutSweepPkScript, DefaultConfTarget, |
| 127 | + ctx, txID, f.deposit.TimeOutSweepPkScript, DefaultConfTarget, |
120 | 128 | int32(f.deposit.ConfirmationHeight), |
121 | 129 | ) |
122 | 130 | if err != nil { |
|
0 commit comments