Skip to content

wallet: keep enumerating after duplicate signers - #35233

Closed
l0rinc wants to merge 2 commits into
bitcoin:masterfrom
l0rinc:l0rinc/external-signer-skip-canceled-duplicates
Closed

l0rinc wants to merge 2 commits into
bitcoin:masterfrom
l0rinc:l0rinc/external-signer-skip-canceled-duplicates

Conversation

@l0rinc

@l0rinc l0rinc commented May 7, 2026

Copy link
Copy Markdown
Contributor

Problem

ExternalSigner::Enumerate() says it skips duplicate signers, but the current control flow stops enumeration when it finds the first duplicate fingerprint.

This can hide later unique signer entries returned by the same enumerate call.

Fix

Use continue instead of break for duplicate signer entries, so only the duplicate entry is skipped and later entries are still processed.
This does not change error handling: if an enumerate entry reports an error before it reaches the duplicate check, the RPC still reports that error.

Test

The functional test now covers an enumerate result containing one signer, a duplicate of that signer, and a later unique signer.

l0rinc added 2 commits May 7, 2026 11:29
External signer enumeration currently stops when it sees a duplicate fingerprint, so later unique signer entries are not reported.
Add coverage for that behavior before changing duplicate handling from stopping enumeration to skipping one entry.
The code says duplicate signer entries are skipped, but it currently breaks out of enumeration at the first duplicate and can hide later unique signers.
Use `continue`, so the implementation matches the comment: only the duplicate entry is skipped and later entries still reach the caller.
This does not change error handling. A duplicate entry that reports an error before the duplicate check is still reported as an error.
@DrahtBot DrahtBot added the Wallet label May 7, 2026
@DrahtBot

DrahtBot commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35233.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK ViniciusCestarii, kevkevinpal

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

@ViniciusCestarii

Copy link
Copy Markdown
Contributor

tACK d543f8b

Ran the test and did some manual mutation testing to confirm it catches regressions:

  • Dropping {"fingerprint": "00000002", "name": "trezor_one"} from the expected list -> test fails (assertion catches the missing signer).
  • Swapping continue for break in the wallet enumeration -> test fails (only the first signer gets returned).

@Sjors

Sjors commented May 8, 2026

Copy link
Copy Markdown
Member

This probably makes sense. @achow101 do you remember under what circumstances HWI returns duplicate signers?

@achow101

achow101 commented May 8, 2026

Copy link
Copy Markdown
Member

do you remember under what circumstances HWI returns duplicate signers?

It should never have duplicates.

@Sjors

Sjors commented May 8, 2026

Copy link
Copy Markdown
Member

@achow101 I vaguely remember something like finding the same device via two different transports.

@kevkevinpal

Copy link
Copy Markdown
Contributor

ACK d543f8b

I'm confused why, in the first commit, you added a broken test to fix it in the next commit instead of just a single commit. But I guess it does make sense to have some coverage for enumerating duplicate signers if we ever end up rolling back this change.

@l0rinc

l0rinc commented May 8, 2026

Copy link
Copy Markdown
Contributor Author

you added a broken test to fix it

To document the current behavior, so that the next commit shows exactly what changed compared to the current behavior. A single commit would only show the behavior after the fix.

@l0rinc

l0rinc commented May 9, 2026

Copy link
Copy Markdown
Contributor Author

I'll close this one to allow new contributors to continue: #35251

@l0rinc l0rinc closed this May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants