From 044860881e54dd71da455220fff58ad8b17c11f5 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 31 May 2019 17:00:33 +0930 Subject: [PATCH] lightningd: don't let spendable_msat go wumbo. Signed-off-by: Rusty Russell --- lightningd/peer_control.c | 4 ++++ tests/test_pay.py | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index e73dbde18..2c5004ca1 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -688,6 +688,10 @@ static void json_add_channel(struct lightningd *ld, channel->channel_info.their_config.htlc_minimum)) spendable = AMOUNT_MSAT(0); + /* We can't offer an HTLC over the max payment threshold either. */ + if (amount_msat_greater(spendable, get_chainparams(ld)->max_payment)) + spendable = get_chainparams(ld)->max_payment; + json_add_amount_msat_compat(response, spendable, "spendable_msatoshi", "spendable_msat"); json_add_amount_msat_compat(response, diff --git a/tests/test_pay.py b/tests/test_pay.py index 586fe6d57..dbd01c66e 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -2124,7 +2124,6 @@ def test_channel_spendable_large(node_factory, bitcoind): l1.rpc.waitsendpay(payment_hash, TIMEOUT) -@pytest.mark.xfail(strict=True) def test_channel_spendable_capped(node_factory, bitcoind): """Test that spendable_msat is capped at 2^32-1""" sats = 16777215