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

Function channel_amount_spendable

lightningd/peer_control.c:908–946  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

906}
907
908struct amount_msat channel_amount_spendable(const struct channel *channel)
909{
910 struct amount_msat spendable;
911 bool wumbo;
912
913 /* Compute how much we can send via this channel in one payment. */
914 if (!amount_msat_sub_sat(&spendable,
915 channel->our_msat,
916 channel->channel_info.their_config.channel_reserve))
917 return AMOUNT_MSAT(0);
918
919 /* Take away any currently-offered HTLCs. */
920 subtract_offered_htlcs(channel, &spendable);
921
922 /* If we're opener, subtract txfees we'll need to spend this */
923 if (channel->opener == LOCAL) {
924 if (!amount_msat_deduct_sat(&spendable,
925 commit_txfee(channel, spendable,
926 LOCAL)))
927 return AMOUNT_MSAT(0);
928 }
929
930 /* We can't offer an HTLC less than the other side will accept. */
931 if (amount_msat_less(spendable,
932 channel->channel_info.their_config.htlc_minimum))
933 return AMOUNT_MSAT(0);
934
935 wumbo = feature_negotiated(channel->peer->ld->our_features,
936 channel->peer->their_features,
937 OPT_LARGE_CHANNELS);
938
939 /* We can't offer an HTLC over the max payment threshold either. */
940 if (amount_msat_greater(spendable, chainparams->max_payment)
941 && !wumbo) {
942 spendable = chainparams->max_payment;
943 }
944
945 return spendable;
946}
947
948struct amount_msat channel_amount_receivable(const struct channel *channel)
949{

Callers 2

peer_control.cFile · 0.85
best_channelFunction · 0.85

Calls 7

amount_msat_sub_satFunction · 0.85
subtract_offered_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