Skip to content

Document listsendpays amount msat better #8384

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions contrib/msggen/msggen/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -21942,7 +21942,7 @@
"amount_msat": {
"type": "msat",
"description": [
"The amount of millisatoshi we intended to send to the destination."
"The amount of millisatoshi we intended to send to the destination. This can only be missing in the case of someone manually calling sendonion without the `amount_msat` parameter (which no plugin currently does)."
]
},
"amount_sent_msat": {
Expand Down Expand Up @@ -24449,7 +24449,7 @@
"amount_msat": {
"type": "msat",
"description": [
"The amount delivered to destination (if known)."
"The amount delivered to destination (if known). This is not known in the case where sendonion(7) was used to manually initiate a payment without the `amount_msat` parameter."
]
},
"destination": {
Expand Down Expand Up @@ -29732,6 +29732,7 @@
"rpc": "sendonion",
"title": "Send a payment with a custom onion packet",
"description": [
"Note: you probably want to use the more modern and flexible `injectpaymentonion` command instead of this.",
"The **sendonion** RPC command can be used to initiate a payment attempt with a custom onion packet. The onion packet is used to deliver instructions for hops along the route on how to behave. Normally these instructions are indications on where to forward a payment and what parameters to use, or contain details of the payment for the final hop. However, it is possible to add arbitrary information for hops in the custom onion, allowing for custom extensions that are not directly supported by Core Lightning.",
"",
"If the first element of *route* does not have \"channel\" set, a suitable channel (if any) will be chosen, otherwise that specific short-channel-id is used. The following is an example of a 3 hop onion:",
Expand Down Expand Up @@ -30057,6 +30058,7 @@
"Christian Decker <<[email protected]>> is mainly responsible."
],
"see_also": [
"lightning-injectpaymentonion(7)",
"lightning-createonion(7)",
"lightning-sendpay(7)",
"lightning-listsendpays(7)"
Expand Down
2 changes: 1 addition & 1 deletion doc/schemas/listpays.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
"amount_msat": {
"type": "msat",
"description": [
"The amount of millisatoshi we intended to send to the destination."
"The amount of millisatoshi we intended to send to the destination. This can only be missing in the case of someone manually calling sendonion without the `amount_msat` parameter (which no plugin currently does)."
]
},
"amount_sent_msat": {
Expand Down
2 changes: 1 addition & 1 deletion doc/schemas/listsendpays.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
"amount_msat": {
"type": "msat",
"description": [
"The amount delivered to destination (if known)."
"The amount delivered to destination (if known). This is not known in the case where sendonion(7) was used to manually initiate a payment without the `amount_msat` parameter."
]
},
"destination": {
Expand Down
2 changes: 2 additions & 0 deletions doc/schemas/sendonion.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"rpc": "sendonion",
"title": "Send a payment with a custom onion packet",
"description": [
"Note: you probably want to use the more modern and flexible `injectpaymentonion` command instead of this.",
"The **sendonion** RPC command can be used to initiate a payment attempt with a custom onion packet. The onion packet is used to deliver instructions for hops along the route on how to behave. Normally these instructions are indications on where to forward a payment and what parameters to use, or contain details of the payment for the final hop. However, it is possible to add arbitrary information for hops in the custom onion, allowing for custom extensions that are not directly supported by Core Lightning.",
"",
"If the first element of *route* does not have \"channel\" set, a suitable channel (if any) will be chosen, otherwise that specific short-channel-id is used. The following is an example of a 3 hop onion:",
Expand Down Expand Up @@ -329,6 +330,7 @@
"Christian Decker <<[email protected]>> is mainly responsible."
],
"see_also": [
"lightning-injectpaymentonion(7)",
"lightning-createonion(7)",
"lightning-sendpay(7)",
"lightning-listsendpays(7)"
Expand Down
25 changes: 16 additions & 9 deletions tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -2995,16 +2995,20 @@ def test_sendonion_rpc(node_factory):
invs = l4.rpc.listinvoices(label="lbl")['invoices']
assert(len(invs) == 1 and invs[0]['status'] == 'paid')

pays = l1.rpc.listsendpays()['payments']
assert(len(pays) == 1 and pays[0]['status'] == 'complete'
and pays[0]['payment_hash'] == inv['payment_hash'])
pay = only_one(l1.rpc.listsendpays()['payments'])
assert (pay['status'] == 'complete'
and pay['payment_hash'] == inv['payment_hash'])

# listsendpays promised that amount would be missing if sendonion didn't
# specify
assert 'amount_msat' not in pay

# And now for a failing payment, using a payment_hash that doesn't match an
# invoice
payment_hash = "00" * 32
onion = l1.rpc.createonion(hops=hops, assocdata=payment_hash)
l1.rpc.sendonion(onion=onion['onion'], first_hop=first_hop,
payment_hash=payment_hash)
payment_hash=payment_hash, amount_msat=amt)

try:
l1.rpc.waitsendpay(payment_hash=payment_hash)
Expand All @@ -3013,13 +3017,16 @@ def test_sendonion_rpc(node_factory):
assert(e.error['code'] == 202)
assert(e.error['message'] == "Malformed error reply")

pays = l1.rpc.listsendpays(payment_hash=payment_hash)['payments']
assert(len(pays) == 1 and pays[0]['status'] == 'failed'
and pays[0]['payment_hash'] == payment_hash)
assert('erroronion' in pays[0])
pay = only_one(l1.rpc.listsendpays(payment_hash=payment_hash)['payments'])
assert(pay['status'] == 'failed'
and pay['payment_hash'] == payment_hash)
assert 'erroronion' in pay

# Since we told sendonion the destination amount, listsendpays will know:
assert pay['amount_msat'] == amt

# Fail onion is msg + padding = 256 + 2*2 byte lengths + 32 byte HMAC
assert(len(pays[0]['erroronion']) == (256 + 32 + 2 + 2) * 2)
assert(len(pay['erroronion']) == (256 + 32 + 2 + 2) * 2)

# Let's try that again, this time we give it the shared_secrets so it
# should be able to decode the error.
Expand Down
Loading