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

Function htlc_max_possible_send

lightningd/channel.c:470–498  ·  view source on GitHub ↗

* The maximum msat that this node could possibly accept for an htlc. * It's the default htlc_maximum_msat in channel_updates, if none is * explicitly set (and the cap on what can be set!). * * We advertize the maximum value possible, defined as the smaller * of the remote's maximum in-flight HTLC or the total channel * capacity the reserve we have to keep. * FIXME: does this need fuzz? */

Source from the content-addressed store, hash-verified

468 * FIXME: does this need fuzz?
469 */
470struct amount_msat htlc_max_possible_send(const struct channel *channel)
471{
472 struct amount_sat lower_bound;
473 struct amount_msat lower_bound_msat;
474
475 /* These shouldn't fail */
476 if (!amount_sat_sub(&lower_bound, channel->funding_sats,
477 channel->channel_info.their_config.channel_reserve)) {
478 log_broken(channel->log, "%s: their reserve %s > funding %s!",
479 __func__,
480 fmt_amount_sat(tmpctx, channel->funding_sats),
481 fmt_amount_sat(tmpctx,
482 channel->channel_info.their_config.channel_reserve));
483 return AMOUNT_MSAT(0);
484 }
485
486 if (!amount_sat_to_msat(&lower_bound_msat, lower_bound)) {
487 log_broken(channel->log, "%s: impossible size channel %s!",
488 __func__,
489 fmt_amount_sat(tmpctx, lower_bound));
490 return AMOUNT_MSAT(0);
491 }
492
493 if (amount_msat_less(channel->channel_info.their_config.max_htlc_value_in_flight,
494 lower_bound_msat))
495 lower_bound_msat = channel->channel_info.their_config.max_htlc_value_in_flight;
496
497 return lower_bound_msat;
498}
499
500struct channel *new_channel(struct peer *peer, u64 dbid,
501 /* NULL or stolen */

Callers 4

wallet_update_channelFunction · 0.70
wallet_commit_channelFunction · 0.70
new_channelFunction · 0.70
set_channel_configFunction · 0.70

Calls 4

amount_sat_subFunction · 0.50
fmt_amount_satFunction · 0.50
amount_sat_to_msatFunction · 0.50
amount_msat_lessFunction · 0.50

Tested by

no test coverage detected