AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 22 Bitcoin

plugin: nwc: lookup_invoice: fix exc, include b11

Public commit record

What the developer wrote

Authored by f321x

76/100 · Adequate
plugin: nwc: lookup_invoice: fix exc, include b11

Fixes exception in lookup_invoice:
```
62.69 | E | plugins.nwc.nwcserver.NWCServer | Error handling nwc request
Traceback (most recent call last):
File "/home/user/code/vibecoding_vm/electrum/electrum/plugins/nwc/nwcserver.py", line 381, in run_request_task
await task
File "/home/user/code/vibecoding_vm/electrum/electrum/util.py", line 1211, in wrapper
return await func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/code/vibecoding_vm/electrum/electrum/plugins/nwc/nwcserver.py", line 526, in handle_lookup_invoice
info = self.wallet.lnworker.get_payment_info(invoice.payment_hash, direction=RECEIVED)
^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Invoice' object has no attribute 'payment_hash'
```

Always includes bolt11 invoice in response, even if the client already
sent it to us in the request. It doesn't seem useful and is marked
optional in the spec but https://sandbox.albylabs.com considers the
response invalid if the invoice is not included.
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit fixes a crash in Electrum's Nostr Wallet Connect (NWC) plugin when a user looks up an existing incoming invoice. The code was trying to read a non-existent 'payment_hash' field and instead should use the invoice's existing 'rhash' value. It also changes the response so the BOLT11 invoice string is always included, rather than only when the client originally searched by payment hash. This improves compatibility with a third-party service (sandbox.albylabs.com) that rejects responses missing the invoice string. There is no indication this bug could be exploited by an attacker; it is a functional bug causing request failures.

Recommended action

Treat as a routine bug-fix commit. Reviewers may want to verify that invoice.rhash is always a valid hex string before bytes.fromhex is called, and confirm the always-include-invoice behavior does not leak invoice data to unauthorized clients. No urgent security action is indicated.

Security signals we found

01

Crash/exception in request handler due to incorrect attribute access

02

Behavioral change to always include BOLT11 invoice in NWC lookup_invoice response

03

No input validation, memory safety, or authorization changes observed

Risk score

Why this scored 22/100

Our methodology →
Potential impact 5/30
Exploitability 0/25
Stealth signal 0/15
Affected reach 5/15
Confidence 8/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.