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

Function channel_amount_spendable

lightningd/peer_control.c:852–890  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

850}
851
852struct amount_msat channel_amount_spendable(const struct channel *channel)
853{
854 struct amount_msat spendable;
855 bool wumbo;
856
857 /* Compute how much we can send via this channel in one payment. */
858 if (!amount_msat_sub_sat(&spendable,
859 channel->our_msat,
860 channel->channel_info.their_config.channel_reserve))
861 return AMOUNT_MSAT(0);
862
863 /* Take away any currently-offered HTLCs. */
864 subtract_offered_htlcs(channel, &spendable);
865
866 /* If we're opener, subtract txfees we'll need to spend this */
867 if (channel->opener == LOCAL) {
868 if (!amount_msat_deduct_sat(&spendable,
869 commit_txfee(channel, spendable,
870 LOCAL)))
871 return AMOUNT_MSAT(0);
872 }
873
874 /* We can't offer an HTLC less than the other side will accept. */
875 if (amount_msat_less(spendable,
876 channel->channel_info.their_config.htlc_minimum))
877 return AMOUNT_MSAT(0);
878
879 wumbo = feature_negotiated(channel->peer->ld->our_features,
880 channel->peer->their_features,
881 OPT_LARGE_CHANNELS);
882
883 /* We can't offer an HTLC over the max payment threshold either. */
884 if (amount_msat_greater(spendable, chainparams->max_payment)
885 && !wumbo) {
886 spendable = chainparams->max_payment;
887 }
888
889 return spendable;
890}
891
892struct amount_msat channel_amount_receivable(const struct channel *channel)
893{

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