From ecbb7635c3b86f2b1e9c829c5efccf254eb9689e Mon Sep 17 00:00:00 2001 From: Harry Beckwith Date: Wed, 26 Aug 2026 15:31:55 -0700 Subject: [PATCH] Punctuate the three bech32 error strings the reader actually sees These are not comments. They render on both sites: two of them appear in the Lightning invoice decoder when a reader breaks an invoice on purpose, which is the whole point of that control. Colons rather than dashes, matching the pattern the rest of the file already uses for its errors ("Too long:", "No separator:"). The tests assert only the "Mixed case" substring, so nothing depended on the punctuation. Co-Authored-By: Claude Opus 5 --- packages/bitcoin-logic/src/lib/bech32.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/bitcoin-logic/src/lib/bech32.ts b/packages/bitcoin-logic/src/lib/bech32.ts index 90d04c3..c401216 100644 --- a/packages/bitcoin-logic/src/lib/bech32.ts +++ b/packages/bitcoin-logic/src/lib/bech32.ts @@ -86,7 +86,7 @@ export function decodeBech32(input: string, options: Bech32Options = {}): Bech32 const hasLower = /[a-z]/.test(input); const hasUpper = /[A-Z]/.test(input); if (hasLower && hasUpper) { - return { ok: false, error: 'Mixed case — a bech32 string must be all-lower or all-upper, never both.' }; + return { ok: false, error: 'Mixed case: a bech32 string must be all-lower or all-upper, never both.' }; } const str = input.toLowerCase(); const sep = str.lastIndexOf('1'); @@ -109,7 +109,7 @@ export function decodeBech32(input: string, options: Bech32Options = {}): Bech32 } const encoding = verifyChecksum(hrp, values); if (!encoding) { - return { ok: false, error: 'Checksum failed — at least one character here is wrong.' }; + return { ok: false, error: 'Checksum failed: at least one character here is wrong.' }; } return { ok: true, hrp, payload: values.slice(0, -6), encoding }; } @@ -158,7 +158,7 @@ export function decodeSegwitAddress(input: string): SegwitAddress | Bech32Error if (!dec.ok) return dec; if (dec.payload.length === 0) return { ok: false, error: 'Empty data section after the checksum.' }; const version = dec.payload[0]; - if (version > 16) return { ok: false, error: `Invalid witness version ${version} — only 0 through 16 exist.` }; + if (version > 16) return { ok: false, error: `Invalid witness version ${version}: only 0 through 16 exist.` }; if (version === 0 && dec.encoding !== 'bech32') { return { ok: false, error: 'Version 0 witness address must use Bech32 checksum (key_io.cpp:145).' }; }