forked from ElementsProject/lightning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlightning-pay.json
281 lines (281 loc) · 11.4 KB
/
lightning-pay.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
{
"$schema": "../rpc-schema-draft.json",
"type": "object",
"rpc": "pay",
"title": "Command for sending a payment to a BOLT11 invoice",
"description": [
"The **pay** RPC command attempts to find a route to the given destination, and send the funds it asks for. .",
"",
"The response will occur when the payment fails or succeeds. Once a payment has succeeded, calls to **pay** with the same *bolt11* will succeed immediately.",
"",
"When using *lightning-cli*, you may skip optional parameters by using *null*. Alternatively, use **-k** option to provide parameters by name."
],
"request": {
"required": [
"bolt11"
],
"additionalProperties": false,
"properties": {
"bolt11": {
"type": "string",
"description": [
"Bolt11 or bolt12 invoice (such as one received from lightningd-fetchinvoice(7)). For a bolt11 invoice, if it does not contain an amount, *amount_msat* is required, otherwise if it is specified it must be *null*."
]
},
"amount_msat": {
"type": "msat",
"description": [
"*amount_msat* is in millisatoshi precision; it can be a whole number, or a whole number with suffix *msat* or *sat*, or a three decimal point number with suffix *sat*, or an 1 to 11 decimal point number suffixed by *btc*."
]
},
"label": {
"type": "string",
"description": [
"It is used to attach a label to payments, and is returned in lightning- listpays(7) and lightning-listsendpays(7)."
]
},
"riskfactor": {
"type": "number",
"description": [
"The *riskfactor* is described in detail in lightning-getroute(7)."
],
"default": "10"
},
"maxfeepercent": {
"type": "number",
"description": [
"Percentage of the amount that is to be paid."
],
"default": "0.5"
},
"retry_for": {
"type": "u16",
"description": [
"Until *retry_for* seconds passes, the command will keep finding routes and retrying the payment."
],
"default": "60 seconds"
},
"maxdelay": {
"type": "u16",
"description": [
"A payment may be delayed for up to `maxdelay` blocks by another node; clients should be prepared for this worst case."
]
},
"exemptfee": {
"type": "msat",
"description": [
"This option can be used for tiny payments which would be dominated by the fee leveraged by forwarding nodes. Setting `exemptfee` allows the `maxfeepercent` check to be skipped on fees that are smaller than `exemptfee`."
],
"default": "5000 millisatoshi"
},
"localinvreqid": {
"type": "hex",
"description": [
"`localinvreqid` is used by offers to link a payment attempt to a local `invoice_request` offer created by lightningd-invoicerequest(7). This ensures that we only make a single payment for an offer, and that the offer is marked `used` once paid."
]
},
"exclude": {
"type": "array",
"description": [
"*exclude* is a JSON array of short-channel-id/direction (e.g. [ '564334x877x1/0', '564195x1292x0/1' ]) or pubkey which should be excluded from consideration for routing."
],
"default": "not to exclude any channels or nodes",
"items": {
"oneOf": [
{
"type": "short_channel_id_dir"
},
{
"type": "pubkey"
}
]
}
},
"maxfee": {
"type": "msat",
"description": [
"*maxfee* overrides both *maxfeepercent* and *exemptfee* defaults (and if you specify *maxfee* you cannot specify either of those), and creates an absolute limit on what fee we will pay. This allows you to implement your own heuristics rather than the primitive ones used here."
]
},
"description": {
"type": "string",
"description": [
"It is only required for bolt11 invoices which do not contain a description themselves, but contain a description hash: in this case *description* is required. *description* is then checked against the hash inside the invoice before it will be paid."
]
},
"partial_msat": {
"type": "msat",
"added": "v23.05",
"description": [
"Explicitly state that you are only paying some part of the invoice. Presumably someone else is paying the rest (otherwise the payment will time out at the recipient). Note that this is currently not supported for self-payment (please file an issue if you need this)"
]
}
}
},
"response": {
"required": [
"payment_preimage",
"payment_hash",
"created_at",
"parts",
"amount_msat",
"amount_sent_msat",
"status"
],
"additionalProperties": false,
"properties": {
"payment_preimage": {
"type": "secret",
"description": [
"The proof of payment: SHA256 of this **payment_hash**."
]
},
"destination": {
"type": "pubkey",
"description": [
"The final destination of the payment."
]
},
"payment_hash": {
"type": "hash",
"description": [
"The hash of the *payment_preimage* which will prove payment."
]
},
"created_at": {
"type": "number",
"description": [
"The UNIX timestamp showing when this payment was initiated."
]
},
"parts": {
"type": "u32",
"description": [
"How many attempts this took."
]
},
"amount_msat": {
"type": "msat",
"description": [
"Amount the recipient received."
]
},
"amount_sent_msat": {
"type": "msat",
"description": [
"Total amount we sent (including fees)."
]
},
"warning_partial_completion": {
"type": "string",
"description": [
"Not all parts of a multi-part payment have completed."
]
},
"status": {
"type": "string",
"enum": [
"complete",
"pending",
"failed"
],
"description": [
"Status of payment."
]
}
},
"post_return_value_notes": [
"You can monitor the progress and retries of a payment using the lightning-paystatus(7) command."
]
},
"randomization": [
"To protect user privacy, the payment algorithm performs some randomization.",
"",
"1: Route Randomization",
"",
"Route randomization means the payment algorithm does not always use the lowest-fee or shortest route. This prevents some highly-connected node from learning all of the user payments by reducing their fees below the network average.",
"",
"2: Shadow Route",
"",
"Shadow route means the payment algorithm will virtually extend the route by adding delays and fees along it, making it appear to intermediate nodes that the route is longer than it actually is. This prevents intermediate nodes from reliably guessing their distance from the payee.",
"",
"Route randomization will never exceed *maxfeepercent* of the payment. Route randomization and shadow routing will not take routes that would exceed *maxdelay*."
],
"errors": [
"The following error codes may occur:",
"",
"- -1: Catchall nonspecific error.",
"- 201: Already paid with this *hash* using different amount or destination.",
"- 203: Permanent failure at destination. The *data* field of the error will be routing failure object (except for self-payment, which currently returns the error directly from lightning-sendpay(7)).",
"- 205: Unable to find a route.",
"- 206: Route too expensive. Either the fee or the needed total locktime for the route exceeds your *maxfeepercent* or *maxdelay* settings, respectively. The *data* field of the error will indicate the actual *fee* as well as the *feepercent* percentage that the fee has of the destination payment amount. It will also indicate the actual *delay* along the route.",
"- 207: Invoice expired. Payment took too long before expiration, or already expired at the time you initiated payment. The *data* field of the error indicates *now* (the current time) and *expiry* (the invoice expiration) as UNIX epoch time in seconds.",
"- 210: Payment timed out without a payment in progress.",
"",
"Error codes 202 and 204 will only get reported at **sendpay**; in **pay** we will keep retrying if we would have gotten those errors.",
"",
"A routing failure object has the fields below:",
"",
"*erring_index*: The index of the node along the route that reported the error. 0 for the local node, 1 for the first hop, and so on.",
"*erring_node*: The hex string of the pubkey id of the node that reported the error.",
"*erring_channel*: The short channel ID of the channel that has the error, or *0:0:0* if the destination node raised the error.",
"*failcode*: The failure code, as per BOLT #4.",
"*channel_update*: The hex string of the *channel_update* message received from the remote node. Only present if error is from the remote node and the *failcode* has the UPDATE bit set, as per BOLT #4.",
"",
"The *data* field of errors will include statistics *getroute_tries* and *sendpay_tries*. It will also contain a *failures* field with detailed data about routing errors."
],
"author": [
"Rusty Russell <<[email protected]>> is mainly responsible."
],
"see_also": [
"lightning-listpays(7)",
"lightning-decodepay(7)",
"lightning-listinvoices(7)",
"lightning-delinvoice(7)",
"lightning-getroute(7)",
"lightning-invoice(7)"
],
"resources": [
"Main web site: <https://github.com/ElementsProject/lightning>"
],
"examples": [
{
"request": {
"id": "example:pay#1",
"method": "pay",
"params": [
"lnbcrt100n1pnt2bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000bolt11invl032000000000"
]
},
"response": {
"destination": "nodeid030303030303030303030303030303030303030303030303030303030303",
"payment_hash": "paymenthashinvl0320032003200320032003200320032003200320032003200",
"created_at": 1738000000,
"parts": 1,
"amount_msat": 50000,
"amount_sent_msat": 50001,
"payment_preimage": "paymentpreimagep010101010101010101010101010101010101010101010101",
"status": "complete"
}
},
{
"request": {
"id": "example:pay#2",
"method": "pay",
"params": {
"bolt11": "lnbcrt100n1pnt2bolt11invl030300000000bolt11invl030300000000bolt11invl030300000000bolt11invl030300000000bolt11invl030300000000bolt11invl030300000000bolt11invl030300000000bolt11invl030300000000bolt11invl030300000000bolt11invl030300000000"
}
},
"response": {
"destination": "nodeid030303030303030303030303030303030303030303030303030303030303",
"payment_hash": "paymenthashinvl0330033003300330033003300330033003300330033003300",
"created_at": 1738000000,
"parts": 1,
"amount_msat": 100000,
"amount_sent_msat": 100000,
"payment_preimage": "paymentpreimagep020202020202020202020202020202020202020202020202",
"status": "complete"
}
}
]
}