fix(wallet): accept uppercase QR-scanned BOLT11 invoices on send
The send path detected and decoded uppercase invoices correctly (SendDialog's
isBolt11 lowercases first) but WalletService.sendPayment gated the bolt11
branch on a case-sensitive startsWith('ln'), so QR-scanned invoices (uppercase
bech32, e.g. LNBC...) fell through to the else and threw "Invalid payment
destination format" despite the UI showing a valid decode.
Detect BOLT11 case-insensitively by its HRP (lnbc/lntb/lntbs/lnbcrt) and send
the lowercase canonical form. The bare 'ln' prefix also incidentally matched
bech32 LNURLs (lnurl1...) and misrouted them to the bolt11 endpoint; matching
the full HRP closes that gap too.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
db497d8a06
commit
138f9905bf
1 changed files with 15 additions and 8 deletions
|
|
@ -240,21 +240,28 @@ export default class WalletService extends BaseService {
|
||||||
let endpoint = ''
|
let endpoint = ''
|
||||||
let body: any = {}
|
let body: any = {}
|
||||||
|
|
||||||
// Determine payment type and prepare request
|
// Determine payment type and prepare request.
|
||||||
if (request.destination.startsWith('ln')) {
|
// QR-scanned invoices are uppercase bech32, so detection must be
|
||||||
// Lightning invoice
|
// case-insensitive. Match BOLT11 by its HRP (lnbc / lntb / lntbs /
|
||||||
|
// lnbcrt) rather than a bare "ln" prefix, which would also swallow
|
||||||
|
// bech32 LNURLs and misroute them to the bolt11 endpoint.
|
||||||
|
const dest = request.destination.trim()
|
||||||
|
const lower = dest.toLowerCase()
|
||||||
|
|
||||||
|
if (lower.startsWith('lnbc') || lower.startsWith('lntb') || lower.startsWith('lntbs') || lower.startsWith('lnbcrt')) {
|
||||||
|
// Lightning invoice (BOLT11) — send the lowercase canonical form
|
||||||
endpoint = `${config.api.baseUrl}/api/v1/payments`
|
endpoint = `${config.api.baseUrl}/api/v1/payments`
|
||||||
body = {
|
body = {
|
||||||
out: true,
|
out: true,
|
||||||
bolt11: request.destination
|
bolt11: lower
|
||||||
}
|
}
|
||||||
} else if (request.destination.includes('@') || request.destination.toLowerCase().startsWith('lnurl')) {
|
} else if (dest.includes('@') || lower.startsWith('lnurl')) {
|
||||||
// Lightning address or LNURL
|
// Lightning address or LNURL
|
||||||
endpoint = `${config.api.baseUrl}/api/v1/payments/lnurl`
|
endpoint = `${config.api.baseUrl}/api/v1/payments/lnurl`
|
||||||
body = {
|
body = {
|
||||||
lnurl: request.destination.includes('@')
|
lnurl: dest.includes('@')
|
||||||
? `https://${request.destination.split('@')[1]}/.well-known/lnurlp/${request.destination.split('@')[0]}`
|
? `https://${dest.split('@')[1]}/.well-known/lnurlp/${dest.split('@')[0]}`
|
||||||
: request.destination,
|
: dest,
|
||||||
amount: request.amount * 1000, // Convert to millisats
|
amount: request.amount * 1000, // Convert to millisats
|
||||||
comment: request.comment || ''
|
comment: request.comment || ''
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue