core-lightning/doc/schemas/lightning-sendonion.json
Rusty Russell b327bd30c3 doc: fix all JSON schemas to enforce no additional properties.
Without this, we have hardly any enforcement.  This is why the schema
mistake fixed in the previous patches weren't spotted immediately.

The hard work was done by:

```
$ for f in lightning-*.json; do grep -v '^  "additionalProperties": false,' $f | bagto $f; done
$ for f in lightning-*.json; do sed 's/"properties": {/"additionalProperties": false, "properties": {/' $f | bagto $f; done
$ make fmt-schemas
```

Then checking where 'additionalProperties: true' had been turned to
false (we deliberately use it in some places where there are if
statements in the schema, or occasionally where there can be arbitrary
fields).

[Including doc/rpc-schema-draft.json update by Shahana]
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-10-30 15:39:12 +10:30

363 lines
14 KiB
JSON

{
"$schema": "../rpc-schema-draft.json",
"type": "object",
"rpc": "sendonion",
"title": "Send a payment with a custom onion packet",
"description": [
"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:",
"",
"```json",
"[",
" \"298606954e9de3e9d938d18a74fed794c440e8eda82e52dc08600953c8acf9c4\",",
" \"2dc094de72adb03b90894192edf9f67919cb2691b37b1f7d4a2f4f31c108b087\",",
" \"a7b82b240dbd77a4ac8ea07709b1395d8c510c73c17b4b392bb1f0605d989c85\"",
"]",
"```"
],
"request": {
"required": [
"onion",
"first_hop",
"payment_hash"
],
"additionalProperties": false,
"properties": {
"onion": {
"type": "hex",
"description": [
"Hex-encoded 1366 bytes long blob that was returned by either of the tools that can generate onions. It contains the payloads destined for each hop and some metadata. Please refer to [BOLT 04][bolt04] for further details. If is specific to the route that is being used and the *payment_hash* used to construct, and therefore cannot be reused for other payments or to attempt a separate route. The custom onion can generally be created using the `devtools/onion` CLI tool, or the **createonion** RPC command."
]
},
"first_hop": {
"type": "object",
"description": [
"Instructs Core Lightning which peer to send the onion to. It is a JSON dictionary that corresponds to the first element of the route array returned by *getroute* (so fields not mentioned here are ignored)."
],
"required": [
"id",
"amount_msat",
"delay"
],
"additionalProperties": true,
"properties": {
"id": {
"type": "pubkey",
"description": [
"Node id for the peer. Use any available channel available to this peer."
]
},
"amount_msat": {
"type": "msat",
"description": [
"The amount to add an HTLC for millisatoshis."
]
},
"delay": {
"type": "u16",
"description": [
"The number of blocks delay of blocks on top of the current blockheight."
]
}
}
},
"payment_hash": {
"type": "hash",
"description": [
"Specifies the 32 byte hex-encoded hash to use as a challenge to the HTLC that we are sending. It is specific to the onion and has to match the one the onion was created with."
]
},
"label": {
"type": "string",
"description": [
"Can be used to provide a human readable reference to retrieve the payment at a later time."
]
},
"shared_secrets": {
"type": "array",
"description": [
"A JSON list of 32 byte hex-encoded secrets that were used when creating the onion. Core Lightning can send a payment with a custom onion without the knowledge of these secrets, however it will not be able to parse an eventual error message since that is encrypted with the shared secrets used in the onion. If *shared_secrets* is provided Core Lightning will decrypt the error, act accordingly, e.g., add a `channel_update` included in the error to its network view, and set the details in *listsendpays* correctly. If it is not provided Core Lightning will store the encrypted onion, and expose it in *listsendpays* allowing the caller to decrypt it externally. If it is not provided the Core Lightning node does not know how long the route is, which channels or nodes are involved, and what an eventual error could have been. It can therefore be used for oblivious payments."
],
"items": {
"type": "secret"
}
},
"partid": {
"type": "u16",
"description": [
"If provided and non-zero, allows for multiple parallel partial payments with the same *payment_hash*."
]
},
"bolt11": {
"type": "string",
"description": [
"If provided, it will be returned in *waitsendpay* and *listsendpays* results."
]
},
"amount_msat": {
"type": "msat",
"description": [
"Used to annotate the payment, and is returned by *waitsendpay* and *listsendpays*."
]
},
"destination": {
"type": "pubkey",
"description": [
"If provided, it will be returned in **listpays** result."
]
},
"localinvreqid": {
"type": "hash",
"description": [
"`localinvreqid` is used by offers to link a payment attempt to a local `invoice_request` offer created by lightningd-invoicerequest(7)."
]
},
"groupid": {
"type": "u64",
"description": [
"Grouping key to disambiguate multiple attempts to pay an invoice or the same payment_hash."
]
},
"description": {
"added": "v0.11.0",
"type": "string",
"description": [
"If provided, it will be returned in *waitsendpay* and *listsendpays* results."
]
}
}
},
"response": {
"required": [
"created_index",
"id",
"payment_hash",
"status",
"created_at",
"amount_sent_msat"
],
"additionalProperties": true,
"properties": {
"created_index": {
"added": "v23.11",
"type": "u64",
"description": [
"1-based index indicating order this payment was created in."
]
},
"id": {
"type": "u64",
"description": [
"Old synonym for created_index."
]
},
"payment_hash": {
"type": "hash",
"description": [
"The hash of the *payment_preimage* which will prove payment."
]
},
"status": {
"type": "string",
"enum": [
"pending",
"complete"
],
"description": [
"Status of the payment (could be complete if already sent previously)."
]
},
"amount_msat": {
"type": "msat",
"description": [
"The amount delivered to destination (if known)."
]
},
"destination": {
"type": "pubkey",
"description": [
"The final destination of the payment if known."
]
},
"created_at": {
"type": "u64",
"description": [
"The UNIX timestamp showing when this payment was initiated."
]
},
"amount_sent_msat": {
"type": "msat",
"description": [
"The amount sent."
]
},
"label": {
"type": "string",
"description": [
"The label, if given to sendpay."
]
},
"bolt11": {
"type": "string",
"description": [
"The bolt11 string (if supplied)."
]
},
"bolt12": {
"type": "string",
"description": [
"The bolt12 string (if supplied: **experimental-offers** only)."
]
},
"partid": {
"type": "u64",
"description": [
"The partid (if supplied) to sendonion/sendpay."
]
}
},
"allOf": [
{
"if": {
"additionalProperties": true,
"properties": {
"status": {
"type": "string",
"enum": [
"complete"
]
}
}
},
"then": {
"additionalProperties": false,
"required": [
"payment_preimage"
],
"properties": {
"created_index": {},
"id": {},
"payment_hash": {},
"status": {},
"msatoshi": {},
"amount_msat": {},
"destination": {},
"created_at": {},
"groupid": {},
"msatoshi_sent": {},
"amount_sent_msat": {},
"label": {},
"bolt11": {},
"bolt12": {},
"partid": {},
"updated_index": {
"added": "v23.11",
"type": "u64",
"description": [
"1-based index indicating order this payment was changed."
]
},
"payment_preimage": {
"type": "secret",
"description": [
"The proof of payment: SHA256 of this **payment_hash**."
]
}
}
}
},
{
"if": {
"additionalProperties": true,
"properties": {
"status": {
"type": "string",
"enum": [
"pending"
]
}
}
},
"then": {
"additionalProperties": false,
"required": [],
"properties": {
"created_index": {},
"id": {},
"payment_hash": {},
"status": {},
"msatoshi": {},
"amount_msat": {},
"destination": {},
"created_at": {},
"groupid": {},
"msatoshi_sent": {},
"amount_sent_msat": {},
"label": {},
"bolt11": {},
"bolt12": {},
"partid": {},
"message": {
"type": "string",
"description": [
"Monitor status with listpays or waitsendpay."
]
}
}
}
}
]
},
"errors": [
"The following error codes may occur:",
"",
"- 202: an parseable onion",
"",
"the error details are decrypted and presented here, if *shared_secrets* was provided and an error was returned by one of the intermediate nodes"
],
"author": [
"Christian Decker <<decker.christian@gmail.com>> is mainly responsible."
],
"see_also": [
"lightning-createonion(7)",
"lightning-sendpay(7)",
"lightning-listsendpays(7)"
],
"resources": [
"Main web site: <https://github.com/ElementsProject/lightning>",
"",
"[bolt04]: https://github.com/lightning/bolts/blob/master/04-onion-routing.md"
],
"examples": [
{
"request": {
"id": "example:sendonion#1",
"method": "sendonion",
"params": {
"onion": "0003ccc1f8876af4810e23bd4cccd8f2f38ee5dc117f527c783fefa4e632f857c98d588d2e3150d16b78f9458777502e4829b490e8a2d560841eb0c2368311bf9bb4e8ded0356badafd915839409ad60866c24dd7580b468c14097575565ca95425b9f44211d9ad0305ddba2391a70892ac8c9fd7c3b67d0fe22faf5a0b6905ee2e22278fe224e89ea72c3fcc598b35afaa255123e61ae7a697703e3bb8aec4d36ea487df6ec27942aadff0527d178c897e75f1ee284995196b5ead963ee9d0df798c8265c00c5c73daac917d298cc17e5d813189321d914c45ef30170c4d617dae12bb3a760d1665705e61bb6c52789e15623cefc68d96b86a6f17159c4a86bb196c9f5e40a0744d08d6da0cfd587717b6d0d074d42ac0893fa6ae1497c84824f1d27670d4e201af5e9e5a3493b603cfc209bb0ee41b573ca647c5b9882272c972cd18f19fd895e8995097d86882a473f4d26118a7ed656c5ea04c2a183b05cc0191d07fab5e78edab4ab8ec58e05e03f32d150449c0c8e3505e46ae58e77c87616144873f72f4571b00ccf8e71bcdf33a7d32345aecb660970fa73c4844ab157aa322f140f5d47b66a0590273728ddb5b8a7f3577cff5a268935b93fe598d6df4413c67c45efa9461abaf3294070a484418aa28c03ac20d08856eb0c74dfca851e8ed110bdcacb2a2fb90954b04e99986fde0678846a709120b5d1eeab9cde8d9f27d77448f4591e00bf30d7580703e6c189c658746cf7a7cc1430ce41f84244612b438c3d895333848e5f55e99b2a9d28860863c11aaa8e3ef01ead7ba1545156c356424c33aeeaa2f1e2c290d1d8dd52cd7b8116159025aba26db6fb81ad7f9cc4554c6f9f13d16defe38918b32d62a0516521934a0009a8d37c9a84689bfd8fc1f0beceb92701dca11175e0099d7541698956ba5d93efff996f538ee47717ae6c5cda98111bc28c822e99cf8957b707de270f447b6e52d30bcf9b8a9befd8663bc54612b543d0e167da67e2f295207b70857d0a7cae8932d905db2f48c873dec20aeafa07e15fa98a088e529424c8b404f03ba0ee78a6639fde5cd37dee42877ff6489ce1de5a8992cae25dd20a6521955c19129fdcc0ea157913373bf47a8018a1dd825a2f8e26194d5008161360ae9b25fc701b2accbe88eb47eee6a50b7ee6d6e169e3905e03ca72e00eb6a51b7ed3d27501715428368662b822e2262749d3e7d3243c4fd3d825b3e72bebdeebf6e035f1ad6634523ab5dc0335611c19c9936d006f2e4cd8818eb4f8b4857c8f35d18a4891e35ff91e3b54b384398574d673fcc8da50b22b8f485a41223c97e3b8ee5b8e5ff9c00a2cbfe7360509d3fee9248b5eaa81bb83da3be45dfa8cbbbf5c52ba8749c9d6261d4239feea1e7ce85ad40ad0c66bbeb1c6898626ae4e710a66f9c39a5ee94581353b46e070cfcff9a14e3f9a6108d55bb92852eb3a50e89b1e45d31b760f2a4e263a6a876ad638b123ffee7a2b0b48e16175e3eb92bfaad4dbe0af8b2bc1c15fec5a9d92d3970c2ffab2ab8fa2c9de0bd276680a4284707cd8543a97bca2394e9514236129f1c50a932f7e9bfb98c2aaa6ffc9a4a30641061246de6edf0f711a8d25d59af42ee4445b22ce2f832f3ece52c18ca62d90c590729e04c47accaec95b556ee2541c84843c54a116f5cc45bc251a8023b695f0bf79c43a97bece8a761d387a466821984fb5ec438af20d14cebb7f0026988c81b5a1b895ef94df61aa509e53083b4306c42132b5ce302fd5a2fbb1cee30a7078ccaa3bdccf781b8c9d6ae016a5f8e5cb13f7ac1f3fd0d74a182c9abea67d346f0dfcfc211aaa7ff47196465398fce3e6e0f3b73a944a7f57a90cc6a8f1bfcd385f8312e23af6f508f4f8a976d750660ac3d63630555a3a2e7fe158a982aaf0278d9f8819e5cb",
"first_hop": {
"id": "022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59",
"channel": "109x1x1",
"direction": 1,
"amount_msat": 1002,
"delay": 21,
"style": "tlv"
},
"payment_hash": "e445ebcf339db3cba6184330ccc6e4a41e0bb38d237b93c1d2f71958d5a74e13"
}
},
"response": {
"message": "Monitor status with listpays or waitsendpay",
"created_index": 8,
"id": 8,
"payment_hash": "e445ebcf339db3cba6184330ccc6e4a41e0bb38d237b93c1d2f71958d5a74e13",
"groupid": 1,
"amount_sent_msat": 1002,
"created_at": 1722303689,
"status": "pending"
}
}
]
}