keysend: Add error when trying to send to self

There is little point in faking a self-payment, but we should also not
crash :-)

Fixes #4438

Changelog-Fixed: keysend: Keysend returns an error when a self-payment is requested
This commit is contained in:
Christian Decker
2021-03-17 12:30:06 +01:00
committed by Rusty Russell
parent 3a031bf0e3
commit 6cfb72ea1b
2 changed files with 11 additions and 1 deletions

View File

@@ -3030,6 +3030,10 @@ def test_keysend(node_factory):
features = l1.rpc.listnodes(l4.info['id'])['nodes'][0]['features']
assert(int(features, 16) >> 55 & 0x01 == 0)
# Self-sends are not allowed (see #4438)
with pytest.raises(RpcError, match=r'We are the destination.'):
l1.rpc.keysend(l1.info['id'], amt)
# Send an indirect one from l1 to l3
l1.rpc.keysend(l3.info['id'], amt)
invs = l3.rpc.listinvoices()['invoices']