Skip to content

Commit

Permalink
offerout: don't insist that invoice vendor match our vendor.
Browse files Browse the repository at this point in the history
This was a bug in the spec, actually.

Reported-by: @shesek
Signed-off-by: Rusty Russell <[email protected]>
Fixes: ElementsProject#4666
  • Loading branch information
rustyrussell authored and niftynei committed Jul 21, 2021
1 parent cb9e026 commit ce338dc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
4 changes: 0 additions & 4 deletions plugins/offers_inv_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,11 @@ static struct command_result *listoffers_done(struct command *cmd,
* or unset exactly as they are in the `offer`:
* - `refund_for`
* - `description`
* - `vendor`
*/
err = inv_must_equal_offer(cmd, inv, refund_for);
if (err)
return err;
err = inv_must_equal_offer(cmd, inv, description);
if (err)
return err;
err = inv_must_equal_offer(cmd, inv, vendor);
if (err)
return err;

Expand Down
21 changes: 21 additions & 0 deletions tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -4452,6 +4452,27 @@ def test_sendinvoice(node_factory, bitcoind):
'label': 'test sendinvoice refund'})
wait_for(lambda: only_one(l2.rpc.call('listoffers', [refund['offer_id']])['offers'])['used'] is True)

# Offer with vendor: we must not copy vendor into our invoice!
offer = l1.rpc.call('offerout', {'amount': '10000sat',
'description': 'simple test',
'vendor': "clightning test suite"})

out = l2.rpc.call('sendinvoice', {'offer': offer['bolt12'],
'label': 'test sendinvoice 3'})
assert out['label'] == 'test sendinvoice 3'
assert out['description'] == 'simple test'
assert 'vendor' not in out
assert 'bolt12' in out
assert 'payment_hash' in out
assert out['status'] == 'paid'
assert 'payment_preimage' in out
assert 'expires_at' in out
assert out['msatoshi'] == 10000000
assert out['amount_msat'] == Millisatoshi(10000000)
assert 'pay_index' in out
assert out['msatoshi_received'] == 10000000
assert out['amount_received_msat'] == Millisatoshi(10000000)


def test_self_pay(node_factory):
"""Repro test for issue 4345: pay ourselves via the pay plugin.
Expand Down

0 comments on commit ce338dc

Please sign in to comment.