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

Function channel_amount_receivable

lightningd/peer_control.c:923–964  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

921}
922
923struct amount_msat channel_amount_receivable(const struct channel *channel)
924{
925 struct amount_msat their_msat, receivable;
926 bool wumbo;
927
928 /* Compute how much we can receive via this channel in one payment */
929 if (!amount_sat_sub_msat(&their_msat,
930 channel->funding_sats, channel->our_msat))
931 their_msat = AMOUNT_MSAT(0);
932
933 if (!amount_msat_sub_sat(&receivable,
934 their_msat,
935 channel->our_config.channel_reserve))
936 return AMOUNT_MSAT(0);
937
938 /* Take away any currently-offered HTLCs. */
939 subtract_received_htlcs(channel, &receivable);
940
941 /* If they're opener, subtract txfees they'll need to spend this */
942 if (channel->opener == REMOTE) {
943 if (!amount_msat_deduct_sat(&receivable,
944 commit_txfee(channel,
945 receivable, REMOTE)))
946 return AMOUNT_MSAT(0);
947 }
948
949 /* They can't offer an HTLC less than what we will accept. */
950 if (amount_msat_less(receivable, channel->our_config.htlc_minimum))
951 return AMOUNT_MSAT(0);
952
953 wumbo = feature_negotiated(channel->peer->ld->our_features,
954 channel->peer->their_features,
955 OPT_LARGE_CHANNELS);
956
957 /* They can't offer an HTLC over the max payment threshold either. */
958 if (amount_msat_greater(receivable, chainparams->max_payment)
959 && !wumbo) {
960 receivable = chainparams->max_payment;
961 }
962
963 return receivable;
964}
965
966static void NON_NULL_ARGS(1, 2, 4, 5) json_add_channel(struct command *cmd,
967 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