-
Notifications
You must be signed in to change notification settings - Fork 912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lightningd: disallow msatoshi
arg to sendpay unless exact when non-…
#3470
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2601,7 +2601,7 @@ def test_partial_payment(node_factory, bitcoind, executor): | |
with pytest.raises(RpcError, match=r'Already have parallel payment in progress'): | ||
l1.rpc.sendpay(route=r124, | ||
payment_hash=inv['payment_hash'], | ||
msatoshi=1000, | ||
msatoshi=499, | ||
payment_secret=paysecret) | ||
|
||
# It will not allow a parallel with different msatoshi! | ||
|
@@ -2800,3 +2800,35 @@ def pay(l1, inv): | |
|
||
# pay command should complete without error | ||
fut.result() | ||
|
||
|
||
def test_sendpay_msatoshi_arg(node_factory): | ||
"""sendpay msatoshi arg was used for non-MPP to indicate the amount | ||
they asked for. But using it with anything other than the final amount | ||
caused a crash in 0.8.0, so we then disallowed it. | ||
""" | ||
Comment on lines
+2806
to
+2809
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: comments should be a short single line description (<80 chars), followed by a blank line, and then a multiline description (if any) that is indented to match the """Verify that the msatoshi arg is checked for `sendpay`.
The `sendpay` `msatoshi` argument was used for non-MPP to indicate the amount
they asked for. But using it with anything other than the final amount caused a crash
in 0.8.0, so we then disallowed it.
""" |
||
l1, l2 = node_factory.line_graph(2) | ||
|
||
inv = l2.rpc.invoice(1000, 'inv', 'inv') | ||
|
||
# Can't send non-MPP payment which specifies msatoshi != final. | ||
with pytest.raises(RpcError, match=r'Do not specify msatoshi \(1001msat\) without' | ||
' partid: if you do, it must be exactly' | ||
r' the final amount \(1000msat\)'): | ||
l1.rpc.sendpay(route=l1.rpc.getroute(l2.info['id'], 1000, 1)['route'], payment_hash=inv['payment_hash'], msatoshi=1001, bolt11=inv['bolt11']) | ||
with pytest.raises(RpcError, match=r'Do not specify msatoshi \(999msat\) without' | ||
' partid: if you do, it must be exactly' | ||
r' the final amount \(1000msat\)'): | ||
l1.rpc.sendpay(route=l1.rpc.getroute(l2.info['id'], 1000, 1)['route'], payment_hash=inv['payment_hash'], msatoshi=999, bolt11=inv['bolt11']) | ||
|
||
# Can't send MPP payment which pays any more than amount. | ||
with pytest.raises(RpcError, match=r'Final amount 1001msat is greater than 1000msat, despite MPP'): | ||
l1.rpc.sendpay(route=l1.rpc.getroute(l2.info['id'], 1001, 1)['route'], payment_hash=inv['payment_hash'], msatoshi=1000, bolt11=inv['bolt11'], partid=1) | ||
|
||
# But this works | ||
l1.rpc.sendpay(route=l1.rpc.getroute(l2.info['id'], 1001, 1)['route'], payment_hash=inv['payment_hash'], msatoshi=1001, bolt11=inv['bolt11']) | ||
l1.rpc.waitsendpay(inv['payment_hash']) | ||
|
||
inv = only_one(l2.rpc.listinvoices('inv')['invoices']) | ||
assert inv['status'] == 'paid' | ||
assert inv['amount_received_msat'] == Millisatoshi(1001) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This parameter used to be used for value randomization, where we overpay the payee, but record the exact amount indicated in the invoice in our database rather than the overpaid amount (i.e. treating the overpayment as a fee). We have since replaced value randomization with shadow routing, also overpaying the payee, but it seems this was no longer used to override the database record. I think it is better if our permanent records did not reveal the use of overpayment to obscure the location of the payee, but well. In any case changing
msatoshi
to make it signal multipath is a breaking change in the previous interface.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the original intent with mpp was to only override the semantic for msatoshi for this case, but since it's broken in 0.8.0 anyway :(
The original use has been largely superceded by the fact that we now save the bolt11 string with the payment.