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

Function channel_amount_spendable

lightningd/peer_control.c:883–921  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

881}
882
883struct amount_msat channel_amount_spendable(const struct channel *channel)
884{
885 struct amount_msat spendable;
886 bool wumbo;
887
888 /* Compute how much we can send via this channel in one payment. */
889 if (!amount_msat_sub_sat(&spendable,
890 channel->our_msat,
891 channel->channel_info.their_config.channel_reserve))
892 return AMOUNT_MSAT(0);
893
894 /* Take away any currently-offered HTLCs. */
895 subtract_offered_htlcs(channel, &spendable);
896
897 /* If we're opener, subtract txfees we'll need to spend this */
898 if (channel->opener == LOCAL) {
899 if (!amount_msat_deduct_sat(&spendable,
900 commit_txfee(channel, spendable,
901 LOCAL)))
902 return AMOUNT_MSAT(0);
903 }
904
905 /* We can't offer an HTLC less than the other side will accept. */
906 if (amount_msat_less(spendable,
907 channel->channel_info.their_config.htlc_minimum))
908 return AMOUNT_MSAT(0);
909
910 wumbo = feature_negotiated(channel->peer->ld->our_features,
911 channel->peer->their_features,
912 OPT_LARGE_CHANNELS);
913
914 /* We can't offer an HTLC over the max payment threshold either. */
915 if (amount_msat_greater(spendable, chainparams->max_payment)
916 && !wumbo) {
917 spendable = chainparams->max_payment;
918 }
919
920 return spendable;
921}
922
923struct amount_msat channel_amount_receivable(const struct channel *channel)
924{

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