Skip to content

Commit

Permalink
pay: don't say "Could not find a route" unless we never tried a payment.
Browse files Browse the repository at this point in the history
It's deeply confusing: we say this after exhausting all other routes.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed May 22, 2019
1 parent aa62ae3 commit 71460ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions plugins/pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ static struct command_result *next_routehint(struct command *cmd,
return command_fail(cmd, PAY_ROUTE_TOO_EXPENSIVE,
"%s", pc->expensive_route);

if (tal_count(pc->ps->attempts) > 1)
return command_fail(cmd, PAY_STOPPED_RETRYING,
"Ran out of routes to try after"
" %zu attempts: see paystatus",
tal_count(pc->ps->attempts));

return command_fail(cmd, PAY_ROUTE_NOT_FOUND,
"Could not find a route");
}
Expand Down
7 changes: 6 additions & 1 deletion tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,7 @@ def exhaust_channel(funder, fundee, scid, already_spent=0):
# This should make it fail.
exhaust_channel(l4, l5, scid45, 10**8)

with pytest.raises(RpcError):
with pytest.raises(RpcError, match=r'5 attempts'):
l1.rpc.pay(l5.rpc.invoice(10**8, 'test_retry2', 'test_retry2')['bolt11'])


Expand All @@ -1475,6 +1475,11 @@ def test_pay_routeboost(node_factory, bitcoind):
# l1->l2->l3--private-->l4
l1, l2 = node_factory.line_graph(2, announce_channels=True, wait_for_announce=True)
l3, l4, l5 = node_factory.line_graph(3, announce_channels=False, wait_for_announce=False)

# This should a "could not find a route" because that's true.
with pytest.raises(RpcError, match=r'Could not find a route'):
l1.rpc.pay(l5.rpc.invoice(10**8, 'test_retry', 'test_retry')['bolt11'])

l2.rpc.connect(l3.info['id'], 'localhost', l3.port)
scidl2l3 = l2.fund_channel(l3, 10**6)

Expand Down

0 comments on commit 71460ac

Please sign in to comment.