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

Function htlc_max_possible_send

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

296 * FIXME: does this need fuzz?
297 */
298struct amount_msat htlc_max_possible_send(const struct channel *channel)
299{
300 struct amount_sat lower_bound;
301 struct amount_msat lower_bound_msat;
302
303 /* These shouldn't fail */
304 if (!amount_sat_sub(&lower_bound, channel->funding_sats,
305 channel->channel_info.their_config.channel_reserve)) {
306 log_broken(channel->log, "%s: their reserve %s > funding %s!",
307 __func__,
308 type_to_string(tmpctx, struct amount_sat,
309 &channel->funding_sats),
310 type_to_string(tmpctx, struct amount_sat,
311 &channel->channel_info.their_config.channel_reserve));
312 return AMOUNT_MSAT(0);
313 }
314
315 if (!amount_sat_to_msat(&lower_bound_msat, lower_bound)) {
316 log_broken(channel->log, "%s: impossible size channel %s!",
317 __func__,
318 type_to_string(tmpctx, struct amount_sat,
319 &lower_bound));
320 return AMOUNT_MSAT(0);
321 }
322
323 if (amount_msat_less(channel->channel_info.their_config.max_htlc_value_in_flight,
324 lower_bound_msat))
325 lower_bound_msat = channel->channel_info.their_config.max_htlc_value_in_flight;
326
327 return lower_bound_msat;
328}
329
330struct channel *new_channel(struct peer *peer, u64 dbid,
331 /* 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_msat_lessFunction · 0.85
amount_sat_subFunction · 0.50
type_to_stringClass · 0.50
amount_sat_to_msatFunction · 0.50

Tested by

no test coverage detected