event icon indicating copy to clipboard operation
event copied to clipboard

Certificate Verification unchecks after scanning lndconnect QR code

Open AndySchroder opened this issue 2 years ago • 4 comments

Describe the bug

Certificate Verification Unchecks after scanning lndconnect QR code

Reproduce

  1. Settings
  2. Add a new node
  3. Choose LND REST
  4. Check Certificate Verification
  5. Scan lndconnect QR code
  6. Certificate Verification changes from checked to unchecked

ZEUS version

v0.9.0

Node interface

LND (REST)

Network

Clearnet

Device

GrapheneOS

Device operating system

android

Log output

No response

AndySchroder avatar Sep 10 '24 16:09 AndySchroder

Hello, @kaloudis

If this issue is available, I would love to take it as part of my Summer of Bitcoin contribution.

On the surface, it appears that when the lndconnect QR payload is parsed and applied to the node configuration, the certificate verification flag may be overridden.

My intention is to:

Track the decoding and mapping of the QR data to the LND REST configuration.

Verify the location of the certificate verification setting and reset during that flow.

After scanning, make sure the user's explicit toggle state is maintained.

To prevent this from regressing, add a small test or safeguard.

Would you kindly assign the problem to me if this strategy seems reasonable? I'd be happy to make any necessary adjustments based on your advice.

Regards!

preetham3127 avatar Feb 03 '26 08:02 preetham3127

Hi, I'd like to work on this. My guess at the root cause: when the lndconnect QR is scanned, the handler parses the connection string into a fresh node config object and merges it into form state, and that merge likely overwrites the certVerification flag back to its default rather than preserving whatever the user had already set, since the parsed lndconnect string itself doesn't carry a certVerification field. I'll trace where the QR result gets merged into the node-add form state and fix it to preserve the existing checkbox value instead of resetting it. Happy to be assigned.

nisargpatel7042lva avatar Sep 20 '26 08:09 nisargpatel7042lva

@nisargpatel7042lva this is yours — not trying to take it. I had already traced it before I saw your comment, and your guess is right, so here is the exact mechanism to save you the digging.

ConnectionFormatUtils.processLndConnectUrl returns only four fields:

return { host, port, macaroonHex, enableTor };

No certVerification. The lndconnect branch of handleAnything passes that object straight through as node (utils/handleAnything.ts:625), and the lndhub branch right below it is the contrast — that one does set certVerification: true explicitly.

The clobber is in WalletConfiguration.initFromProps. It destructures the incoming node and assigns the field straight into state (views/Settings/WalletConfiguration.tsx:485):

implementation: implementation || 'lnd',
certVerification,          // undefined for a scanned lndconnect node

Note implementation on the line above has a fallback and certVerification does not, so undefined overwrites the true the user just ticked, and the checkbox renders unticked.

The reason a fallback works here rather than needing the value threaded through the scanner: HandleAnythingQRScanner returns with

navigation.goBack();
navigation.navigate(route, props);

so this is the same WalletConfiguration instance the user ticked the box on, receiving new params via componentDidUpdate. That is also why index, active, tor, saved and newEntry a few lines up are already written as route.params.X ?? this.state.X — certVerification just never got the same treatment.

Two things worth deciding, which are yours to call:

  1. Whether to fix it at the consumer (certVerification ?? this.state.certVerification) or at the source (certVerification: true in the lndconnect branch, mirroring lndhub). I would lean to the consumer: lndconnect URLs commonly point at self-signed certs, so defaulting verification on at the source could turn a silent unticking into a failed connection.
  2. nickname sits in the same setState with no fallback either, so typing a nickname and then scanning should wipe it the same way. Might be worth checking whether that reproduces while you are in there.

kunalKumar-13 avatar Sep 21 '26 22:09 kunalKumar-13

Done, Opened a PR! @kunalKumar-13

nisargpatel7042lva avatar Sep 22 '26 05:09 nisargpatel7042lva