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

Function channel_amount_receivable

lightningd/peer_control.c:892–933  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

890}
891
892struct amount_msat channel_amount_receivable(const struct channel *channel)
893{
894 struct amount_msat their_msat, receivable;
895 bool wumbo;
896
897 /* Compute how much we can receive via this channel in one payment */
898 if (!amount_sat_sub_msat(&their_msat,
899 channel->funding_sats, channel->our_msat))
900 their_msat = AMOUNT_MSAT(0);
901
902 if (!amount_msat_sub_sat(&receivable,
903 their_msat,
904 channel->our_config.channel_reserve))
905 return AMOUNT_MSAT(0);
906
907 /* Take away any currently-offered HTLCs. */
908 subtract_received_htlcs(channel, &receivable);
909
910 /* If they're opener, subtract txfees they'll need to spend this */
911 if (channel->opener == REMOTE) {
912 if (!amount_msat_deduct_sat(&receivable,
913 commit_txfee(channel,
914 receivable, REMOTE)))
915 return AMOUNT_MSAT(0);
916 }
917
918 /* They can't offer an HTLC less than what we will accept. */
919 if (amount_msat_less(receivable, channel->our_config.htlc_minimum))
920 return AMOUNT_MSAT(0);
921
922 wumbo = feature_negotiated(channel->peer->ld->our_features,
923 channel->peer->their_features,
924 OPT_LARGE_CHANNELS);
925
926 /* They can't offer an HTLC over the max payment threshold either. */
927 if (amount_msat_greater(receivable, chainparams->max_payment)
928 && !wumbo) {
929 receivable = chainparams->max_payment;
930 }
931
932 return receivable;
933}
934
935static void NON_NULL_ARGS(1, 2, 4, 5) json_add_channel(struct command *cmd,
936 struct json_stream *response,

Callers 2

peer_control.cFile · 0.85
routehint_candidatesFunction · 0.85

Calls 8

amount_sat_sub_msatFunction · 0.85
amount_msat_sub_satFunction · 0.85
subtract_received_htlcsFunction · 0.85
amount_msat_deduct_satFunction · 0.85
commit_txfeeFunction · 0.85
feature_negotiatedFunction · 0.85
amount_msat_greaterFunction · 0.85
amount_msat_lessFunction · 0.50

Tested by

no test coverage detected