-
Notifications
You must be signed in to change notification settings - Fork 255
deps: bump hwi 2.4.0 -> 3.1.0 (drops Python 3.7/3.8) #2616
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
Open
k9ert
wants to merge
4
commits into
cryptoadvance:master
Choose a base branch
from
k9ert:kn/bump-hwi-3.1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
fb17459
deps: bump hwi 2.4.0 -> 3.1.0; require Python >=3.9,<3.13
k9ert bea2c8e
test: opt-in Jade-hardware test suite
k9ert f057131
test(jade_hardware): full sign path + fixtures + docs
k9ert 85e01c9
test(jade_hardware): tighten marker gate + skip implicit HWIBridge init
k9ert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| cHNidP8BAHECAAAAAYz9aGwGnHSzsZXBuDlKg9hNl6KeLvo8czy6WHaPTGwGAAAAAAD/////AqyEAQAAAAAAFgAUb6AWUAo8anN+uyYOLdyni6kjRVishAEAAAAAABYAFC80qhzwClOwVaKRoDp9RfCmmItSAAAAAAABAFMCAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////wFR/////wFADQMAAAAAABYAFNDEo+8J6Ze26Z45flGP4+QaEYyhAAAAAAEBH0ANAwAAAAAAFgAU0MSj7wnpl7bpnjl+UY/j5BoRjKEiBgLnqyU3tdSelwMJquBunknzbOHJ/rvUTsjg0cygtPnDGRhzxdoKVAAAgAEAAIAAAACAAAAAAAAAAAAAACICA11J7M1U0AmeQ2did8em1GJdYR2oil30m/lReneRp3elGHPF2gpUAACAAQAAgAAAAIABAAAAAAAAAAA= |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| █████████████████████████████ | ||
| ██ ▄▄▄▄▄ ██▄▀▀ ▀▄▀▄█ ▄▄▄▄▄ ██ | ||
| ██ █ █ █▄ ▀▄▀▄▀▄█ █ █ ██ | ||
| ██ █▄▄▄█ ██▀▄██▀▄▀▄█ █▄▄▄█ ██ | ||
| ██▄▄▄▄▄▄▄█ ▀ █ ▀▄▀▄█▄▄▄▄▄▄▄██ | ||
| ██ ▄▀ ▄▄▄▄█ █▀▄▀▄ ▄▀█▀▄▀███ | ||
| ██ ▀██▄▀▄▀▀▄█▀██▄▀▄▀▄▀▄▀▄▀▄██ | ||
| ████▀▄▄▄▄▀▀██▀ ▀█▀▄▀▄▀▄▀▄▀▄██ | ||
| ██▄▀█ ██▄▀██ ▄ ▀▄▀▄▀▄▀▄▀▄▀▄██ | ||
| ██▄██▄▄▄▄▄▀▀▀ ██▄▀ ▄▄▄ ▀▄▀▄██ | ||
| ██ ▄▄▄▄▄ █ ▄ ▀█▄█▀ █▄█ ▀▄▀▄██ | ||
| ██ █ █ █▄▄ ▀ ▀█▀▄ ▄ ▄▀▄ ███ | ||
| ██ █▄▄▄█ █ ▀█▄ ▀ ▀▄▀▄▀▄▀▄█▄██ | ||
| ██▄▄▄▄▄▄▄█▄█▄▄██▄█▄█▄█▄█▄█▄██ | ||
| ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| """Opt-in tests requiring a physical Blockstream Jade attached + operator. | ||
|
|
||
| Skipped by default. Enable with:: | ||
|
|
||
| pytest --run-jade-hardware tests/test_jade_hardware.py -s | ||
|
|
||
| The ``-s`` is required so operator prompts reach your terminal. | ||
|
|
||
| Operator setup | ||
| -------------- | ||
| For ``test_jade_enumerate_via_specter`` and | ||
| ``test_jade_extract_xpub_via_specter``: any Jade with any seed (your | ||
| real one is fine — those tests only read public material). | ||
|
|
||
| For ``test_jade_sign_psbt_via_specter``: the Jade must be in | ||
| **Temporary Signer mode** with the public **BIP-39 abandon vector** seed | ||
| (``abandon abandon ... about``) loaded. The simplest path: | ||
|
|
||
| 1. Power-cycle the Jade so it's at the boot menu. | ||
| 2. Choose ``Temporary Signer`` -> ``Scan SeedQR``. | ||
| 3. Scan ``tests/fixtures/jade_seedqr_abandon.png`` (or display | ||
| ``tests/fixtures/jade_seedqr_abandon.txt`` and scan from screen). | ||
| 4. Confirm the **testnet** network on Jade. | ||
| 5. The PSBT at ``tests/fixtures/jade_hardware.psbt`` is fabricated by | ||
| Coldcard's psbt_faker against this exact seed. | ||
|
|
||
| Temporary Signer state lives in RAM only; it's wiped on power-cycle. Your | ||
| real seed is not affected. | ||
| """ | ||
|
|
||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
|
|
||
| from cryptoadvance.specter.hwi_rpc import HWIBridge | ||
|
|
||
|
|
||
| FIXTURE_DIR = Path(__file__).parent / "fixtures" | ||
| PSBT_FIXTURE = FIXTURE_DIR / "jade_hardware.psbt" | ||
| SEEDQR_PNG = FIXTURE_DIR / "jade_seedqr_abandon.png" | ||
| SEEDQR_TXT = FIXTURE_DIR / "jade_seedqr_abandon.txt" | ||
|
|
||
| ABANDON_FINGERPRINT = "73c5da0a" | ||
|
|
||
|
|
||
| def _enumerate_jade(bridge: HWIBridge, chain: str = "main"): | ||
| # HWIBridge.enumerate defaults chain="" which Chain.argparse passes | ||
| # through unchanged; Jade's enumerate then fails with | ||
| # "Unhandled network: ". Pass an explicit chain. | ||
| devs = bridge.enumerate(chain=chain) | ||
| return [d for d in devs if d.get("type") == "jade"] | ||
|
|
||
|
|
||
| def _prompt(msg: str) -> None: | ||
| print(f"\n>>> {msg}") | ||
| try: | ||
| input(">>> Press Enter when ready... ") | ||
| except EOFError: | ||
| pass | ||
|
|
||
|
|
||
| @pytest.mark.jade_hardware | ||
| def test_jade_enumerate_via_specter(): | ||
| """Jade is detected by Specter's HWIBridge and reports a fingerprint.""" | ||
| _prompt("Connect and unlock the Jade.") | ||
| bridge = HWIBridge() | ||
| jades = _enumerate_jade(bridge) | ||
|
k9ert marked this conversation as resolved.
|
||
| assert jades, "no Jade detected — connect, unlock, and rerun" | ||
| jade = jades[0] | ||
| assert jade.get("fingerprint"), f"Jade enumerated without fingerprint: {jade}" | ||
| assert jade.get("path"), f"Jade enumerated without path: {jade}" | ||
|
|
||
|
|
||
| @pytest.mark.jade_hardware | ||
| def test_jade_extract_xpub_via_specter(): | ||
| """Specter can pull an xpub at a known derivation from Jade.""" | ||
| _prompt("Unlock the Jade. You may be asked to confirm the xpub export.") | ||
| bridge = HWIBridge() | ||
| jades = _enumerate_jade(bridge) | ||
| assert jades, "no Jade detected" | ||
| fingerprint = jades[0].get("fingerprint") | ||
| assert fingerprint, f"Jade enumerated without fingerprint: {jades[0]}" | ||
|
|
||
| # chain must be passed explicitly: HWIBridge.extract_xpub default is | ||
| # chain="" which Specter's JadeClient.__init__ rejects via _network() | ||
| # before extract_xpub's post-init override can apply. | ||
| xpub_line = bridge.extract_xpub( | ||
| derivation="m/84h/0h/0h", | ||
| device_type="jade", | ||
| fingerprint=fingerprint, | ||
| chain="main", | ||
| ) | ||
| assert xpub_line, "extract_xpub returned empty" | ||
| assert xpub_line.startswith("["), f"unexpected format: {xpub_line!r}" | ||
| assert "]" in xpub_line, f"unexpected format: {xpub_line!r}" | ||
| body = xpub_line.split("]", 1)[1].strip() | ||
| assert body.startswith(("xpub", "zpub", "ypub")), f"unexpected xpub: {body[:8]}" | ||
|
|
||
|
|
||
| @pytest.mark.jade_hardware | ||
| def test_jade_sign_psbt_via_specter(): | ||
| """End-to-end: Specter signs the canned abandon-vector PSBT through Jade. | ||
|
|
||
| Requires Jade in Temporary Signer mode with the abandon-vector seed | ||
| (see module docstring). The fixture PSBT was generated by Coldcard's | ||
| psbt_faker against m/84'/1'/0' on testnet; xfp is 73c5da0a. | ||
| """ | ||
| assert PSBT_FIXTURE.exists(), f"missing fixture: {PSBT_FIXTURE}" | ||
|
|
||
| seedqr_hint = ( | ||
| f"\n PNG: {SEEDQR_PNG}\n" | ||
| f" ASCII: cat {SEEDQR_TXT}" | ||
| ) | ||
| _prompt( | ||
| "Put Jade in Temporary Signer mode -> Scan SeedQR -> select TESTNET." | ||
| f"\n SeedQR for the BIP-39 abandon-vector lives at:{seedqr_hint}\n" | ||
| " Then confirm the transaction on device when prompted." | ||
| ) | ||
|
|
||
| psbt_b64 = PSBT_FIXTURE.read_text().strip() | ||
|
|
||
| bridge = HWIBridge() | ||
| jades = _enumerate_jade(bridge, chain="test") | ||
| assert jades, "no Jade detected" | ||
| fingerprint = jades[0].get("fingerprint") | ||
| assert fingerprint, f"Jade enumerated without fingerprint: {jades[0]}" | ||
| assert fingerprint.lower() == ABANDON_FINGERPRINT, ( | ||
| f"connected Jade fingerprint is {fingerprint}; " | ||
| f"expected {ABANDON_FINGERPRINT} (abandon-vector). " | ||
| "Are you in Temporary Signer mode with the right SeedQR?" | ||
| ) | ||
|
|
||
| signed = bridge.sign_tx( | ||
| psbt=psbt_b64, | ||
| device_type="jade", | ||
| fingerprint=fingerprint, | ||
| chain="test", | ||
| ) | ||
| assert signed, "sign_tx returned empty" | ||
| assert signed != psbt_b64, "PSBT was returned unsigned" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.