Skip to content

Commit

Permalink
listpays: change type answer is bolt11 is null
Browse files Browse the repository at this point in the history
  • Loading branch information
vincenzopalazzo committed Jul 27, 2020
1 parent 81fd552 commit b59f72b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
6 changes: 5 additions & 1 deletion plugins/pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -1702,7 +1702,11 @@ static void add_new_entry(struct json_stream *ret,
const struct pay_mpp *pm)
{
json_object_start(ret, NULL);
json_add_string(ret, "bolt11", pm->b11);
if(pm->b11){
json_add_string(ret, "bolt11", pm->b11);
}else{
json_add_sha256(ret, "payment_hash", pm->payment_hash);
}
json_add_string(ret, "status", pm->status);
if (pm->label)
json_add_tok(ret, "label", pm->label, buf);
Expand Down
24 changes: 24 additions & 0 deletions tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -3216,3 +3216,27 @@ def test_bolt11_null_after_pay(node_factory, bitcoind):

pays = l2.rpc.listpays()["pays"]
assert pays[0]["bolt11"] == invl1


def test_listpay_resutl_with_paymod(node_factory, bitcoind):
"""
The object of this test is to verify the correct behavior
of the RPC command listpay e with two different type of
payment, such as: keysend (without invoice) and pay (with invoice).
l1 -> keysend -> l2
l2 -> pay invoice -> l3
"""

amount_sat = 10 ** 6

l1, l2, l3 = node_factory.line_graph(3)

invl2 = l2.rpc.invoice(amount_sat * 2, "inv_l2", "inv_l2")
l1.rpc.pay(invl2['bolt11'])

l2.rpc.keysend(l3.info['id'], amount_sat * 2, "keysend_l3")

assert 'bolt11' in l1.rpc.listpays()['pays'][0]
assert 'payment_hash' in l2.rpc.listpays()['pays'][0]
assert 'payment_hash' not in l1.rpc.listpays()['pays'][0]
assert 'bolt11' not in l2.rpc.listpays()['pays'][0]

0 comments on commit b59f72b

Please sign in to comment.