Skip to content

Commit 5776d2a

Browse files
committed
BOLT 11: Add payment_secret field (compulsory for new invoices).
We also define what the basic_mpp feature means in an invoice, by reference to the next commit. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent b2a3c2f commit 5776d2a

File tree

1 file changed

+52
-15
lines changed

1 file changed

+52
-15
lines changed

11-payment-encoding.md

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ Each Tagged Field is of the form:
129129
Currently defined tagged fields are:
130130

131131
* `p` (1): `data_length` 52. 256-bit SHA256 payment_hash. Preimage of this provides proof of payment.
132+
* `s` (16): `data_length` 52. This 256-bit secret prevents forwarding nodes from probing the payment recipient.
132133
* `d` (13): `data_length` variable. Short description of purpose of payment (UTF-8), e.g. '1 cup of coffee' or 'ナンセンス 1杯'
133134
* `n` (19): `data_length` 53. 33-byte public key of the payee node
134135
* `h` (23): `data_length` 52. 256-bit description of purpose of payment (SHA256). This is used to commit to an associated description that is over 639 bytes, but the transport mechanism for the description in that case is transport specific and not defined here.
@@ -148,7 +149,7 @@ Currently defined tagged fields are:
148149
### Requirements
149150

150151
A writer:
151-
- MUST include exactly one `p` field.
152+
- MUST include exactly one `p` and `s` fields.
152153
- MUST set `payment_hash` to the SHA2 256-bit hash of the `payment_preimage`
153154
that will be given in return for payment.
154155
- MUST include either exactly one `d` or exactly one `h` field.
@@ -191,8 +192,8 @@ A writer:
191192
- MUST specify the most-preferred field first, followed by less-preferred fields, in order.
192193

