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

Function is_fundee_should_forget

lightningd/channel_control.c:889–925  ·  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

887 * it has been too long since the channel was first opened.
888 * If so, we should forget the channel. */
889static bool
890is_fundee_should_forget(struct lightningd *ld,
891 struct channel *channel,
892 u32 block_height)
893{
894 /* BOLT #2:
895 *
896 * A non-funding node (fundee):
897 * - SHOULD forget the channel if it does not see the
898 * correct funding transaction after a timeout of 2016 blocks.
899 */
900 u32 max_funding_unconfirmed = IFDEV(ld->dev_max_funding_unconfirmed, 2016);
901
902 /* Only applies if we are fundee. */
903 if (channel->opener == LOCAL)
904 return false;
905
906 /* Does not apply if we already saw the funding tx. */
907 if (channel->scid)
908 return false;
909
910 /* Not even reached previous starting blocknum.
911 * (e.g. if --rescan option is used) */
912 if (block_height < channel->first_blocknum)
913 return false;
914
915 /* Timeout in blocks not yet reached. */
916 if (block_height - channel->first_blocknum < max_funding_unconfirmed)
917 return false;
918
919 /* If we've got funds in the channel, don't forget it */
920 if (!amount_sat_zero(channel->our_funds))
921 return false;
922
923 /* Ah forget it! */
924 return true;
925}
926
927/* Notify all channels of new blocks. */
928void channel_notify_new_block(struct lightningd *ld,

Callers 1

channel_notify_new_blockFunction · 0.85

Calls 1

amount_sat_zeroFunction · 0.85

Tested by

no test coverage detected