invoice: don't allow zero-value invoices.

You can't pay them anyway, and at least one person used 0 instead of "any".

Closes: #3808
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: JSON-RPC: `invoice` no longer accepts zero amounts (did you mean "any"?)
This commit is contained in:
Rusty Russell
2020-08-25 10:35:46 +09:30
parent 2e51f23a95
commit ef3fbab551
4 changed files with 32 additions and 10 deletions

View File

@@ -59,6 +59,26 @@ def test_invoice(node_factory, chainparams):
l2.rpc.invoice(4294967295, 'inv3', '?')
def test_invoice_zeroval(node_factory):
"""A zero value invoice is unpayable, did you mean 'any'?"""
l1 = node_factory.get_node()
with pytest.raises(RpcError, match=r"positive .* not '0'"):
l1.rpc.invoice(0, 'inv', '?')
with pytest.raises(RpcError, match=r"positive .* not '0msat'"):
l1.rpc.invoice('0msat', 'inv', '?')
with pytest.raises(RpcError, match=r"positive .* not '0sat'"):
l1.rpc.invoice('0sat', 'inv', '?')
with pytest.raises(RpcError, match=r"positive .* not '0.00000000btc'"):
l1.rpc.invoice('0.00000000btc', 'inv', '?')
with pytest.raises(RpcError, match=r"positive .* not '0.00000000000btc'"):
l1.rpc.invoice('0.00000000000btc', 'inv', '?')
def test_invoice_weirdstring(node_factory):
l1 = node_factory.get_node()