MCPcopy Create free account
hub / github.com/ElementsProject/lightning / is_fundee_should_forget

Function is_fundee_should_forget

lightningd/channel_control.c:2018–2053  ·  view source on GitHub ↗

Check if we are the fundee of this channel, the channel * funding transaction is still not yet seen onchain, and * it has been too long since the channel was first opened. * If so, we should forget the channel. */

Source from the content-addressed store, hash-verified

2016 * it has been too long since the channel was first opened.
2017 * If so, we should forget the channel. */
2018static bool
2019is_fundee_should_forget(struct lightningd *ld,
2020 struct channel *channel)
2021{
2022 u32 block_height = get_block_height(ld->topology);
2023 /* 2016 by default */
2024 u32 max_funding_unconfirmed = ld->dev_max_funding_unconfirmed;
2025
2026 /* Only applies if we are fundee. */
2027 if (channel->opener == LOCAL)
2028 return false;
2029
2030 /* Does not apply if we already saw the funding tx. */
2031 if (channel->scid)
2032 return false;
2033
2034 /* Not even reached previous starting blocknum.
2035 * (e.g. if --rescan option is used) */
2036 if (block_height < channel->first_blocknum)
2037 return false;
2038
2039 /* Timeout in blocks not yet reached. */
2040 if (block_height - channel->first_blocknum < max_funding_unconfirmed)
2041 return false;
2042
2043 /* If we've got funds in the channel initially, don't forget it */
2044 if (!amount_sat_is_zero(channel->our_funds))
2045 return false;
2046
2047 /* If we ever had a stake in the channel, don't forget it. */
2048 if (!amount_msat_is_zero(channel->msat_to_us_max))
2049 return false;
2050
2051 /* Ah forget it! */
2052 return true;
2053}
2054
2055/* We want in ascending order, so oldest channels first */
2056static int cmp_channel_start(struct channel *const *a, struct channel *const *b, void *unused)

Callers 1

channel_notify_new_blockFunction · 0.85

Calls 3

amount_sat_is_zeroFunction · 0.85
amount_msat_is_zeroFunction · 0.85
get_block_heightFunction · 0.70

Tested by

no test coverage detected