1
0
mirror of https://github.com/lightning/bolts.git synced 2024-11-19 10:00:04 +01:00
Commit Graph

71 Commits

Author SHA1 Message Date
Jesse de Wit
f7dcc32694
A note on the maximum size of Tagged Fields (#1042)
Make it more obvious to readers of bolt 11 that the maximum length of a Tagged
Field is 639 bytes.
2022-12-22 13:27:15 +01:00
Bastien Teinturier
b38156b951
Allow nodes to overshoot final htlc amount and expiry (#1032)
When nodes receive HTLCs, they verify that the contents of those HTLCs
match the intructions that the sender provided in the onion. It is
important to ensure that intermediate nodes and final nodes have similar
requirements, otherwise a malicious intermediate node could easily probe
whether the next node is the final recipient or not.

Unfortunately, the requirements for intermediate nodes were more lenient
than the requirements for final nodes. Intermediate nodes allowed overpaying
and increasing the CLTV expiry, whereas final nodes required a perfect
equality between the HTLC values and the onion values.

This provided a trivial way of probing: when relaying an HTLC, nodes could
relay 1 msat more than what the onion instructed (or increase the outgoing
expiry by 1). If the next node was an intermediate node, they would accept
this HTLC, but if the next node was the recipient, they would reject it.

We update those requirements to fix this probing attack vector.

We also clarify `min_final_cltv_expiry`: this is actually a cltv_expiry_delta,
not an absolute cltv_expiry, so the field name should reflect that.

Recipients require incoming HTLC expiry to comply with that expiry delta.
2022-11-08 08:38:36 +01:00
Joost Jager
2ab3a9f022
Add payment metadata to payment request 2022-01-03 20:09:14 +01:00
Bastien Teinturier
c876dac2b5
Add payment secret feature to Bolt 11 test vectors (#898)
Bolt 11 invoices must contain a `payment_secret`, which means that the
`features` field must set the `payment_secret` feature (and its dependency,
`var_onion_optin`).

Fixes #897
2021-09-14 09:11:45 +02:00
t-bast
ec1d4dc665
Make s field mandatory in invoices 2021-08-10 17:22:23 +02:00
t-bast
42bd71d49c
Add payment secret to Bolt 11 test vectors
Update Bolt 11 test vectors to always include a payment secret.

We want to make it mandatory in invoices which would make the existing
test vectors invalid.
2021-07-19 14:41:34 +02:00
Oliver Gugger
80c1ae1732
Bolt 11: add distinct HRP prefix for Bitcoin signet (#844)
Judging from the comment
https://github.com/bitcoin/bitcoin/pull/18267/files#r491150895 in the
Signet PR all test networks should have the same bech32_hrp prefix (even
regtest). That's why 'tb' was chosen for Signet as well.
This is not optimal for LN as invoices shouldn't be vague in
what network they were issued for.
Therefore we add the explicit prefix 'lntbs' for Signet invoices.
2021-03-02 09:16:36 +01:00
t-bast
b4132ff240 fixup! Update Bolt 11 default recommendation 2020-08-20 14:57:34 +09:30
t-bast
c5693d336d Update Bolt 11 default recommendation 2020-08-20 14:57:34 +09:30
Rusty Russell
f8ef3b4222
BOLT 11: make UPPERCASE explicit. (#677)
Explicitly mirror the BIP-173 advice for QR codes, and note the reader
requirements.

Fixes: #659
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-08-03 23:18:22 +02:00
Rusty Russell
1e2927b42c BOLT 11: add requirement that reader reject sub-msat invoices, and test.
We added a requirement on the writer, not the reader.  We can't really add
a test vector without a new requirement, though.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-05-12 06:56:40 +09:30
Rusty Russell
9e305f1ac1 BOLT 11: Add more negative tests.
This tests various forms of malformed invoices (it's not exhaustive though).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-05-12 06:56:40 +09:30
Rusty Russell
9a84c661b1 BOLT 11: Add two more successful test vectors.
One for uppercase, and one with should-be-ignored fields.

The first of these addresses #659 (#677 directly changes the text
to make it clear this is allowed, and should also be applied).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-05-12 06:56:40 +09:30
Rusty Russell
9c10fd36fa BOLT 11: move pico-BTC test vector earlier in file.
We're going to extend the final case with negative test cases.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-05-12 06:56:40 +09:30
Thorkil Værge
85068c5099
Add bolt11 test vector with amount in p units (#699) 2020-03-03 18:36:44 +01:00
Jonathan Underwood
9a3a0a47f1
[Bolt11] Clarify when payment secret should be included (#747)
Payment secret must be included if and only if the corresponding feature bit is set.
2020-02-27 09:32:08 +01:00
Thorkil Værge
0bb69d3a37
Fix bad wording of amount requirement in Bolt11 (#733) 2020-01-31 09:23:15 +01:00
Christian Decker
17df7f2bba
Merge pull request #700 from Sword-Smith/patch-3
Specify that resolution of amount is msat
2020-01-29 14:21:19 +01:00
Christian Decker
29f1386995 fixup! Specify that resolution of amount is msat 2020-01-21 14:01:04 +01:00
Christian Decker
798ff4bdec fixup! Specify that resolution of amount is msat 2020-01-21 13:57:40 +01:00
Conner Fromknecht
c3a8e5e1a7 BOLT11: simplify existing writer feature requirements
As a final step, we now can remove several of the BOLT 11 writer's
requirements now that it builds on BOLT 9's, particularly:
 - setting the even bit if a feature is required.
 - only setting a feature if the node supports a given feature.

The lone requirement that remains pertains to setting the `s` value if
and only if the `payment_secret` feature is set.
2020-01-21 13:26:49 +01:00
Conner Fromknecht
1259f8f0db BOLT11: set TLV bit in payment secret test vectors 2020-01-21 13:26:49 +01:00
Conner Fromknecht
4c638b7353 09+11: require transitive feature dependencies
This commit:
 - Adds a new Dependencies column to the BOLT 9 feature table
   populated with existing feature dependencies.
 - Requires that all valid feature vectors set transitive dependencies.
 - Requires checking transitive dependencies when validating init
   messages and payment request.
 - Removes transitive feature requiremetns from the BOLT 11 writer, now
   that they are implicit by needing to comply with the BOLT 9 origin
   requirements.
2020-01-21 13:26:49 +01:00
Rusty Russell
6ad8ee4cc4 BOLT 4/11: require payment_secret for multi-part payments.
This means the BOLT11 invoice must offer it (we already say it must
set the field if it offers it), and that the receiving node must
require it (again, we already say it must check it if it requires it).

Without the payment_secret, MPP payments are especially vulnerable to
probing attacks: unlike normal payments (with amounts) they can be
detected with 1msat payment probes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-12-13 14:20:02 +10:30
Rusty Russell
4c3d01616d BOLT 4: Multi-part payments.
This also defines the TLV format for payment_secret; the two are intertwined.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-12-13 03:48:57 +00:00
Rusty Russell
5776d2a7ec 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>
2019-12-13 03:48:57 +00:00
Rusty Russell
8e69306e0a BOLT 11: use the same features for BOLT11 invoices as for others.
A bit less dense, but avoids a separate feature space.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-11-25 19:34:23 +00:00
Thorkil Værge
a5b3818204
Specify that resolution of amount is msat
When the `p` multiplier is used, the amount MUST be divisible
by 10 since the resolution used internally is millisatoshi.

This addresses but does not close #692.
2019-11-14 08:38:53 +01:00
Dimitris Apostolou
3476c9b25a Fix typos 2019-09-26 06:12:41 +00:00
Rusty Russell
03fd18e5bc fixup! BOLT 11: Add test vectors for feature bitfield. 2019-09-03 01:00:47 +00:00
Rusty Russell
2eea93e133 BOLT 11: Add test vectors for feature bitfield.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-03 01:00:47 +00:00
Rusty Russell
b93b3bf518 BOLT 11: Add feature bits.
Most obviously, we want this for BASE AMP, but it's useful in future.

Even though even bits won't cause existing implementations to know
they can't pay the invoice, it will allow it in future once everyone
has upgraded.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-09-03 01:00:47 +00:00
Jorge Timón
8bdfc16156 BOLT11: Clarification on n field (#613) 2019-07-17 09:45:35 +02:00
Otto Suess
53343c99a5 BOLT 11: fix link (#626)
Update link to reference Bolt04's overpayment ("if the amount paid is more than twice the amount expected [the final node] SHOULD fail the HTLC.")
2019-07-09 09:38:34 +02:00
landonMutch
90faaeda89 resolve @rustyrussell requests 2019-01-07 19:34:58 +00:00
Landon Mutch
63b1b46043 finish second pass copy edit to EOF, to bring in line with stylesheet 2019-01-07 19:34:58 +00:00
Landon Mutch
4839cd8e5f second pass copy edit to line 191; 2019-01-07 19:34:58 +00:00
Landon Mutch
2039e977ed second pass edit to line 100; 2019-01-07 19:34:58 +00:00
Landon Mutch
a2ca6c0dbb first pass edit to bring inline with stylesheet 2019-01-07 19:34:58 +00:00
Chris Stewart
25a9debcf3 Make unit explicit encoded in BOLT11 invoice
Rewording
2018-10-18 05:15:48 +00:00
Rusty Russell
f971e0dbf2 BOLT 11: delete confusing-causing rationale sentence.
I was trying to compactly indicate that the considered alternative to
multiplier postfixes was just express everything in millisatoshi, but
it's just confusing, and anyway there are other notations we didn't use
so it seems like a weird thing to explain.

Reported-by: @cdecker
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-25 02:38:02 +00:00
Rusty Russell
21e3688e84 BOLT 11: reword Human-Readable Part Requirements in modern form.
a.k.a. landonmutch style, where requirements are explicit and bullet-pointed.

This also tightens requirements:
1. New requirement (previously implied) that writer use correct prefix.
2. Reader MUST rather than SHOULD fail malformed `amount`.

It also makes it clear that writer can omit the multiplier.

Fixes: #442
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-07-25 02:38:02 +00:00
Janus Troelsen
4aabe60523 Break lines in route example 2018-06-26 20:42:09 +00:00
DanielWeigl
e39d3d2ff3 Add clarification for Bolt11 prefix for regtest
The document (and also BIP-0173) does not clarify which prefix bitcoin regtest should use, but bitcoin-core seems to have settled on `bcrt`, thus the most concise way for bolt11 would be to use `lnbcrt...`

currently c-lightning and lnd are not compatible if you want to pay invoices in regtest mode, see:
- https://github.com/ElementsProject/lightning/issues/1241
- https://github.com/lightningnetwork/lnd/issues/882
2018-04-30 20:23:38 +00:00
Christian Decker
2c472da0f9 bolt11: Rephrase the amount requirement 2018-04-16 23:28:17 +02:00
johnta0
b3269207b5 Change "if" to "so that" to make sense 2018-04-16 23:28:17 +02:00
Sebastian Geisler
e95fabca69 Fix test vector routing part
The routing tagged field of one test vector was extracted from the
invoice incorrectly. The route included in the invoice has as base
fee of 1 resp. 2 msat (as described in the explanation), but the
extracted bech32 part had a 0 msat base fee.
2018-04-11 03:43:33 +00:00
Conner Fromknecht
e86ac9a3b2 BOLT 11: notes payment desc injection vulnerabilities 2018-02-05 23:38:01 +00:00
practicalswift
2c3466a2af Remove trailing whitespace 2018-01-30 04:54:31 +00:00
practicalswift
a820356da8 Redundancy. Drop redundant use of "very". 2018-01-30 03:34:22 +00:00