@@ -250,18 +250,111 @@ This is a more flexible format, which avoids the redundant `short_channel_id` fi
250250 1 . type: 6 (` short_channel_id ` )
251251 2 . data:
252252 * [ ` short_channel_id ` :` short_channel_id ` ]
253+ 1 . type: 8 (` payment_data ` )
254+ 2 . data:
255+ * [ ` 32*byte ` :` payment_secret ` ]
256+ * [ ` tu64 ` :` total_msat ` ]
253257
254258### Requirements
255259
256260The writer:
257- - MUST include ` amt_to_forward ` and ` outgoing_cltv_value ` for every node.
258- - MUST include ` short_channel_id ` for every non-final node.
259- - MUST NOT include ` short_channel_id ` for the final node.
261+ - Unless ` node_announcement ` , ` init ` message or the [ BOLT #11 ] ( 11-payment-encoding.md#tagged-fields ) offers feature ` var_onion_optin ` :
262+ - MUST use the legacy payload format instead.
263+ - For every node:
264+ - MUST include ` amt_to_forward ` and ` outgoing_cltv_value ` .
265+ - For every non-final node:
266+ - MUST include ` short_channel_id `
267+ - MUST NOT include `payment_data`
268+ - For the final node:
269+ - MUST NOT include ` short_channel_id `
270+ - if the recipient provided ` payment_secret ` :
271+ - MUST include ` payment_data `
272+ - MUST set `payment_secret` to the one provided
273+ - MUST set `total_msat` to the total amount it will send
260274
261275The reader:
262276 - MUST return an error if ` amt_to_forward ` or ` outgoing_cltv_value ` are not present.
277+ - if it is the final node:
278+ - MUST treat ` total_msat ` as if it were equal to ` amt_to_forward ` if it
279+ is not present.
280+
281+ The requirements for the contents of these fields are specified [ above] ( #legacy-hop_data-payload-format )
282+ and [ below] ( #basic-multi-part-payments ) .
283+
284+ ### Basic Multi-Part Payments
285+
286+ An HTLC may be part of a larger "multi-part" payment: such
287+ "base" atomic multipath payments will use the same ` payment_hash ` for
288+ all paths.
289+
290+ Note that ` amt_to_forward ` is the amount for this HTLC only: a
291+ ` total_msat ` field containing a greater value is a promise by the
292+ ultimate sender that the rest of the payment will follow in succeeding
293+ HTLCs; we call these outstanding HTLCs which have the same preimage,
294+ an "HTLC set".
295+
296+ #### Requirements
263297
264- The requirements for the contents of these fields are specified [ above] ( #legacy-hop_data-payload-format ) .
298+ The writer:
299+ - if the invoice offers the ` basic_mpp ` feature:
300+ - MAY send more than one HTLC to pay the invoice.
301+ - MUST use the same ` payment_hash ` on all HTLCs in the set.
302+ - SHOULD send all payments at approximately the same time.
303+ - SHOULD try to use diverse paths to the recipient for each HTLC.
304+ - SHOULD retry and/or re-divide HTLCs which fail.
305+ - if the invoice specifies an ` amount ` :
306+ - MUST set ` total_msat ` to at least that ` amount ` , and less
307+ than or equal to twice ` amount ` .
308+ - otherwise:
309+ - MUST set ` total_msat ` to the amount it wishes to pay.
310+ - MUST ensure that the total ` amount_msat ` of the HTLC set which arrives at the payee
311+ is equal to ` total_msat ` .
312+ - MUST NOT send another HTLC if the total ` amount_msat ` of the HTLC set is already greater or equal to ` total_msat ` .
313+ - otherwise:
314+ - MUST set ` total_msat ` equal to ` amt_to_forward ` .
315+
316+ The final node:
317+ - MUST fail the HTLC if dictated by Requirements under [ Failure Messages] ( #failure-messages )
318+ - Note: "amount paid" specified there is the ` total_msat ` field.
319+ - if it does not support ` basic_mpp ` :
320+ - MUST fail the HTLC if ` total_msat ` is not exactly equal to ` amt_to_forward ` .
321+ - otherwise, if it supports ` basic_mpp ` :
322+ - MUST add it to the HTLC set corresponding to that ` payment_hash ` .
323+ - SHOULD fail the entire HTLC set if ` total_msat ` is not the same for
324+ all HTLCs in the set.
325+ - if the total ` amount_msat ` of this HTLC set equals ` total_msat ` :
326+ - SHOULD fulfill all HTLCs in the HTLC set
327+ - otherwise, if the total ` amount_msat ` of this HTLC set is less than
328+ `total_msat`:
329+ - MUST NOT fulfill any HTLCs in the HTLC set
330+ - MUST fail all HTLCs in the HTLC set after some reasonable timeout.
331+ - SHOULD wait for at least 60 seconds after the initial HTLC.
332+ - SHOULD use `mpp_timeout` for the failure message.
333+ - if it fulfills any HTLCs in the HTLC set:
334+ - MUST fulfill the entire HTLC set.
335+
336+ #### Rationale
337+
338+ If ` basic_mpp ` is present it causes a delay to allow other partial
339+ payments to combine. The total amount must be sufficient for the
340+ desired payment, just as it must be for single payments. But this must
341+ be reasonably bounded to avoid a denial-of-service.
342+
343+ Because invoices do not necessarily specify an amount, and because
344+ payers can add noise to the final amount, the total amount must be
345+ sent explicitly. The requirements allow exceeding this slightly, as
346+ it simplifies adding noise to the amount when splitting, as well as
347+ scenarios in which the senders are genuinely independent (friends
348+ splitting a bill, for example).
349+
350+ The restriction on sending an HTLC once the set is over the agreed total prevents the preimage being released before all
351+ the partial payments have arrived: that would allow any intermediate
352+ node to immediately claim any outstanding partial payments.
353+
354+ An implementation may choose not to fulfill an HTLC set which
355+ otherwise meets the amount criterion (eg. some other failure, or
356+ invoice timeout), however if it were to fulfill only some of them,
357+ intermediary nodes could simply claim the remaining ones.
265358
266359# Accepting and Forwarding a Payment
267360
@@ -315,6 +408,8 @@ using an alternate channel.
315408When building the route, the origin node MUST use a payload for
316409the final node with the following values:
317410
411+ * ` payment_secret ` : set to the payment secret specified by the recipient (e.g.
412+ ` payment_secret ` from a [ BOLT #11 ] ( 11-payment-encoding.md ) payment invoice)
318413* ` outgoing_cltv_value ` : set to the final expiry specified by the recipient (e.g.
319414 ` min_final_cltv_expiry ` from a [ BOLT #11 ] ( 11-payment-encoding.md ) payment invoice)
320415* ` amt_to_forward ` : set to the final amount specified by the recipient (e.g. ` amount `
@@ -829,9 +924,10 @@ handling by the processing node.
829924 * [ ` u64 ` :` htlc_msat ` ]
830925 * [ ` u32 ` :` height ` ]
831926
832- The ` payment_hash ` is unknown to the final node, the amount for that
833- ` payment_hash ` is incorrect or the CLTV expiry of the htlc is too close to the
834- current block height for safe handling.
927+ The ` payment_hash ` is unknown to the final node, the ` payment_secret ` doesn't
928+ match the ` payment_hash ` , the amount for that ` payment_hash ` is incorrect or
929+ the CLTV expiry of the htlc is too close to the current block height for safe
930+ handling.
835931
836932The ` htlc_msat ` parameter is superfluous, but left in for backwards
837933compatibility. The value of ` htlc_msat ` always matches the amount specified in
@@ -887,6 +983,11 @@ or is incomplete. If the failure can be narrowed down to a specific tlv type in
887983the payload, the erring node may include that ` type ` and its byte ` offset ` in
888984the decrypted byte stream.
889985
986+ 1 . type: 23 (` mpp_timeout ` )
987+
988+ The complete amount of the multi-part payment was not received within a
989+ reasonable time.
990+
890991### Requirements
891992
892993An _ erring node_ :
@@ -954,6 +1055,10 @@ An _intermediate hop_ MUST NOT, but the _final node_:
9541055 - if the payment hash has already been paid:
9551056 - MAY treat the payment hash as unknown.
9561057 - MAY succeed in accepting the HTLC.
1058+ - if the ` payment_secret ` doesn't match the expected value for that ` payment_hash ` ,
1059+ or the ` payment_secret ` is required and is not present:
1060+ - MUST fail the HTLC.
1061+ - MUST return an ` incorrect_or_unknown_payment_details ` error.
9571062 - if the amount paid is less than the amount expected:
9581063 - MUST fail the HTLC.
9591064 - MUST return an ` incorrect_or_unknown_payment_details ` error.
0 commit comments