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

Function channel_amount_receivable

lightningd/peer_control.c:646–680  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

644}
645
646struct amount_msat channel_amount_receivable(const struct channel *channel)
647{
648 struct amount_msat their_msat, receivable;
649
650 /* Compute how much we can receive via this channel in one payment */
651 if (!amount_sat_sub_msat(&their_msat,
652 channel->funding_sats, channel->our_msat))
653 their_msat = AMOUNT_MSAT(0);
654
655 if (!amount_msat_sub_sat(&receivable,
656 their_msat,
657 channel->our_config.channel_reserve))
658 return AMOUNT_MSAT(0);
659
660 /* Take away any currently-offered HTLCs. */
661 subtract_received_htlcs(channel, &receivable);
662
663 /* If they're opener, subtract txfees they'll need to spend this */
664 if (channel->opener == REMOTE) {
665 if (!amount_msat_sub_sat(&receivable, receivable,
666 commit_txfee(channel,
667 receivable, REMOTE)))
668 return AMOUNT_MSAT(0);
669 }
670
671 /* They can't offer an HTLC less than what we will accept. */
672 if (amount_msat_less(receivable, channel->our_config.htlc_minimum))
673 return AMOUNT_MSAT(0);
674
675 /* They can't offer an HTLC over the max payment threshold either. */
676 if (amount_msat_greater(receivable, chainparams->max_payment))
677 receivable = chainparams->max_payment;
678
679 return receivable;
680}
681
682static void json_add_channel(struct lightningd *ld,
683 struct json_stream *response, const char *key,

Callers 2

json_add_channelFunction · 0.85
routehint_candidatesFunction · 0.85

Calls 6

amount_sat_sub_msatFunction · 0.85
amount_msat_sub_satFunction · 0.85
subtract_received_htlcsFunction · 0.85
commit_txfeeFunction · 0.85
amount_msat_lessFunction · 0.85
amount_msat_greaterFunction · 0.85

Tested by

no test coverage detected