From 7d8a57a806240ef11504746778f3a6c4d3031ce5 Mon Sep 17 00:00:00 2001 From: matejcik Date: Wed, 18 Oct 2023 16:15:45 +0200 Subject: [PATCH] style(python): use 'h' for hardening instead of apostrophe (fixes #3037) --- python/.changelog.d/3037.changed | 1 + python/docs/transaction-format.md | 6 +++--- python/src/trezorlib/cli/binance.py | 2 +- python/src/trezorlib/cli/cardano.py | 2 +- python/src/trezorlib/cli/cosi.py | 2 +- python/src/trezorlib/cli/crypto.py | 4 ++-- python/src/trezorlib/cli/eos.py | 2 +- python/src/trezorlib/cli/ethereum.py | 2 +- python/src/trezorlib/cli/monero.py | 2 +- python/src/trezorlib/cli/nem.py | 2 +- python/src/trezorlib/cli/ripple.py | 2 +- python/src/trezorlib/cli/stellar.py | 2 +- python/src/trezorlib/cli/tezos.py | 2 +- python/tools/helloworld.py | 2 +- python/tools/trezorctl_script_client.py | 2 +- 15 files changed, 18 insertions(+), 17 deletions(-) create mode 100644 python/.changelog.d/3037.changed diff --git a/python/.changelog.d/3037.changed b/python/.changelog.d/3037.changed new file mode 100644 index 000000000..68e32dc7f --- /dev/null +++ b/python/.changelog.d/3037.changed @@ -0,0 +1 @@ +Use 'h' character for hardened BIP-32 components in help texts. diff --git a/python/docs/transaction-format.md b/python/docs/transaction-format.md index 5d8ddceb8..7339482fc 100644 --- a/python/docs/transaction-format.md +++ b/python/docs/transaction-format.md @@ -191,17 +191,17 @@ The JSON below encodes a transaction with the following inputs: * [e9cec1644db8fa95fe639a9b503a63ea587d2f4e480d3847703e3ec73adf6b5a](https://btc5.trezor.io/tx/e9cec1644db8fa95fe639a9b503a63ea587d2f4e480d3847703e3ec73adf6b5a) output **0** (P2PKH address 1Jw5FrKhi2aWbbF4h3QRWLog5AjsJYGswv) - at derivation path **m/44'/0'/0'/0/282** + at derivation path **m/44h/0h/0h/0/282** amount **85 170** sat * [1f545c0ca1f2c055e199c70457025c1e393edd013a274a976187115a5c601155](https://btc5.trezor.io/tx/1f545c0ca1f2c055e199c70457025c1e393edd013a274a976187115a5c601155) output **0** (P2SH-SegWit address 3DEAk9KGrgvj2gHQ1hyfCXus9hZr9K8Beh) - at derivation path **m/49'/0'/0'/0/55** + at derivation path **m/49h/0h/0h/0/55** amount **500 000** sat And the following outputs: * **12 345** sat to address **3DDEgt7quAq7XqoG6PjVXi1eeAea4rfWck** -* **562 825** sat to a P2SH-SegWit change address at derivation path **m/49'/0'/0'/1/99** +* **562 825** sat to a P2SH-SegWit change address at derivation path **m/49h/0h/0h/1/99** * fee of 10 000 sat (Note that Trezor does not support change addresses when mixing input types. The example diff --git a/python/src/trezorlib/cli/binance.py b/python/src/trezorlib/cli/binance.py index b954274dd..a3139fb27 100644 --- a/python/src/trezorlib/cli/binance.py +++ b/python/src/trezorlib/cli/binance.py @@ -27,7 +27,7 @@ if TYPE_CHECKING: from ..client import TrezorClient -PATH_HELP = "BIP-32 path to key, e.g. m/44'/714'/0'/0/0" +PATH_HELP = "BIP-32 path to key, e.g. m/44h/714h/0h/0/0" @click.group(name="binance") diff --git a/python/src/trezorlib/cli/cardano.py b/python/src/trezorlib/cli/cardano.py index b18ae5a11..ef8256274 100644 --- a/python/src/trezorlib/cli/cardano.py +++ b/python/src/trezorlib/cli/cardano.py @@ -25,7 +25,7 @@ from . import ChoiceType, with_client if TYPE_CHECKING: from ..client import TrezorClient -PATH_HELP = "BIP-32 path to key, e.g. m/44'/1815'/0'/0/0" +PATH_HELP = "BIP-32 path to key, e.g. m/44h/1815h/0h/0/0" TESTNET_CHOICES = { "preprod": "testnet_preprod", diff --git a/python/src/trezorlib/cli/cosi.py b/python/src/trezorlib/cli/cosi.py index eaa7b95a3..95b1e816e 100644 --- a/python/src/trezorlib/cli/cosi.py +++ b/python/src/trezorlib/cli/cosi.py @@ -25,7 +25,7 @@ if TYPE_CHECKING: from .. import messages from ..client import TrezorClient -PATH_HELP = "BIP-32 path, e.g. m/10018'/0'" +PATH_HELP = "BIP-32 path, e.g. m/10018h/0h" @click.group(name="cosi") diff --git a/python/src/trezorlib/cli/crypto.py b/python/src/trezorlib/cli/crypto.py index 4bfd9041c..a58b80d4b 100644 --- a/python/src/trezorlib/cli/crypto.py +++ b/python/src/trezorlib/cli/crypto.py @@ -49,7 +49,7 @@ def get_entropy(client: "TrezorClient", size: int) -> str: @cli.command() -@click.option("-n", "--address", required=True, help="BIP-32 path, e.g. m/10016'/0") +@click.option("-n", "--address", required=True, help="BIP-32 path, e.g. m/10016h/0") @click.option( "-p", "--prompt", type=PROMPT_TYPE, default="always", help="Prompt for passphrase" ) @@ -85,7 +85,7 @@ def encrypt_keyvalue( @cli.command() -@click.option("-n", "--address", required=True, help="BIP-32 path, e.g. m/10016'/0") +@click.option("-n", "--address", required=True, help="BIP-32 path, e.g. m/10016h/0") @click.option( "-p", "--prompt", type=PROMPT_TYPE, default="always", help="Prompt for passphrase" ) diff --git a/python/src/trezorlib/cli/eos.py b/python/src/trezorlib/cli/eos.py index c0b3657b9..84c248c4a 100644 --- a/python/src/trezorlib/cli/eos.py +++ b/python/src/trezorlib/cli/eos.py @@ -26,7 +26,7 @@ if TYPE_CHECKING: from .. import messages from ..client import TrezorClient -PATH_HELP = "BIP-32 path, e.g. m/44'/194'/0'/0/0" +PATH_HELP = "BIP-32 path, e.g. m/44h/194h/0h/0/0" @click.group(name="eos") diff --git a/python/src/trezorlib/cli/ethereum.py b/python/src/trezorlib/cli/ethereum.py index 886febcee..10b72fad5 100644 --- a/python/src/trezorlib/cli/ethereum.py +++ b/python/src/trezorlib/cli/ethereum.py @@ -35,7 +35,7 @@ if TYPE_CHECKING: from ..client import TrezorClient -PATH_HELP = "BIP-32 path, e.g. m/44'/60'/0'/0/0" +PATH_HELP = "BIP-32 path, e.g. m/44h/60h/0h/0/0" # fmt: off ETHER_UNITS = { diff --git a/python/src/trezorlib/cli/monero.py b/python/src/trezorlib/cli/monero.py index 91311af6e..355c562ae 100644 --- a/python/src/trezorlib/cli/monero.py +++ b/python/src/trezorlib/cli/monero.py @@ -24,7 +24,7 @@ from . import ChoiceType, with_client if TYPE_CHECKING: from ..client import TrezorClient -PATH_HELP = "BIP-32 path, e.g. m/44'/128'/0'" +PATH_HELP = "BIP-32 path, e.g. m/44h/128h/0h" @click.group(name="monero") diff --git a/python/src/trezorlib/cli/nem.py b/python/src/trezorlib/cli/nem.py index 9cf77a276..746ad1872 100644 --- a/python/src/trezorlib/cli/nem.py +++ b/python/src/trezorlib/cli/nem.py @@ -26,7 +26,7 @@ from . import with_client if TYPE_CHECKING: from ..client import TrezorClient -PATH_HELP = "BIP-32 path, e.g. m/44'/134'/0'/0'" +PATH_HELP = "BIP-32 path, e.g. m/44h/134h/0h/0h" @click.group(name="nem") diff --git a/python/src/trezorlib/cli/ripple.py b/python/src/trezorlib/cli/ripple.py index f710ac01c..e4bcc0b35 100644 --- a/python/src/trezorlib/cli/ripple.py +++ b/python/src/trezorlib/cli/ripple.py @@ -25,7 +25,7 @@ from . import with_client if TYPE_CHECKING: from ..client import TrezorClient -PATH_HELP = "BIP-32 path to key, e.g. m/44'/144'/0'/0/0" +PATH_HELP = "BIP-32 path to key, e.g. m/44h/144h/0h/0/0" @click.group(name="ripple") diff --git a/python/src/trezorlib/cli/stellar.py b/python/src/trezorlib/cli/stellar.py index 1d56de2fb..77ce700ee 100644 --- a/python/src/trezorlib/cli/stellar.py +++ b/python/src/trezorlib/cli/stellar.py @@ -34,7 +34,7 @@ try: except ImportError: pass -PATH_HELP = "BIP32 path. Always use hardened paths and the m/44'/148'/ prefix" +PATH_HELP = "BIP32 path. Always use hardened paths and the m/44h/148h/ prefix" @click.group(name="stellar") diff --git a/python/src/trezorlib/cli/tezos.py b/python/src/trezorlib/cli/tezos.py index 45af6bafd..7dcd1ab9d 100644 --- a/python/src/trezorlib/cli/tezos.py +++ b/python/src/trezorlib/cli/tezos.py @@ -25,7 +25,7 @@ from . import with_client if TYPE_CHECKING: from ..client import TrezorClient -PATH_HELP = "BIP-32 path, e.g. m/44'/1729'/0'" +PATH_HELP = "BIP-32 path, e.g. m/44h/1729h/0h" @click.group(name="tezos") diff --git a/python/tools/helloworld.py b/python/tools/helloworld.py index b2e947e33..76b4502da 100755 --- a/python/tools/helloworld.py +++ b/python/tools/helloworld.py @@ -29,7 +29,7 @@ def main() -> None: print(client.features) # Get the first address of first BIP44 account - bip32_path = parse_path("44'/0'/0'/0/0") + bip32_path = parse_path("44h/0h/0h/0/0") address = btc.get_address(client, "Bitcoin", bip32_path, True) print("Bitcoin address:", address) diff --git a/python/tools/trezorctl_script_client.py b/python/tools/trezorctl_script_client.py index 72aa3287b..527c7a670 100644 --- a/python/tools/trezorctl_script_client.py +++ b/python/tools/trezorctl_script_client.py @@ -84,7 +84,7 @@ def get_passphrase_from_user(available_on_device: bool = False) -> str: def get_address() -> str: args = """ - trezorctl --script get-address -n "m/49'/0'/0'/0/0" + trezorctl --script get-address -n "m/49h/0h/0h/0/0" """.strip() p = subprocess.Popen( # type: ignore [No overloads for "__new__" match the provided arguments] args,