From eb943dded7562854984d0d406c61f830dc3f9694 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Thu, 4 Jun 2026 10:41:42 +0000 Subject: [PATCH] BipHDNode.from_path(): determine addr type from protocol --- examples/bip_hd.py | 1 - mmgen/bip_hd/__init__.py | 8 +++++--- test/modtest_d/bip_hd.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/bip_hd.py b/examples/bip_hd.py index d7d46b62..8d8d117d 100755 --- a/examples/bip_hd.py +++ b/examples/bip_hd.py @@ -74,7 +74,6 @@ nonstd_path = BipHDNode.from_path( seed = seed, path_str = "m/111'/222/333/444", coin = 'eth', - addr_type = 'E', no_path_checks = True) print('Non-standard path (ETH):\n') diff --git a/mmgen/bip_hd/__init__.py b/mmgen/bip_hd/__init__.py index efe00295..a4731194 100644 --- a/mmgen/bip_hd/__init__.py +++ b/mmgen/bip_hd/__init__.py @@ -24,7 +24,7 @@ from ..keygen import KeyGenerator, keygen_public_data from ..addrgen import AddrGenerator from ..addr import MMGenAddrType from ..key import PrivKey -from ..protocol import CoinProtocol +from ..protocol import CoinProtocol, init_proto from ..proto.btc.common import hash160, b58chk_encode, b58chk_decode from ..proto.secp256k1.secp256k1 import pubkey_tweak_add, pubkey_check @@ -379,9 +379,11 @@ class BipHDNode(Lockable): if path.pop(0) != 'm': raise ValueError(f'{path_str}: invalid path string (first component is not "m")') + proto = init_proto(base_cfg, coin or 'btc') + res = MasterNode(base_cfg, seed).init_cfg( - coin = coin or 'btc', - addr_type = addr_type or 'compressed', + coin = proto.coin, + addr_type = addr_type or proto.dfl_mmtype, no_path_checks = no_path_checks, from_path = True) diff --git a/test/modtest_d/bip_hd.py b/test/modtest_d/bip_hd.py index b5c72f75..48e2e5ee 100755 --- a/test/modtest_d/bip_hd.py +++ b/test/modtest_d/bip_hd.py @@ -143,7 +143,7 @@ vectors_multicoin = { 'doge': 'DFX88RXpi4S4W24YVvuMgbdUcCAYNeEYGd', 'avax-c': '0x373731f4d885Fc7Da05498F9f0804a87A14F891b', 'ltc_bech32': 'ltc1q3uh5ga5cp9kkdfx6a52uymxj9keq4tpzep7er0', - 'bch_compressed': 'bitcoincash:qpqpcllprftg4s0chdgkpxhxv23wfymq3gj7n0a9vw', + 'bch': 'bitcoincash:qpqpcllprftg4s0chdgkpxhxv23wfymq3gj7n0a9vw', 'bsc_smart': '0x373731f4d885Fc7Da05498F9f0804a87A14F891b', 'bnb_beacon': 'bnb179c3ymltqm4utlp089zxqeta5dvn48a305rhe5', 'rune': 'thor1nr6fye3nznyn20m5w6fey6w8a8l4q599cdqmpc',