Skip to content

Commit d885e38

Browse files
Stop hardcoding from_onchain in monitor ev claim_funds
In upcoming commits, we'll be generating monitor events for off-chain claims as well as on-chain. As a small prefactor, calculate the from_onchain value rather than hardcoding it to true.
1 parent fee0591 commit d885e38

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

lightning/src/ln/channelmanager.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13568,14 +13568,26 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1356813568
"Claiming HTLC with preimage {} from our monitor",
1356913569
preimage
1357013570
);
13571+
let from_onchain = self
13572+
.per_peer_state
13573+
.read()
13574+
.unwrap()
13575+
.get(&counterparty_node_id)
13576+
.map_or(true, |peer_state_mtx| {
13577+
!peer_state_mtx
13578+
.lock()
13579+
.unwrap()
13580+
.channel_by_id
13581+
.contains_key(&channel_id)
13582+
});
1357113583
// Claim the funds from the previous hop, if there is one. Because this is in response to a
1357213584
// chain event, no attribution data is available.
1357313585
self.claim_funds_internal(
1357413586
htlc_update.source,
1357513587
preimage,
1357613588
htlc_update.htlc_value_satoshis.map(|v| v * 1000),
1357713589
None,
13578-
true,
13590+
from_onchain,
1357913591
counterparty_node_id,
1358013592
funding_outpoint,
1358113593
channel_id,

0 commit comments

Comments
 (0)