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

Function channel_amount_spendable

lightningd/peer_control.c:613–644  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

611}
612
613struct amount_msat channel_amount_spendable(const struct channel *channel)
614{
615 struct amount_msat spendable;
616
617 /* Compute how much we can send via this channel in one payment. */
618 if (!amount_msat_sub_sat(&spendable,
619 channel->our_msat,
620 channel->channel_info.their_config.channel_reserve))
621 return AMOUNT_MSAT(0);
622
623 /* Take away any currently-offered HTLCs. */
624 subtract_offered_htlcs(channel, &spendable);
625
626 /* If we're opener, subtract txfees we'll need to spend this */
627 if (channel->opener == LOCAL) {
628 if (!amount_msat_sub_sat(&spendable, spendable,
629 commit_txfee(channel, spendable,
630 LOCAL)))
631 return AMOUNT_MSAT(0);
632 }
633
634 /* We can't offer an HTLC less than the other side will accept. */
635 if (amount_msat_less(spendable,
636 channel->channel_info.their_config.htlc_minimum))
637 return AMOUNT_MSAT(0);
638
639 /* We can't offer an HTLC over the max payment threshold either. */
640 if (amount_msat_greater(spendable, chainparams->max_payment))
641 spendable = chainparams->max_payment;
642
643 return spendable;
644}
645
646struct amount_msat channel_amount_receivable(const struct channel *channel)
647{

Callers 2

json_add_channelFunction · 0.85
best_channelFunction · 0.85

Calls 5

amount_msat_sub_satFunction · 0.85
subtract_offered_htlcsFunction · 0.85
commit_txfeeFunction · 0.85
amount_msat_lessFunction · 0.85
amount_msat_greaterFunction · 0.85

Tested by

no test coverage detected