mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
plugin: Check that we have a non-empty route in libplugin
Changelog-Fixed: pay: Payments with an empty route (self-payment) are now aborted.
This commit is contained in:
@@ -807,6 +807,12 @@ static struct command_result *payment_getroute(struct payment *p)
|
|||||||
p->step = PAYMENT_STEP_GOT_ROUTE;
|
p->step = PAYMENT_STEP_GOT_ROUTE;
|
||||||
p->route = route_hops_from_route(p, p, r);
|
p->route = route_hops_from_route(p, p, r);
|
||||||
|
|
||||||
|
if (tal_count(p->route) == 0) {
|
||||||
|
payment_root(p)->abort = true;
|
||||||
|
payment_fail(p, "Empty route returned by getroute, are you "
|
||||||
|
"trying to pay yourself?");
|
||||||
|
}
|
||||||
|
|
||||||
fee = payment_route_fee(p);
|
fee = payment_route_fee(p);
|
||||||
|
|
||||||
/* Ensure that our fee and CLTV budgets are respected. */
|
/* Ensure that our fee and CLTV budgets are respected. */
|
||||||
|
|||||||
@@ -4134,7 +4134,6 @@ def test_sendinvoice(node_factory, bitcoind):
|
|||||||
'label': 'test sendinvoice refund'})
|
'label': 'test sendinvoice refund'})
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.xfail(strict=True)
|
|
||||||
def test_self_pay(node_factory):
|
def test_self_pay(node_factory):
|
||||||
"""Repro test for issue 4345: pay ourselves via the pay plugin.
|
"""Repro test for issue 4345: pay ourselves via the pay plugin.
|
||||||
|
|
||||||
@@ -4142,4 +4141,6 @@ def test_self_pay(node_factory):
|
|||||||
l1, l2 = node_factory.line_graph(2, wait_for_announce=True)
|
l1, l2 = node_factory.line_graph(2, wait_for_announce=True)
|
||||||
|
|
||||||
inv = l1.rpc.invoice(10000, 'test', 'test')['bolt11']
|
inv = l1.rpc.invoice(10000, 'test', 'test')['bolt11']
|
||||||
|
|
||||||
|
with pytest.raises(RpcError):
|
||||||
l1.rpc.pay(inv)
|
l1.rpc.pay(inv)
|
||||||
|
|||||||
Reference in New Issue
Block a user