Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Light refactor of Electrum seed support #571

Merged
merged 8 commits into from
Jul 15, 2024

Conversation

kdmukai
Copy link
Contributor

@kdmukai kdmukai commented Jul 13, 2024

Description

Light refactor of #513:

  • A View should only ever invoke a single Screen. Pulled the Electrum seed warning screen into its own View. Also gain some modest DRY efficiency and easier future maintenance this way.
  • The SettingsEntry for the Electrum seed option used a display_name value that was way too long to fit in the button list (Settings -> Advanced) that would leave a rendering artifact on the far right edge (scroll past the Electrum option to the bottom of the list).
  • Slightly tightens up ElectrumSeed mnemonic validation.

Housekeeping, more robust testing:

  • Adds a screenshot for the Electrum seed warning.
  • Adds a screenshot for the "Advanced" section of the Settings list.
  • Adds flow tests:
    • Basic Electrum mnemonic entry.
    • Export xpub should respect ElectrumSeed.override_script.
    • Load PSBT side flow to load an Electrum mnemonic and return to PSBT flow (incomplete)
    • Address Explorer side flow to load an Electrum mnemonic and return.
  • Additional tests for ElectrumSeed:
    • Check mnemonic length requirement
    • Reject most BIP-39 mnemonics but confirm that some are valid for both BIP-39 and Electrum.

Reversions:

  • Reverts the changes to SeedQREncoder that were probably added at an earlier phase when Electrum seed + SeedQR was being considered. Downstream effect of this reversion includes seed_views.py, test_encodepsbtqr.py, test_seedqr.py.

Misc:

  • Remove bool return from Seed._generate_seed as it is never used.
  • Naming convention conformance in Seed: wallet_type -> sig_type; the term "wallet" is just too overused and poorly specified in bitcoin. Note: embit_utils does still use wallet_type but in order to keep this ever-larger PR in check and since it's older, existing code, I left that refactor for another day.

Settings list issue before the fix in this PR:

After:

SettingsMenuView__Advanced


New/Updated screenshots:

SeedElectrumMnemonicStartView

After moving part of the long settings name into help_text:

SettingsEntryUpdateSelectionView_electrum_seeds


This pull request is categorized as a:

  • Code refactor
  • Additional tests

Checklist

  • I’ve run pytest and made sure all unit tests pass before sumbitting the PR

If you modified or added functionality/workflow, did you add new unit tests?

  • Yes

I have tested this PR on the following platforms/os:

Note: Keep your changes limited in scope; if you uncover other issues or improvements along the way, ideally submit those as a separate PR. The more complicated the PR the harder to review, test, and merge.

status_headline=None,
text=f"Some features disabled for Electrum seeds",
show_back_button=False,
)
from seedsigner.views.seed_views import SeedMnemonicEntryView
self.controller.storage.init_pending_mnemonic(num_words=12, is_electrum=True)
return Destination(SeedMnemonicEntryView)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant this to direct to the new SeedElectrumMnemonicStartView since removed the warning screen above

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from seedsigner.views.seed_views import SeedElectrumMnemonicStartView
return Destination(SeedElectrumMnemonicStartView)

self.controller.storage.init_pending_mnemonic(num_words=12, is_electrum=True)
return Destination(SeedMnemonicEntryView)
from seedsigner.views.seed_views import SeedElectrumWarningView
return Destination(SeedElectrumWarningView)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you meant to call SeedElectrumMnemonicStartView here, perhaps renamed it in the middle of the refactor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I get for being too dependent on VSCode to just magically get things right...

(...okay, and for not having enough FlowTest scenarios to catch things!)

@jdlcdl
Copy link

jdlcdl commented Jul 14, 2024

As of f06666e

ACK tested

Everything is working for me:

  • electrum 12w seed with custom extension
  • exporting xpub to sparrow
  • address explorer and address verification matching
  • psbt reading/signing (of course).

@kdmukai
Copy link
Contributor Author

kdmukai commented Jul 14, 2024

  • electrum 12w seed with custom extension

Ooh, I should add the "custom extension" wrinkle to the FlowTest.

@jdlcdl
Copy link

jdlcdl commented Jul 14, 2024

I've retested this w/ a modified version on top of 6d114f7:

w/ that said, I repeat my ACK tested from earlier today w/ same manual tests performed.

src/seedsigner/views/tools_views.py Show resolved Hide resolved
status_headline=None,
text=f"Some features disabled for Electrum seeds",
show_back_button=False,
)
from seedsigner.views.seed_views import SeedMnemonicEntryView
self.controller.storage.init_pending_mnemonic(num_words=12, is_electrum=True)
return Destination(SeedMnemonicEntryView)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from seedsigner.views.seed_views import SeedElectrumMnemonicStartView
return Destination(SeedElectrumMnemonicStartView)

@newtonick
Copy link
Collaborator

tACK

@newtonick newtonick merged commit e16c853 into SeedSigner:dev Jul 15, 2024
2 checks passed
@kdmukai kdmukai deleted the electrum_seed_cleanup branch September 2, 2024 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants