Skip to content

Commit 3ca1c70

Browse files
rustyrussellcdecker
authored andcommitted
lightningd: don't cap spendable_msat/receivable_msat for wumbo channels.
If we both support large channels, we can actually send giant HTLCs. This, in turn, fixes pay (which relies on this field!). Signed-off-by: Rusty Russell <[email protected]> Changelog-Fixed: Plugins: `pay` now knows it can use locally-connected wumbo channels for large payments. Fixes: #5250 Fixes: #5417
1 parent b6555dc commit 3ca1c70

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

lightningd/peer_control.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ static void subtract_received_htlcs(const struct channel *channel,
613613
struct amount_msat channel_amount_spendable(const struct channel *channel)
614614
{
615615
struct amount_msat spendable;
616+
bool wumbo;
616617

617618
/* Compute how much we can send via this channel in one payment. */
618619
if (!amount_msat_sub_sat(&spendable,
@@ -636,16 +637,23 @@ struct amount_msat channel_amount_spendable(const struct channel *channel)
636637
channel->channel_info.their_config.htlc_minimum))
637638
return AMOUNT_MSAT(0);
638639

640+
wumbo = feature_negotiated(channel->peer->ld->our_features,
641+
channel->peer->their_features,
642+
OPT_LARGE_CHANNELS);
643+
639644
/* We can't offer an HTLC over the max payment threshold either. */
640-
if (amount_msat_greater(spendable, chainparams->max_payment))
645+
if (amount_msat_greater(spendable, chainparams->max_payment)
646+
&& !wumbo) {
641647
spendable = chainparams->max_payment;
648+
}
642649

643650
return spendable;
644651
}
645652

646653
struct amount_msat channel_amount_receivable(const struct channel *channel)
647654
{
648655
struct amount_msat their_msat, receivable;
656+
bool wumbo;
649657

650658
/* Compute how much we can receive via this channel in one payment */
651659
if (!amount_sat_sub_msat(&their_msat,
@@ -672,9 +680,15 @@ struct amount_msat channel_amount_receivable(const struct channel *channel)
672680
if (amount_msat_less(receivable, channel->our_config.htlc_minimum))
673681
return AMOUNT_MSAT(0);
674682

683+
wumbo = feature_negotiated(channel->peer->ld->our_features,
684+
channel->peer->their_features,
685+
OPT_LARGE_CHANNELS);
686+
675687
/* They can't offer an HTLC over the max payment threshold either. */
676-
if (amount_msat_greater(receivable, chainparams->max_payment))
688+
if (amount_msat_greater(receivable, chainparams->max_payment)
689+
&& !wumbo) {
677690
receivable = chainparams->max_payment;
691+
}
678692

679693
return receivable;
680694
}

tests/test_connection.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3407,7 +3407,6 @@ def test_pay_disconnect_stress(node_factory, executor):
34073407

34083408
@pytest.mark.openchannel('v1')
34093409
@pytest.mark.openchannel('v2')
3410-
@pytest.mark.xfail(strict=True)
34113410
def test_wumbo_channels(node_factory, bitcoind):
34123411
l1, l2, l3 = node_factory.get_nodes(3,
34133412
opts=[{'large-channels': None},

0 commit comments

Comments
 (0)