193194
A reader:
194-
- MUST skip over unknown fields, OR an `f` field with unknown `version`, OR `p`, `h`, or
195-
`n` fields that do NOT have `data_length`s of 52, 52, or 53, respectively.
195+
- MUST skip over unknown fields, OR an `f` field with unknown `version`, OR `p`, `h`, `s` or
196+
`n` fields that do NOT have `data_length`s of 52, 52, 52 or 53, respectively.
196197
- if the `9` field contains unknown _odd_ bits that are non-zero:
197198
- MUST ignore the bit.
198199
- if the `9` field contains unknown _even_ bits that are non-zero:
@@ -202,6 +203,8 @@ A reader:
202203
description.
203204
- if a valid `n` field is provided:
204205
- MUST use the `n` field to validate the signature instead of performing signature recovery.
206+
- if there is a valid `s` field:
207+
- MUST use that as [`payment_secret`](04-onion-routing.md#tlv_payload-payload-format)
205208

206209
### Rationale
207210

@@ -279,6 +282,34 @@ The field is big-endian. The least-significant bit is numbered 0,
279282
which is _even_, and the next most significant bit is numbered 1,
280283
which is _odd_.
281284

285+
Note that the `payment_secret` feature probing attacks from nodes
286+
along the path, but only if made compulsory: yet doing so will break
287+
older clients which do not understand the feature.
288+
289+
### Requirements
290+
291+
A writer:
292+
- if `payment_secret` feature is set:
293+
- MUST include an `s` field.
294+
- otherwise:
295+
- MUST NOT include an `s` field.
296+
- if the `payment_secret` field is required in the onion:
297+
- MUST set the even feature `payment_secret`.
298+
- If the final node supports [Basic multi-part payments](04-onion-routing.md#basic-multi-part-payments):
299+
- MUST set the `basic_mpp` feature.
300+
- Otherwise:
301+
- MUST NOT set the `basic_mpp` feature.
302+
- if it sets either `payment_secret` or `basic_mpp` features:
303+
- MUST set the `var_onion_optin` feature.
304+
- MUST set `var_onion_optin` if and only if it supports that feature.
305+
306+
A reader:
307+
- if the `basic_mpp` feature is offered in the invoice:
308+
- MAY pay using [Basic multi-part payments](04-onion-routing.md#basic-multi-part-payments).
309+
- otherwise:
310+
- MUST NOT use [Basic multi-part payments](04-onion-routing.md#basic-multi-part-payments).
311+
312+
282313
# Payer / Payee Interactions
283314

284315
These are generally defined by the rest of the Lightning BOLT series,
@@ -318,7 +349,7 @@ https://github.com/rustyrussell/lightning-payencode
318349

319350
# Examples
320351

321-
NB: all the following examples are signed with `priv_key`=`e126f68f7eafcc8b74f54d269fe206be715000f94dac067d1c04a8ca3b2db734`.
352+
NB: all the following examples are signed with `priv_key`=`e126f68f7eafcc8b74f54d269fe206be715000f94dac067d1c04a8ca3b2db734`. Also, the first 9 examples are legacy: modern invoices have an `s` field.
322353

323354
> ### Please make a donation of any amount using payment_hash 0001020304050607080900010203040506070809000102030405060708090102 to me @03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad
324355
> lnbc1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaq8rkx3yf5tcsyz3d73gafnh3cax9rn449d9p5uxz9ezhhypd0elx87sjle52x86fux2ypatgddc6k63n7erqz25le42c4u4ecky03ylcqca784w
@@ -535,8 +566,8 @@ Breakdown:
535566
* `6c6e626332306d0b25fe64570d0e496dbd9f8b0d000dbb44824f751380da37c6dba89b14f6f92047d63f576e304021a00008101820283038404800081018202830384048000810182028303840480810243500c318a1e0a628b34025e8c9019ab6d09b64c2b3c66a693d0dc63194b02481931000` hex of data for signing (prefix + data after separator up to the start of the signature)
536567
* `399a8b167029fda8564fd2e99912236b0b8017e7d17e416ae17307812c92cf42` hex of SHA256 of the preimage
537568

538-
> ### Please send $30 for coffee beans to the same peer, which supports features 1 and 9
539-
> lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdees9qzsze992adudgku8p05pstl6zh7av6rx2f297pv89gu5q93a0hf3g7lynl3xq56t23dpvah6u7y9qey9lccrdml3gaqwc6nxsl5ktzm464sq73t7cl
569+
> ### Please send $30 for coffee beans to the same peer, which supports features 15 and 99, using secret 0x1111111111111111111111111111111111111111111111111111111111111111
570+
> lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q5sqqqqqqqqqqqqqqqpqqq4u9s93jtgysm3mrwll70zr697y3mf902hvxwej0v7c62rsltw83ng0pu8w3j230sluc5gxkdmm9dvpy9y6ggtjd2w544mzdrcs42t7sqdkcy8h
540571
541572
Breakdown:
542573

@@ -548,14 +579,17 @@ Breakdown:
548579
* `d`: short description
549580
* `q5`: `data_length` (`q` = 0, `5` = 20; 0 * 32 + 20 == 20)
550581
* `vdhkven9v5sxyetpdees`: 'coffee beans'
582+
* `s`: payment secret
583+
* `p5`: `data_length` (`p` = 1, `5` = 20; 1 * 32 + 20 == 52)
584+
* `zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs`: 0x1111111111111111111111111111111111111111111111111111111111111111
551585
* `9`: features
552-
* `qz`: `data_length` (`q` = 0, `z` = 2; 0 * 32 + 2 == 2)
553-
* `sz`: b1000000010
554-
* `e992adudgku8p05pstl6zh7av6rx2f297pv89gu5q93a0hf3g7lynl3xq56t23dpvah6u7y9qey9lccrdml3gaqwc6nxsl5ktzm464sq`: signature
555-
* `73t7cl`: Bech32 checksum
586+
* `q5`: `data_length` (`q` = 0, `5` = 20; 0 * 32 + 20 == 20) 4
587+
* `sqqqqqqqqqqqqqqqpqqq`: b1000....00001000000000000000
588+
* `pqqq4u9s93jtgysm3mrwll70zr697y3mf902hvxwej0v7c62rsltw83ng0pu8w3j230sluc5gxkdmm9dvpy9y6ggtjd2w544mzdrcs42t7sq`: signature
589+
* `dkcy8h`: Bech32 checksum
556590

557-
> # Same, but using invalid unknown feature 100
558-
> lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdees9q4pqqqqqqqqqqqqqqqqqqszk3ed62snp73037h4py4gry05eltlp0uezm2w9ajnerhmxzhzhsu40g9mgyx5v3ad4aqwkmvyftzk4k9zenz90mhjcy9hcevc7r3lx2sphzfxz7
591+
> # Same, but adding invalid unknown feature 100
592+
> lnbc25m1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5vdhkven9v5sxyetpdeessp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs9q4psqqqqqqqqqqqqqqqpqqqqu7fz6pjqczdm3jp3qps7xntj2w2mm70e0ckhw3c5xk9p36pvk3sewn7ncaex6uzfq0vtqzy28se6pcwn790vxex7xystzumhg55p6qq9wq7td
559593
560594
Breakdown:
561595

@@ -567,11 +601,14 @@ Breakdown:
567601
* `d`: short description
568602
* `q5`: `data_length` (`q` = 0, `5` = 20; 0 * 32 + 20 == 20)
569603
* `vdhkven9v5sxyetpdees`: 'coffee beans'
604+
* `s`: payment secret
605+
* `p5`: `data_length` (`p` = 1, `5` = 20; 1 * 32 + 20 == 52)
606+
* `zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygs`: 0x1111111111111111111111111111111111111111111111111111111111111111
570607
* `9`: features
571608
* `q4`: `data_length` (`q` = 0, `4` = 21; 0 * 32 + 21 == 21)
572-
* `pqqqqqqqqqqqqqqqqqqsz`: b00001...(90 zeroes)...1000000010
573-
* `k3ed62snp73037h4py4gry05eltlp0uezm2w9ajnerhmxzhzhsu40g9mgyx5v3ad4aqwkmvyftzk4k9zenz90mhjcy9hcevc7r3lx2sp`: signature
574-
* `hzfxz7`: Bech32 checksum
609+
* `psqqqqqqqqqqqqqqqpqqqq`: b000011000....00001000000000000000
610+
* `u7fz6pjqczdm3jp3qps7xntj2w2mm70e0ckhw3c5xk9p36pvk3sewn7ncaex6uzfq0vtqzy28se6pcwn790vxex7xystzumhg55p6qq`: signature
611+
* `9wq7td`: Bech32 checksum
575612

576613
# Authors
577614

0 commit comments

Comments
 (0)