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

Function htlc_max_possible_send

lightningd/channel.c:462–490  ·  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

460 * FIXME: does this need fuzz?
461 */
462struct amount_msat htlc_max_possible_send(const struct channel *channel)
463{
464 struct amount_sat lower_bound;
465 struct amount_msat lower_bound_msat;
466
467 /* These shouldn't fail */
468 if (!amount_sat_sub(&lower_bound, channel->funding_sats,
469 channel->channel_info.their_config.channel_reserve)) {
470 log_broken(channel->log, "%s: their reserve %s > funding %s!",
471 __func__,
472 fmt_amount_sat(tmpctx, channel->funding_sats),
473 fmt_amount_sat(tmpctx,
474 channel->channel_info.their_config.channel_reserve));
475 return AMOUNT_MSAT(0);
476 }
477
478 if (!amount_sat_to_msat(&lower_bound_msat, lower_bound)) {
479 log_broken(channel->log, "%s: impossible size channel %s!",
480 __func__,
481 fmt_amount_sat(tmpctx, lower_bound));
482 return AMOUNT_MSAT(0);
483 }
484
485 if (amount_msat_less(channel->channel_info.their_config.max_htlc_value_in_flight,
486 lower_bound_msat))
487 lower_bound_msat = channel->channel_info.their_config.max_htlc_value_in_flight;
488
489 return lower_bound_msat;
490}
491
492struct channel *new_channel(struct peer *peer, u64 dbid,
493 /* 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