invoice: hack in merkle of invoice as "payment_secret" (EXPERIMENTAL_FEATURES)

This lets actually pay the invoice that fetchinvoice returns.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2020-12-16 13:48:42 +10:30
committed by Christian Decker
parent 2baa410e2b
commit 19af1d10e6
3 changed files with 70 additions and 0 deletions

View File

@@ -3856,6 +3856,8 @@ def test_fetchinvoice(node_factory, bitcoind):
inv1 = l1.rpc.call('fetchinvoice', {'offer': offer})
inv2 = l1.rpc.call('fetchinvoice', {'offer': offer})
assert inv1 != inv2
l1.rpc.pay(inv1['invoice'])
l1.rpc.pay(inv2['invoice'])
# Single-use invoice can be fetched multiple times, only paid once.
offer = l3.rpc.call('offer', {'amount': '1msat',
@@ -3866,3 +3868,34 @@ def test_fetchinvoice(node_factory, bitcoind):
inv1 = l1.rpc.call('fetchinvoice', {'offer': offer})
inv2 = l1.rpc.call('fetchinvoice', {'offer': offer})
assert inv1 != inv2
l1.rpc.pay(inv1['invoice'])
# FIXME: We don't report failure yet.
# # We can't pay the other one now.
# with pytest.raises(RpcError, match='???'):
# l1.rpc.pay(inv2['invoice'])
#
# # We can't reuse the offer, either.
# with pytest.raises(RpcError, match='???'):
# l1.rpc.call('fetchinvoice', {'offer': offer})
# Recurring offer.
offer = l2.rpc.call('offer', {'amount': '1msat',
'description': 'recurring test',
'recurrence': '1minutes'})['bolt12']
print(offer)
ret = l1.rpc.call('fetchinvoice', {'offer': offer,
'recurrence_counter': 0,
'recurrence_label': 'test recurrence'})
print(ret)
l1.rpc.pay(ret['invoice'], label='test recurrence')
ret = l1.rpc.call('fetchinvoice', {'offer': offer,
'recurrence_counter': 1,
'recurrence_label': 'test recurrence'})
print(ret)
l1.rpc.pay(ret['invoice'], label='test recurrence')