Bolt11Invoice.fromString skips p, h and s fields of the wrong length
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
Research direction
Read eclair-core/src/main/scala/fr/acinq/eclair/payment/Bolt11Invoice.scala around the InvalidTag1, InvalidTag23 and InvalidTag16 decoding branches, then review the related tests in eclair-core/src/test/scala/fr/acinq/eclair/payment/Bolt11InvoiceSpec.scala. Run ./mvnw test -pl eclair-core -Dsuites='*Bolt11InvoiceSpec'; done means invoices with 51-group p, h or s fields fail to decode, as the supplied test expects.
Written by the indexing model from the issue text.
Description
Bolt11Invoice.fromString skips a 51-group p, h or s field and decodes the invoice instead of failing. This happens on master at 06716fce and in v0.14.5.
The case below, added to eclair-core/src/test/scala/fr/acinq/eclair/payment/Bolt11InvoiceSpec.scala, builds three invoices from the BOLT 11 cup of coffee example, each with one wrong-length field: a 51-group h, a 51-group p and a 51-group s.
// BOLT 11 example "Please send $3 for a cup of coffee to the same peer, within one minute".
val cupOfCoffee: Bolt11Invoice = Bolt11Invoice.fromString("lnbc2500u1pvjluezsp5zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zygspp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5xysxxatsyp3k7enxv4jsxqzpu9qrsgquk0rl77nj30yxdy8j9vdx85fkpmdla2087ne0xh8nhedh8w27kyke0lp53ut353s06fv3qfegext0eh0ymjpf39tuven09sam30g4vgpfna3rh").get
test("reject p, h or s fields with an invalid length") {
// Bolt11: a reader MUST fail an invoice whose p, h, s or n field does not have the correct length.
def groups(i: Int) = BitVector.fill(i * 5)(high = false)
val wrongLength = List(InvalidTag23(groups(51)), InvalidTag1(groups(51)), InvalidTag16(groups(51)))
for (bad <- wrongLength) {
val invoice = cupOfCoffee.copy(tags = cupOfCoffee.tags :+ bad).sign(priv)
assert(Bolt11Invoice.fromString(invoice.toString).isFailure)
}
}
./mvnw test -pl eclair-core -Dsuites='*Bolt11InvoiceSpec' reports the case failing.
- reject p, h or s fields with an invalid length *** FAILED ***
Bolt11Invoice.fromString(invoice.toString).isFailure was false (Bolt11InvoiceSpec.scala:686)
Tests: succeeded 37, failed 1, canceled 0, ignored 0, pending 0
The codec reads those fields as InvalidTag1, InvalidTag23 and InvalidTag16 at lines 411-414, 439-442 and 429-432. The constructor counts only the fields of the right length, so a wrong-length field does not stop the decode. The test "ignore hash tags with invalid length" at Bolt11InvoiceSpec.scala:450-451 still quotes the earlier skip rule, which BOLT 11 replaced in commit 68881992 in June 2025.
fromString should fail on all three. BOLT 11, Tagged Fields, line 214 says a reader "MUST fail the payment if any field with fixed data_length (p, h, s, n) does not have the correct length (52, 52, 52, 53)".
- Dominant language
- Scala
- Stars
- 1.3k
- Forks
- 285
- Avg merge
- 20h 22m
- Merged PRs (30d)
- 28
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ACINQ/eclair
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
propensive/soundness#2351 ·
Maintainers usually reply within 1 day
-
Traffic event delivered/rejected counters appear swapped in TrafficStateController.updateWithReceiptOpen
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
digital-asset/canton#705 ·
Maintainers usually reply within 2 days
-
easy first-contributor first-contributors good first issue help wanted scala up-for-grabs
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
fork-commit-merge/fork-commit-merge#8457 ·
Maintainers usually reply within 1 day
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 78/100
promovolve/promovolve#358 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 95/100
svroonland/zio-kinesis#1431 ·