From 8772335ecb0f7af8c090dece3ec1acf051016bd9 Mon Sep 17 00:00:00 2001 From: Joshua Infante Date: Fri, 21 Apr 2023 08:26:24 -0700 Subject: [PATCH 01/16] New Cryptocurrencies: Evrmore "EVR", Foxdcoin "FOXD", and Aviancoin "AVN" wallet protocols added. --- .gitignore | 2 + hdwallet/cryptocurrencies.py | 245 ++++++++++++++++++++++++++++++++++- hdwallet/symbols.py | 13 +- 3 files changed, 256 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 3c1a6c21..5d8f3a20 100644 --- a/.gitignore +++ b/.gitignore @@ -4,9 +4,11 @@ make.bat Makefile # Folders stuff +env/ experiment/ .idea/ .tox/ +.vs/ # Setuptools stuff build/ diff --git a/hdwallet/cryptocurrencies.py b/hdwallet/cryptocurrencies.py index ef24396a..8464bc19 100644 --- a/hdwallet/cryptocurrencies.py +++ b/hdwallet/cryptocurrencies.py @@ -354,6 +354,46 @@ class AuroracoinMainnet(Cryptocurrency): WIF_SECRET_KEY = 0x97 +class AviancoinMainnet(Cryptocurrency): + NAME = "Aviancoin" + SYMBOL = "AVN" + NETWORK = "mainnet" + SOURCE_CODE = "https://github.com/AvianNetwork/Avian" + COIN_TYPE = CoinType({ + "INDEX": 921, + "HARDENED": True + }) + + SCRIPT_ADDRESS = 0x7a + PUBLIC_KEY_ADDRESS = 0x3c + SEGWIT_ADDRESS = SegwitAddress({ + "HRP": None, + "VERSION": 0x00 + }) + + EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({ + "P2PKH": 0x488ade4, + "P2SH": 0x488ade4, + "P2WPKH": None, + "P2WPKH_IN_P2SH": None, + "P2WSH": None, + "P2WSH_IN_P2SH": None + }) + + EXTENDED_PUBLIC_KEY = ExtendedPublicKey({ + "P2PKH": 0x488b21e, + "P2SH": 0x488b21e, + "P2WPKH": None, + "P2WPKH_IN_P2SH": None, + "P2WSH": None, + "P2WSH_IN_P2SH": None + }) + + MESSAGE_PREFIX = "Aviancoin Signed Message:\n" + DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0" + WIF_SECRET_KEY = 0x80 + + class AxeMainnet(Cryptocurrency): NAME = "Axe" @@ -2154,6 +2194,88 @@ class EuropeCoinMainnet(Cryptocurrency): WIF_SECRET_KEY = 0xa8 +class EvrmoreMainnet(Cryptocurrency): + + NAME = "Evrmore" + SYMBOL = "EVR" + NETWORK = "mainnet" + SOURCE_CODE = "https://github.com/EvrmoreOrg/Evrmore" + COIN_TYPE = CoinType({ + "INDEX": 175, + "HARDENED": True + }) + + SCRIPT_ADDRESS = 0x5c + PUBLIC_KEY_ADDRESS = 0x21 + SEGWIT_ADDRESS = SegwitAddress({ + "HRP": None, + "VERSION": 0x00 + }) + + EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({ + "P2PKH": 0x488ade4, + "P2SH": 0x488ade4, + "P2WPKH": None, + "P2WPKH_IN_P2SH": None, + "P2WSH": None, + "P2WSH_IN_P2SH": None + }) + + EXTENDED_PUBLIC_KEY = ExtendedPublicKey({ + "P2PKH": 0x488b21e, + "P2SH": 0x488b21e, + "P2WPKH": None, + "P2WPKH_IN_P2SH": None, + "P2WSH": None, + "P2WSH_IN_P2SH": None + }) + + MESSAGE_PREFIX = "Evrmore Signed Message:\n" + DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0" + WIF_SECRET_KEY = 0x80 + + +class EvrmoreTestnet(Cryptocurrency): + + NAME = "Evrmore" + SYMBOL = "EVRTEST" + NETWORK = "testnet" + SOURCE_CODE = "https://github.com/EvrmoreOrg/Evrmore" + COIN_TYPE = CoinType({ + "INDEX": 1, + "HARDENED": True + }) + + SCRIPT_ADDRESS = 0xc4 + PUBLIC_KEY_ADDRESS = 0x6f + SEGWIT_ADDRESS = SegwitAddress({ + "HRP": None, + "VERSION": 0x00 + }) + + EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({ + "P2PKH": 0x04358394, + "P2SH": 0x04358394, + "P2WPKH": 0x04358394, + "P2WPKH_IN_P2SH": 0x04358394, + "P2WSH": 0x04358394, + "P2WSH_IN_P2SH": 0x04358394 + }) + + EXTENDED_PUBLIC_KEY = ExtendedPublicKey({ + "P2PKH": 0x043587cf, + "P2SH": 0x043587cf, + "P2WPKH": 0x043587cf, + "P2WPKH_IN_P2SH": 0x043587cf, + "P2WSH": 0x043587cf, + "P2WSH_IN_P2SH": 0x043587cf + }) + + MESSAGE_PREFIX = "Evrmore Signed Message:\n" + DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0" + WIF_SECRET_KEY = 0xef + + class ExclusiveCoinMainnet(Cryptocurrency): NAME = "Exclusive Coin" @@ -2431,6 +2553,89 @@ class FluxMainnet(Cryptocurrency): DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0" WIF_SECRET_KEY = 0x80 + +class FoxdcoinMainnet(Cryptocurrency): + + NAME = "Foxdcoin" + SYMBOL = "FOXD" + NETWORK = "mainnet" + SOURCE_CODE = "https://github.com/foxdproject/foxdcoin" + COIN_TYPE = CoinType({ + "INDEX": 175, + "HARDENED": True + }) + + SCRIPT_ADDRESS = 0x1e + PUBLIC_KEY_ADDRESS = 0x23 + SEGWIT_ADDRESS = SegwitAddress({ + "HRP": None, + "VERSION": 0x00 + }) + + EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({ + "P2PKH": 0x488ade4, + "P2SH": 0x488ade4, + "P2WPKH": None, + "P2WPKH_IN_P2SH": None, + "P2WSH": None, + "P2WSH_IN_P2SH": None + }) + + EXTENDED_PUBLIC_KEY = ExtendedPublicKey({ + "P2PKH": 0x488b21e, + "P2SH": 0x488b21e, + "P2WPKH": None, + "P2WPKH_IN_P2SH": None, + "P2WSH": None, + "P2WSH_IN_P2SH": None + }) + + MESSAGE_PREFIX = "Foxdcoin Signed Message:\n" + DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0" + WIF_SECRET_KEY = 0x80 + + +class FoxdcoinTestnet(Cryptocurrency): + + NAME = "Foxdcoin" + SYMBOL = "FOXDTEST" + NETWORK = "testnet" + SOURCE_CODE = "https://github.com/foxdproject/foxdcoin" + COIN_TYPE = CoinType({ + "INDEX": 1, + "HARDENED": True + }) + + SCRIPT_ADDRESS = 0x5a + PUBLIC_KEY_ADDRESS = 0x5f + SEGWIT_ADDRESS = SegwitAddress({ + "HRP": None, + "VERSION": 0x00 + }) + + EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({ + "P2PKH": 0x488ade4, + "P2SH": 0x488ade4, + "P2WPKH": 0x488ade4, + "P2WPKH_IN_P2SH": 0x488ade4, + "P2WSH": 0x488ade4, + "P2WSH_IN_P2SH": 0x488ade4 + }) + + EXTENDED_PUBLIC_KEY = ExtendedPublicKey({ + "P2PKH": 0x488b21e, + "P2SH": 0x488b21e, + "P2WPKH": 0x488b21e, + "P2WPKH_IN_P2SH": 0x488b21e, + "P2WSH": 0x488b21e, + "P2WSH_IN_P2SH": 0x488b21e + }) + + MESSAGE_PREFIX = "Foxdcoin Signed Message:\n" + DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0" + WIF_SECRET_KEY = 0xef + + class FujiCoinMainnet(Cryptocurrency): NAME = "Fuji Coin" @@ -4836,7 +5041,7 @@ class RavencoinMainnet(Cryptocurrency): NAME = "Ravencoin" SYMBOL = "RVN" NETWORK = "mainnet" - SOURCE_CODE = None + SOURCE_CODE = "https://github.com/RavenProject/Ravencoin" COIN_TYPE = CoinType({ "INDEX": 175, "HARDENED": True @@ -4866,11 +5071,47 @@ class RavencoinMainnet(Cryptocurrency): "P2WSH_IN_P2SH": None }) - MESSAGE_PREFIX = "Raven Signed Message:\n" + MESSAGE_PREFIX = "Raven Signed Message:\n" DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0" WIF_SECRET_KEY = 0x80 +class RavencoinTestnet(Cryptocurrency): + + NAME = "Ravencoin" + SYMBOL = "RVNTEST" + NETWORK = "testnet" + SOURCE_CODE = "https://github.com/RavenProject/Ravencoin" + COIN_TYPE = CoinType({ + "INDEX": 1, + "HARDENED": True + }) + + SCRIPT_ADDRESS = 0xc4 + PUBLIC_KEY_ADDRESS = 0x6f + SEGWIT_ADDRESS = SegwitAddress({ + "HRP": None, + "VERSION": 0x00 + }) + + EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({ + "P2PKH": 0x04358394, + "P2SH": 0x04358394, + "P2WPKH": 0x04358394, + "P2WPKH_IN_P2SH": 0x04358394, + "P2WSH": 0x04358394, + "P2WSH_IN_P2SH": 0x04358394 + }) + EXTENDED_PUBLIC_KEY = ExtendedPublicKey({ + "P2PKH": 0x043587cf, + "P2SH": 0x043587cf, + "P2WPKH": 0x043587cf, + "P2WPKH_IN_P2SH": 0x043587cf, + "P2WSH": 0x043587cf, + "P2WSH_IN_P2SH": 0x043587cf + }) + + class ReddcoinMainnet(Cryptocurrency): NAME = "Reddcoin" diff --git a/hdwallet/symbols.py b/hdwallet/symbols.py index 531f6ea1..e78d3790 100644 --- a/hdwallet/symbols.py +++ b/hdwallet/symbols.py @@ -14,6 +14,8 @@ ATOM = "ATOM" # Auroracoin AUR = "AUR" +# Aviancoin +AVN = "AVN" # Axe AXE = "AXE" # Bata @@ -96,6 +98,8 @@ ETH = "ETH" # Europe Coin ERC = "ERC" +# Evrmore +EVR, EVRTEST = "EVR", "EVRTEST" # Exclusive Coin EXCL = "EXCL" # FIX @@ -108,6 +112,8 @@ FLASH = "FLASH" # Flux FLUX = "FLUX" +# Foxdcoin +FOXD, FOXDTEST = "FOXD", "FOXDTEST" # Fuji Coin FJC = "FJC" # GCR Coin @@ -217,7 +223,7 @@ # Rapids RPD = "RPD" # Ravencoin -RVN = "RVN" +RVN, RVNTEST = "RVN", "RVNTEST" # Reddcoin RDD = "RDD" # Rubycoin @@ -296,6 +302,7 @@ "AC", "ATOM", "AUR", + "AVN", "AXE", "BTA", "BEET", @@ -337,12 +344,14 @@ "NRG", "ETH", "ERC", + "EVR", "EVRTEST", "EXCL", "FIX", "FIXTEST", "FLUX", "FTC", "FRST", "FLASH", + "FOXD", "FOXDTEST", "FJC", "GCR", "GAME", @@ -397,7 +406,7 @@ "QTUM", "QTUMTEST", "RBTC", "RBTCTEST", "RPD", - "RVN", + "RVN", "RVNTEST", "RDD", "RBY", "SAFE", From db16f3cfa361dde1c5f8813d74e494d3f89037ea Mon Sep 17 00:00:00 2001 From: Joshua Infante Date: Fri, 21 Apr 2023 08:26:24 -0700 Subject: [PATCH 02/16] New Cryptocurrencies: Evrmore "EVR", Foxdcoin "FOXD", and Aviancoin "AVN" wallet protocols added. --- hdwallet/cryptocurrencies.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hdwallet/cryptocurrencies.py b/hdwallet/cryptocurrencies.py index 8464bc19..89018b98 100644 --- a/hdwallet/cryptocurrencies.py +++ b/hdwallet/cryptocurrencies.py @@ -2625,10 +2625,10 @@ class FoxdcoinTestnet(Cryptocurrency): EXTENDED_PUBLIC_KEY = ExtendedPublicKey({ "P2PKH": 0x488b21e, "P2SH": 0x488b21e, - "P2WPKH": 0x488b21e, - "P2WPKH_IN_P2SH": 0x488b21e, - "P2WSH": 0x488b21e, - "P2WSH_IN_P2SH": 0x488b21e + "P2WPKH": None, + "P2WPKH_IN_P2SH": None, + "P2WSH": None, + "P2WSH_IN_P2SH": None }) MESSAGE_PREFIX = "Foxdcoin Signed Message:\n" From 5445ec144819cfaf16ef392755919171d0461eca Mon Sep 17 00:00:00 2001 From: Joshua Infante Date: Sat, 22 Apr 2023 04:53:41 -0700 Subject: [PATCH 03/16] Added p2wpkh, p2wsh, p2wpkh in p2sh, and p2wsh in p2sh to Ravencoin, Evrmore, Foxdcoin, and Aviancoin. --- hdwallet/cryptocurrencies.py | 155 +++++++++++++++++------------------ hdwallet/hdwallet.py | 10 ++- 2 files changed, 81 insertions(+), 84 deletions(-) diff --git a/hdwallet/cryptocurrencies.py b/hdwallet/cryptocurrencies.py index 89018b98..513ac645 100644 --- a/hdwallet/cryptocurrencies.py +++ b/hdwallet/cryptocurrencies.py @@ -367,26 +367,25 @@ class AviancoinMainnet(Cryptocurrency): SCRIPT_ADDRESS = 0x7a PUBLIC_KEY_ADDRESS = 0x3c SEGWIT_ADDRESS = SegwitAddress({ - "HRP": None, - "VERSION": 0x00 + "HRP": "av", + "VERSION": 0x29 }) EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({ "P2PKH": 0x488ade4, "P2SH": 0x488ade4, - "P2WPKH": None, - "P2WPKH_IN_P2SH": None, - "P2WSH": None, - "P2WSH_IN_P2SH": None + "P2WPKH": 0x04b2430c, + "P2WPKH_IN_P2SH": 0x049d7878, + "P2WSH": 0x02aa7a99, + "P2WSH_IN_P2SH": 0x0295b005 }) - EXTENDED_PUBLIC_KEY = ExtendedPublicKey({ "P2PKH": 0x488b21e, "P2SH": 0x488b21e, - "P2WPKH": None, - "P2WPKH_IN_P2SH": None, - "P2WSH": None, - "P2WSH_IN_P2SH": None + "P2WPKH": 0x04b24746, + "P2WPKH_IN_P2SH": 0x049d7cb2, + "P2WSH": 0x02aa7ed3, + "P2WSH_IN_P2SH": 0x0295b43f }) MESSAGE_PREFIX = "Aviancoin Signed Message:\n" @@ -2208,26 +2207,25 @@ class EvrmoreMainnet(Cryptocurrency): SCRIPT_ADDRESS = 0x5c PUBLIC_KEY_ADDRESS = 0x21 SEGWIT_ADDRESS = SegwitAddress({ - "HRP": None, - "VERSION": 0x00 + "HRP": "ev", + "VERSION": 0x18 }) EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({ "P2PKH": 0x488ade4, "P2SH": 0x488ade4, - "P2WPKH": None, - "P2WPKH_IN_P2SH": None, - "P2WSH": None, - "P2WSH_IN_P2SH": None + "P2WPKH": 0x04b2430c, + "P2WPKH_IN_P2SH": 0x049d7878, + "P2WSH": 0x02aa7a99, + "P2WSH_IN_P2SH": 0x0295b005 }) - EXTENDED_PUBLIC_KEY = ExtendedPublicKey({ "P2PKH": 0x488b21e, "P2SH": 0x488b21e, - "P2WPKH": None, - "P2WPKH_IN_P2SH": None, - "P2WSH": None, - "P2WSH_IN_P2SH": None + "P2WPKH": 0x04b24746, + "P2WPKH_IN_P2SH": 0x049d7cb2, + "P2WSH": 0x02aa7ed3, + "P2WSH_IN_P2SH": 0x0295b43f }) MESSAGE_PREFIX = "Evrmore Signed Message:\n" @@ -2249,26 +2247,25 @@ class EvrmoreTestnet(Cryptocurrency): SCRIPT_ADDRESS = 0xc4 PUBLIC_KEY_ADDRESS = 0x6f SEGWIT_ADDRESS = SegwitAddress({ - "HRP": None, + "HRP": "te", "VERSION": 0x00 }) EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({ - "P2PKH": 0x04358394, - "P2SH": 0x04358394, - "P2WPKH": 0x04358394, - "P2WPKH_IN_P2SH": 0x04358394, - "P2WSH": 0x04358394, - "P2WSH_IN_P2SH": 0x04358394 + "P2PKH": 0x488ade4, + "P2SH": 0x488ade4, + "P2WPKH": 0x04b2430c, + "P2WPKH_IN_P2SH": 0x049d7878, + "P2WSH": 0x02aa7a99, + "P2WSH_IN_P2SH": 0x0295b005 }) - EXTENDED_PUBLIC_KEY = ExtendedPublicKey({ - "P2PKH": 0x043587cf, - "P2SH": 0x043587cf, - "P2WPKH": 0x043587cf, - "P2WPKH_IN_P2SH": 0x043587cf, - "P2WSH": 0x043587cf, - "P2WSH_IN_P2SH": 0x043587cf + "P2PKH": 0x488b21e, + "P2SH": 0x488b21e, + "P2WPKH": 0x04b24746, + "P2WPKH_IN_P2SH": 0x049d7cb2, + "P2WSH": 0x02aa7ed3, + "P2WSH_IN_P2SH": 0x0295b43f }) MESSAGE_PREFIX = "Evrmore Signed Message:\n" @@ -2568,26 +2565,25 @@ class FoxdcoinMainnet(Cryptocurrency): SCRIPT_ADDRESS = 0x1e PUBLIC_KEY_ADDRESS = 0x23 SEGWIT_ADDRESS = SegwitAddress({ - "HRP": None, - "VERSION": 0x00 + "HRP": "fx", + "VERSION": 0x0c }) EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({ "P2PKH": 0x488ade4, "P2SH": 0x488ade4, - "P2WPKH": None, - "P2WPKH_IN_P2SH": None, - "P2WSH": None, - "P2WSH_IN_P2SH": None + "P2WPKH": 0x04b2430c, + "P2WPKH_IN_P2SH": 0x049d7878, + "P2WSH": 0x02aa7a99, + "P2WSH_IN_P2SH": 0x0295b005 }) - EXTENDED_PUBLIC_KEY = ExtendedPublicKey({ "P2PKH": 0x488b21e, "P2SH": 0x488b21e, - "P2WPKH": None, - "P2WPKH_IN_P2SH": None, - "P2WSH": None, - "P2WSH_IN_P2SH": None + "P2WPKH": 0x04b24746, + "P2WPKH_IN_P2SH": 0x049d7cb2, + "P2WSH": 0x02aa7ed3, + "P2WSH_IN_P2SH": 0x0295b43f }) MESSAGE_PREFIX = "Foxdcoin Signed Message:\n" @@ -2609,26 +2605,25 @@ class FoxdcoinTestnet(Cryptocurrency): SCRIPT_ADDRESS = 0x5a PUBLIC_KEY_ADDRESS = 0x5f SEGWIT_ADDRESS = SegwitAddress({ - "HRP": None, + "HRP": "tf", "VERSION": 0x00 }) EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({ "P2PKH": 0x488ade4, "P2SH": 0x488ade4, - "P2WPKH": 0x488ade4, - "P2WPKH_IN_P2SH": 0x488ade4, - "P2WSH": 0x488ade4, - "P2WSH_IN_P2SH": 0x488ade4 + "P2WPKH": 0x04b2430c, + "P2WPKH_IN_P2SH": 0x049d7878, + "P2WSH": 0x02aa7a99, + "P2WSH_IN_P2SH": 0x0295b005 }) - EXTENDED_PUBLIC_KEY = ExtendedPublicKey({ "P2PKH": 0x488b21e, "P2SH": 0x488b21e, - "P2WPKH": None, - "P2WPKH_IN_P2SH": None, - "P2WSH": None, - "P2WSH_IN_P2SH": None + "P2WPKH": 0x04b24746, + "P2WPKH_IN_P2SH": 0x049d7cb2, + "P2WSH": 0x02aa7ed3, + "P2WSH_IN_P2SH": 0x0295b43f }) MESSAGE_PREFIX = "Foxdcoin Signed Message:\n" @@ -5050,25 +5045,25 @@ class RavencoinMainnet(Cryptocurrency): SCRIPT_ADDRESS = 0x7a PUBLIC_KEY_ADDRESS = 0x3c SEGWIT_ADDRESS = SegwitAddress({ - "HRP": None, - "VERSION": 0x00 + "HRP": "rv", + "VERSION": 0x15 }) EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({ "P2PKH": 0x488ade4, "P2SH": 0x488ade4, - "P2WPKH": None, - "P2WPKH_IN_P2SH": None, - "P2WSH": None, - "P2WSH_IN_P2SH": None + "P2WPKH": 0x04b2430c, + "P2WPKH_IN_P2SH": 0x049d7878, + "P2WSH": 0x02aa7a99, + "P2WSH_IN_P2SH": 0x0295b005 }) EXTENDED_PUBLIC_KEY = ExtendedPublicKey({ "P2PKH": 0x488b21e, "P2SH": 0x488b21e, - "P2WPKH": None, - "P2WPKH_IN_P2SH": None, - "P2WSH": None, - "P2WSH_IN_P2SH": None + "P2WPKH": 0x04b24746, + "P2WPKH_IN_P2SH": 0x049d7cb2, + "P2WSH": 0x02aa7ed3, + "P2WSH_IN_P2SH": 0x0295b43f }) MESSAGE_PREFIX = "Raven Signed Message:\n" @@ -5090,25 +5085,25 @@ class RavencoinTestnet(Cryptocurrency): SCRIPT_ADDRESS = 0xc4 PUBLIC_KEY_ADDRESS = 0x6f SEGWIT_ADDRESS = SegwitAddress({ - "HRP": None, + "HRP": "tr", "VERSION": 0x00 }) EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({ - "P2PKH": 0x04358394, - "P2SH": 0x04358394, - "P2WPKH": 0x04358394, - "P2WPKH_IN_P2SH": 0x04358394, - "P2WSH": 0x04358394, - "P2WSH_IN_P2SH": 0x04358394 + "P2PKH": 0x488ade4, + "P2SH": 0x488ade4, + "P2WPKH": 0x04b2430c, + "P2WPKH_IN_P2SH": 0x049d7878, + "P2WSH": 0x02aa7a99, + "P2WSH_IN_P2SH": 0x0295b005 }) EXTENDED_PUBLIC_KEY = ExtendedPublicKey({ - "P2PKH": 0x043587cf, - "P2SH": 0x043587cf, - "P2WPKH": 0x043587cf, - "P2WPKH_IN_P2SH": 0x043587cf, - "P2WSH": 0x043587cf, - "P2WSH_IN_P2SH": 0x043587cf + "P2PKH": 0x488b21e, + "P2SH": 0x488b21e, + "P2WPKH": 0x04b24746, + "P2WPKH_IN_P2SH": 0x049d7cb2, + "P2WSH": 0x02aa7ed3, + "P2WSH_IN_P2SH": 0x0295b43f }) diff --git a/hdwallet/hdwallet.py b/hdwallet/hdwallet.py index 1592fb80..a66ac84d 100644 --- a/hdwallet/hdwallet.py +++ b/hdwallet/hdwallet.py @@ -1196,9 +1196,10 @@ def p2wpkh_address(self) -> Optional[str]: compressed_public_key = unhexlify(self.compressed()) public_key_hash = ripemd160(sha256(compressed_public_key).digest()) - if self._cryptocurrency.SEGWIT_ADDRESS.HRP is None: + segwit = self._cryptocurrency.SEGWIT_ADDRESS + if segwit.HRP is None: return None - return ensure_string(encode(self._cryptocurrency.SEGWIT_ADDRESS.HRP, 0, public_key_hash)) + return ensure_string(encode(segwit.HRP, segwit.VERSION, public_key_hash)) def p2wpkh_in_p2sh_address(self) -> Optional[str]: """ @@ -1240,9 +1241,10 @@ def p2wsh_address(self) -> Optional[str]: compressed_public_key = unhexlify("5121" + self.compressed() + "51ae") script_hash = sha256(compressed_public_key).digest() - if self._cryptocurrency.SEGWIT_ADDRESS.HRP is None: + segwit = self._cryptocurrency.SEGWIT_ADDRESS + if segwit.HRP is None: return None - return ensure_string(encode(self._cryptocurrency.SEGWIT_ADDRESS.HRP, 0, script_hash)) + return ensure_string(encode(segwit.HRP, segwit.VERSION, script_hash)) def p2wsh_in_p2sh_address(self) -> Optional[str]: """ From a4fd87487f4d2deda475133b224d6ec347270ce5 Mon Sep 17 00:00:00 2001 From: Joshua Infante Date: Sat, 22 Apr 2023 05:24:31 -0700 Subject: [PATCH 04/16] fixed a bug with segwit addresses --- hdwallet/cryptocurrencies.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hdwallet/cryptocurrencies.py b/hdwallet/cryptocurrencies.py index 513ac645..a1aeccbe 100644 --- a/hdwallet/cryptocurrencies.py +++ b/hdwallet/cryptocurrencies.py @@ -368,7 +368,7 @@ class AviancoinMainnet(Cryptocurrency): PUBLIC_KEY_ADDRESS = 0x3c SEGWIT_ADDRESS = SegwitAddress({ "HRP": "av", - "VERSION": 0x29 + "VERSION": 0x0d }) EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({ @@ -2208,7 +2208,7 @@ class EvrmoreMainnet(Cryptocurrency): PUBLIC_KEY_ADDRESS = 0x21 SEGWIT_ADDRESS = SegwitAddress({ "HRP": "ev", - "VERSION": 0x18 + "VERSION": 0x0b }) EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({ @@ -5046,7 +5046,7 @@ class RavencoinMainnet(Cryptocurrency): PUBLIC_KEY_ADDRESS = 0x3c SEGWIT_ADDRESS = SegwitAddress({ "HRP": "rv", - "VERSION": 0x15 + "VERSION": 0x0a }) EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({ From a94af4a6f0bcb927d740bcec245763f8b2bde41a Mon Sep 17 00:00:00 2001 From: Joshua Infante <38098280+git-infinianti@users.noreply.github.com> Date: Tue, 25 Apr 2023 06:29:56 -0700 Subject: [PATCH 05/16] Changed prefixes for Ravencoin and Foxdcoin New prefixes are ra1v for Ravencoin and fx1d for Foxdcoin. --- hdwallet/cryptocurrencies.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hdwallet/cryptocurrencies.py b/hdwallet/cryptocurrencies.py index a1aeccbe..f36584de 100644 --- a/hdwallet/cryptocurrencies.py +++ b/hdwallet/cryptocurrencies.py @@ -2566,7 +2566,7 @@ class FoxdcoinMainnet(Cryptocurrency): PUBLIC_KEY_ADDRESS = 0x23 SEGWIT_ADDRESS = SegwitAddress({ "HRP": "fx", - "VERSION": 0x0c + "VERSION": 0x0d }) EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({ @@ -5045,8 +5045,8 @@ class RavencoinMainnet(Cryptocurrency): SCRIPT_ADDRESS = 0x7a PUBLIC_KEY_ADDRESS = 0x3c SEGWIT_ADDRESS = SegwitAddress({ - "HRP": "rv", - "VERSION": 0x0a + "HRP": "ra", + "VERSION": 0x0c }) EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({ From e03b564cb16e82ce6ec7ed8038592056bc919077 Mon Sep 17 00:00:00 2001 From: joxerx Date: Fri, 11 Aug 2023 16:01:25 +0300 Subject: [PATCH 06/16] Add BNB Smart Chain support --- hdwallet/cryptocurrencies.py | 40 ++++++++++++++++++++++++++++++++++++ hdwallet/symbols.py | 2 ++ 2 files changed, 42 insertions(+) diff --git a/hdwallet/cryptocurrencies.py b/hdwallet/cryptocurrencies.py index f36584de..a2fbf68a 100644 --- a/hdwallet/cryptocurrencies.py +++ b/hdwallet/cryptocurrencies.py @@ -2153,6 +2153,46 @@ class EthereumMainnet(Cryptocurrency): WIF_SECRET_KEY = 0x80 +class BinanceSmartChainMainnet(Cryptocurrency): + + NAME = "Binance Smart Chain" + SYMBOL = "BSC" + NETWORK = "mainnet" + SOURCE_CODE = "https://github.com/bnb-chain/bsc" + COIN_TYPE = CoinType({ + "INDEX": 9006, + "HARDENED": True + }) + + SCRIPT_ADDRESS = 0x05 + PUBLIC_KEY_ADDRESS = 0x00 + SEGWIT_ADDRESS = SegwitAddress({ + "HRP": "bc", + "VERSION": 0x00 + }) + + EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({ + "P2PKH": 0x0488ade4, + "P2SH": 0x0488ade4, + "P2WPKH": 0x04b2430c, + "P2WPKH_IN_P2SH": 0x049d7878, + "P2WSH": 0x02aa7a99, + "P2WSH_IN_P2SH": 0x0295b005 + }) + EXTENDED_PUBLIC_KEY = ExtendedPublicKey({ + "P2PKH": 0x0488b21e, + "P2SH": 0x0488b21e, + "P2WPKH": 0x04b24746, + "P2WPKH_IN_P2SH": 0x049d7cb2, + "P2WSH": 0x02aa7ed3, + "P2WSH_IN_P2SH": 0x0295b43f + }) + + MESSAGE_PREFIX = None + DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0" + WIF_SECRET_KEY = 0x80 + + class EuropeCoinMainnet(Cryptocurrency): NAME = "Europe Coin" diff --git a/hdwallet/symbols.py b/hdwallet/symbols.py index e78d3790..b712c266 100644 --- a/hdwallet/symbols.py +++ b/hdwallet/symbols.py @@ -28,6 +28,8 @@ BTDX = "BTDX" # Bit Send BSD = "BSD" +# BNB Smart Chain +BSC = "BSC" # Bitcoin Cash BCH = "BCH" # Bitcoin Gold From 13020226e75713386dfc0d00e48b2a8453fd548f Mon Sep 17 00:00:00 2001 From: joxerx Date: Fri, 11 Aug 2023 16:15:03 +0300 Subject: [PATCH 07/16] Add Polygon support --- hdwallet/cryptocurrencies.py | 40 ++++++++++++++++++++++++++++++++++++ hdwallet/symbols.py | 4 ++++ 2 files changed, 44 insertions(+) diff --git a/hdwallet/cryptocurrencies.py b/hdwallet/cryptocurrencies.py index a2fbf68a..fde0981d 100644 --- a/hdwallet/cryptocurrencies.py +++ b/hdwallet/cryptocurrencies.py @@ -2193,6 +2193,46 @@ class BinanceSmartChainMainnet(Cryptocurrency): WIF_SECRET_KEY = 0x80 +class PolygonMainnet(Cryptocurrency): + + NAME = "Polygon" + SYMBOL = "MATIC" + NETWORK = "mainnet" + SOURCE_CODE = "https://github.com/bnb-chain/bsc" + COIN_TYPE = CoinType({ + "INDEX": 966, + "HARDENED": True + }) + + SCRIPT_ADDRESS = 0x05 + PUBLIC_KEY_ADDRESS = 0x00 + SEGWIT_ADDRESS = SegwitAddress({ + "HRP": "bc", + "VERSION": 0x00 + }) + + EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({ + "P2PKH": 0x0488ade4, + "P2SH": 0x0488ade4, + "P2WPKH": 0x04b2430c, + "P2WPKH_IN_P2SH": 0x049d7878, + "P2WSH": 0x02aa7a99, + "P2WSH_IN_P2SH": 0x0295b005 + }) + EXTENDED_PUBLIC_KEY = ExtendedPublicKey({ + "P2PKH": 0x0488b21e, + "P2SH": 0x0488b21e, + "P2WPKH": 0x04b24746, + "P2WPKH_IN_P2SH": 0x049d7cb2, + "P2WSH": 0x02aa7ed3, + "P2WSH_IN_P2SH": 0x0295b43f + }) + + MESSAGE_PREFIX = None + DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0" + WIF_SECRET_KEY = 0x80 + + class EuropeCoinMainnet(Cryptocurrency): NAME = "Europe Coin" diff --git a/hdwallet/symbols.py b/hdwallet/symbols.py index b712c266..5a30ff27 100644 --- a/hdwallet/symbols.py +++ b/hdwallet/symbols.py @@ -162,6 +162,8 @@ LKR = "LKR" # Lynx LYNX = "LYNX" +# Polygon +MATIC = "MATIC" # Mazacoin MZC = "MZC" # Megacoin @@ -312,6 +314,7 @@ "BTDX", "BSD", "BCH", + "BSC", "BTG", "BTC", "BTCTEST", "XBC", @@ -381,6 +384,7 @@ "MEC", "MNX", "MONA", + "MATIC", "MONK", "XMY", "NIX", From 06da0b4be751d445bc6ad7c0285c758ece4bf4b7 Mon Sep 17 00:00:00 2001 From: joxerx Date: Fri, 11 Aug 2023 16:30:25 +0300 Subject: [PATCH 08/16] Add Arbitrum support --- hdwallet/cryptocurrencies.py | 40 ++++++++++++++++++++++++++++++++++++ hdwallet/symbols.py | 3 +++ 2 files changed, 43 insertions(+) diff --git a/hdwallet/cryptocurrencies.py b/hdwallet/cryptocurrencies.py index fde0981d..8837c880 100644 --- a/hdwallet/cryptocurrencies.py +++ b/hdwallet/cryptocurrencies.py @@ -2233,6 +2233,46 @@ class PolygonMainnet(Cryptocurrency): WIF_SECRET_KEY = 0x80 +class ArbitrumMainnet(Cryptocurrency): + + NAME = "Arbitrum" + SYMBOL = "ARB1" + NETWORK = "mainnet" + SOURCE_CODE = "https://github.com/bnb-chain/bsc" + COIN_TYPE = CoinType({ + "INDEX": 9001, + "HARDENED": True + }) + + SCRIPT_ADDRESS = 0x05 + PUBLIC_KEY_ADDRESS = 0x00 + SEGWIT_ADDRESS = SegwitAddress({ + "HRP": "bc", + "VERSION": 0x00 + }) + + EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({ + "P2PKH": 0x0488ade4, + "P2SH": 0x0488ade4, + "P2WPKH": 0x04b2430c, + "P2WPKH_IN_P2SH": 0x049d7878, + "P2WSH": 0x02aa7a99, + "P2WSH_IN_P2SH": 0x0295b005 + }) + EXTENDED_PUBLIC_KEY = ExtendedPublicKey({ + "P2PKH": 0x0488b21e, + "P2SH": 0x0488b21e, + "P2WPKH": 0x04b24746, + "P2WPKH_IN_P2SH": 0x049d7cb2, + "P2WSH": 0x02aa7ed3, + "P2WSH_IN_P2SH": 0x0295b43f + }) + + MESSAGE_PREFIX = None + DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0" + WIF_SECRET_KEY = 0x80 + + class EuropeCoinMainnet(Cryptocurrency): NAME = "Europe Coin" diff --git a/hdwallet/symbols.py b/hdwallet/symbols.py index 5a30ff27..306449fe 100644 --- a/hdwallet/symbols.py +++ b/hdwallet/symbols.py @@ -164,6 +164,8 @@ LYNX = "LYNX" # Polygon MATIC = "MATIC" +# Arbitrum +ARB1 = "ARB1" # Mazacoin MZC = "MZC" # Megacoin @@ -301,6 +303,7 @@ __all__ = [ "ANON", "AGM", + "ARB1", "XAX", "AYA", "AC", From c5b26c32ffcb847ec8dde3313c3352b247638f3c Mon Sep 17 00:00:00 2001 From: joxerx Date: Fri, 11 Aug 2023 16:34:54 +0300 Subject: [PATCH 09/16] Add zkSync support --- hdwallet/cryptocurrencies.py | 40 ++++++++++++++++++++++++++++++++++++ hdwallet/symbols.py | 3 +++ 2 files changed, 43 insertions(+) diff --git a/hdwallet/cryptocurrencies.py b/hdwallet/cryptocurrencies.py index 8837c880..1000d3c8 100644 --- a/hdwallet/cryptocurrencies.py +++ b/hdwallet/cryptocurrencies.py @@ -2273,6 +2273,46 @@ class ArbitrumMainnet(Cryptocurrency): WIF_SECRET_KEY = 0x80 +class zkSyncMainnet(Cryptocurrency): + + NAME = "zkSync" + SYMBOL = "ZKS" + NETWORK = "mainnet" + SOURCE_CODE = "https://github.com/bnb-chain/bsc" + COIN_TYPE = CoinType({ + "INDEX": 324, + "HARDENED": True + }) + + SCRIPT_ADDRESS = 0x05 + PUBLIC_KEY_ADDRESS = 0x00 + SEGWIT_ADDRESS = SegwitAddress({ + "HRP": "bc", + "VERSION": 0x00 + }) + + EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({ + "P2PKH": 0x0488ade4, + "P2SH": 0x0488ade4, + "P2WPKH": 0x04b2430c, + "P2WPKH_IN_P2SH": 0x049d7878, + "P2WSH": 0x02aa7a99, + "P2WSH_IN_P2SH": 0x0295b005 + }) + EXTENDED_PUBLIC_KEY = ExtendedPublicKey({ + "P2PKH": 0x0488b21e, + "P2SH": 0x0488b21e, + "P2WPKH": 0x04b24746, + "P2WPKH_IN_P2SH": 0x049d7cb2, + "P2WSH": 0x02aa7ed3, + "P2WSH_IN_P2SH": 0x0295b43f + }) + + MESSAGE_PREFIX = None + DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0" + WIF_SECRET_KEY = 0x80 + + class EuropeCoinMainnet(Cryptocurrency): NAME = "Europe Coin" diff --git a/hdwallet/symbols.py b/hdwallet/symbols.py index 306449fe..91999ca2 100644 --- a/hdwallet/symbols.py +++ b/hdwallet/symbols.py @@ -298,12 +298,15 @@ ZEC, ZECTEST = "ZEC", "ZECTEST" # Zencash ZEN = "ZEN" +# zkSync +ZKS = "ZKS" __all__ = [ "ANON", "AGM", "ARB1", + "ZKS", "XAX", "AYA", "AC", From 88191937a6870449a2a121299adef035d5d9fd78 Mon Sep 17 00:00:00 2001 From: joxerx Date: Fri, 11 Aug 2023 16:46:05 +0300 Subject: [PATCH 10/16] Add Linea support --- hdwallet/cryptocurrencies.py | 42 +++++++++++++++++++++++++++++++++++- hdwallet/symbols.py | 3 +++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/hdwallet/cryptocurrencies.py b/hdwallet/cryptocurrencies.py index 1000d3c8..aa8a83df 100644 --- a/hdwallet/cryptocurrencies.py +++ b/hdwallet/cryptocurrencies.py @@ -2280,7 +2280,47 @@ class zkSyncMainnet(Cryptocurrency): NETWORK = "mainnet" SOURCE_CODE = "https://github.com/bnb-chain/bsc" COIN_TYPE = CoinType({ - "INDEX": 324, + "INDEX": 804, + "HARDENED": True + }) + + SCRIPT_ADDRESS = 0x05 + PUBLIC_KEY_ADDRESS = 0x00 + SEGWIT_ADDRESS = SegwitAddress({ + "HRP": "bc", + "VERSION": 0x00 + }) + + EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({ + "P2PKH": 0x0488ade4, + "P2SH": 0x0488ade4, + "P2WPKH": 0x04b2430c, + "P2WPKH_IN_P2SH": 0x049d7878, + "P2WSH": 0x02aa7a99, + "P2WSH_IN_P2SH": 0x0295b005 + }) + EXTENDED_PUBLIC_KEY = ExtendedPublicKey({ + "P2PKH": 0x0488b21e, + "P2SH": 0x0488b21e, + "P2WPKH": 0x04b24746, + "P2WPKH_IN_P2SH": 0x049d7cb2, + "P2WSH": 0x02aa7ed3, + "P2WSH_IN_P2SH": 0x0295b43f + }) + + MESSAGE_PREFIX = None + DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0" + WIF_SECRET_KEY = 0x80 + + +class LineaMainnet(Cryptocurrency): + + NAME = "Linea" + SYMBOL = "LINEA" + NETWORK = "mainnet" + SOURCE_CODE = "https://github.com/bnb-chain/bsc" + COIN_TYPE = CoinType({ + "INDEX": 59144, "HARDENED": True }) diff --git a/hdwallet/symbols.py b/hdwallet/symbols.py index 91999ca2..5fc4c06d 100644 --- a/hdwallet/symbols.py +++ b/hdwallet/symbols.py @@ -300,11 +300,14 @@ ZEN = "ZEN" # zkSync ZKS = "ZKS" +# Linea +LINEA = "LINEA" __all__ = [ "ANON", "AGM", + "LINEA", "ARB1", "ZKS", "XAX", From b7cf337b9f90a04118759b269d30fc6b03c5e4f8 Mon Sep 17 00:00:00 2001 From: Chun Date: Mon, 21 Aug 2023 11:14:35 +0100 Subject: [PATCH 11/16] Update derivations.py --- hdwallet/derivations.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hdwallet/derivations.py b/hdwallet/derivations.py index b34a6d4a..c7d290d3 100644 --- a/hdwallet/derivations.py +++ b/hdwallet/derivations.py @@ -67,7 +67,7 @@ def from_path(cls, path: str) -> "Derivation": >>> from hdwallet.derivations import Derivation >>> derivation = Derivation() - >>> derivation.from_path(path="m/44'/0'/'0/0/0") + >>> derivation.from_path(path="m/44'/0'/0'/0/0") """ @@ -123,9 +123,9 @@ def clean_derivation(self) -> "Derivation": >>> from hdwallet.derivations import Derivation >>> derivation = Derivation() - >>> derivation.from_path(path="m/44'/0'/'0/0/0") + >>> derivation.from_path(path="m/44'/0'/0'/0/0") >>> str(derivation) - "m/44'/0'/'0/0/0" + "m/44'/0'/0'/0/0" >>> derivation.clean_derivation() >>> str(derivation) From 196f24a145af3cf8901b5cdf4f87f6b6d3040085 Mon Sep 17 00:00:00 2001 From: Chun Date: Mon, 21 Aug 2023 11:15:35 +0100 Subject: [PATCH 12/16] Update hdwallet.py --- hdwallet/hdwallet.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hdwallet/hdwallet.py b/hdwallet/hdwallet.py index a66ac84d..8b12dcb8 100644 --- a/hdwallet/hdwallet.py +++ b/hdwallet/hdwallet.py @@ -437,7 +437,7 @@ def from_path(self, path: Union[str, Derivation]) -> "HDWallet": >>> from hdwallet.symbols import BTC >>> hdwallet = HDWallet(symbol=BTC) >>> hdwallet.from_xprivate_key(xprivate_key="xprv9s21ZrQH143K3xPGUzpogJeKtRdjHkK6muBJo8v7rEVRzT83xJgNcLpMoJXUf9wJFKfuHR4SGvfgdShh4t9VmjjrE9usBunK3LfNna31LGF") - >>> hdwallet.from_path(path="m/44'/0'/'0/0/0") + >>> hdwallet.from_path(path="m/44'/0'/0'/0/0") """ @@ -598,7 +598,7 @@ def root_xprivate_key(self, encoded: bool = True) -> Optional[str]: >>> from hdwallet.symbols import BTC >>> hdwallet = HDWallet(symbol=BTC) >>> hdwallet.from_entropy(entropy="ee535b143b0d9d1f87546f9df0d06b1a") - >>> hdwallet.from_path(path="m/44'/0'/'0/0/0") + >>> hdwallet.from_path(path="m/44'/0'/0'/0/0") >>> hdwallet.root_xprivate_key() "xprv9s21ZrQH143K3xPGUzpogJeKtRdjHkK6muBJo8v7rEVRzT83xJgNcLpMoJXUf9wJFKfuHR4SGvfgdShh4t9VmjjrE9usBunK3LfNna31LGF" """ @@ -636,7 +636,7 @@ def root_xpublic_key(self, encoded: bool = True) -> Optional[str]: >>> from hdwallet.symbols import BTC >>> hdwallet = HDWallet(symbol=BTC) >>> hdwallet.from_entropy(entropy="ee535b143b0d9d1f87546f9df0d06b1a") - >>> hdwallet.from_path(path="m/44'/0'/'0/0/0") + >>> hdwallet.from_path(path="m/44'/0'/0'/0/0") >>> hdwallet.root_xpublic_key() "xpub661MyMwAqRbcGSTjb2Mp3Sb4STUDhD2x986ubXKjQa2QsFTCVqzdA98qeZjcncHT1AaZcMSjiP1HJ16jH97q72RwyFfiNhmG8zQ6KBB5PaQ" """ @@ -679,7 +679,7 @@ def xprivate_key(self, encoded=True) -> Optional[str]: >>> from hdwallet.symbols import BTC >>> hdwallet = HDWallet(symbol=BTC) >>> hdwallet.from_entropy(entropy="ee535b143b0d9d1f87546f9df0d06b1a") - >>> hdwallet.from_path(path="m/44'/0'/'0/0/0") + >>> hdwallet.from_path(path="m/44'/0'/0'/0/0") >>> hdwallet.xprivate_key() "xprvA3BYGWQ9FmhyaNRRXB2f1LphNPnaY9T6gngw4BaTbkFtscSH4RCuJhgWUSKs9S6ciGioHd4TX4UeyUg53MkfN9Xh38xkS1j2Wb9YKsYpJHQ" """ @@ -717,7 +717,7 @@ def xpublic_key(self, encoded: bool = True) -> Optional[str]: >>> from hdwallet.symbols import BTC >>> hdwallet = HDWallet(symbol=BTC) >>> hdwallet.from_entropy(entropy="ee535b143b0d9d1f87546f9df0d06b1a") - >>> hdwallet.from_path(path="m/44'/0'/'0/0/0") + >>> hdwallet.from_path(path="m/44'/0'/0'/0/0") >>> hdwallet.xpublic_key() "xpub6GAtg1w369GGnrVtdCZfNUmRvRd4wcAx41cXrZz5A5nskQmRbxX9rVzzKiRU4JruirBrfm4KQXNSU7GfqL1tzZWpZYe9Zo4xKGJYohWoQe7" """ @@ -750,9 +750,9 @@ def clean_derivation(self) -> "HDWallet": >>> from hdwallet.symbols import BTC >>> hdwallet = HDWallet(symbol=BTC) >>> hdwallet.from_xprivate_key(xprivate_key="xprv9s21ZrQH143K3xPGUzpogJeKtRdjHkK6muBJo8v7rEVRzT83xJgNcLpMoJXUf9wJFKfuHR4SGvfgdShh4t9VmjjrE9usBunK3LfNna31LGF") - >>> hdwallet.from_path(path="m/44'/0'/'0/0/0") + >>> hdwallet.from_path(path="m/44'/0'/0'/0/0") >>> hdwallet.path() - "m/44'/0'/'0/0/0" + "m/44'/0'/0'/0/0" >>> hdwallet.clean_derivation() >>> hdwallet.path() From eb0ae829e3454be6a077eed02eef64f366509cd6 Mon Sep 17 00:00:00 2001 From: Chief Zach <59001347+Chief-Zach@users.noreply.github.com> Date: Sat, 3 Jun 2023 01:01:01 -0400 Subject: [PATCH 13/16] Update hdwallet.py Hardened key by index is not returned. Added return statement --- hdwallet/hdwallet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hdwallet/hdwallet.py b/hdwallet/hdwallet.py index 8b12dcb8..a08fec07 100644 --- a/hdwallet/hdwallet.py +++ b/hdwallet/hdwallet.py @@ -483,7 +483,7 @@ def from_index(self, index: int, hardened: bool = False) -> "HDWallet": if hardened: self._path += ("/%d'" % index) - self._derive_key_by_index(index + BIP32KEY_HARDEN) + return self._derive_key_by_index(index + BIP32KEY_HARDEN) else: self._path += ("/%d" % index) return self._derive_key_by_index(index) From 76d9cb17df46192177e8ac8ae592e7b2982cbd3e Mon Sep 17 00:00:00 2001 From: Perry Kundert Date: Mon, 4 Nov 2024 17:20:01 -0700 Subject: [PATCH 14/16] Update requirements, packaging --- .gitignore | 2 ++ GNUmakefile | 39 ++++++++++++++++---------- MANIFEST.in | 3 +- default.nix | 62 ++++++++++++++++++++++++++++++++++++++++++ hdwallet/__init__.py | 6 +++- hdwallet/version.py | 2 ++ nixpkgs.nix | 4 +++ requirements-cli.txt | 3 ++ requirements-dev.txt | 4 +++ requirements-docs.txt | 3 ++ requirements-tests.txt | 3 ++ requirements.txt | 8 +++--- setup.py | 46 +++++++++++++++---------------- shell.nix | 19 +++++++++++++ 14 files changed, 159 insertions(+), 45 deletions(-) create mode 100644 default.nix create mode 100644 hdwallet/version.py create mode 100644 nixpkgs.nix create mode 100644 requirements-cli.txt create mode 100644 requirements-dev.txt create mode 100644 requirements-docs.txt create mode 100644 requirements-tests.txt create mode 100644 shell.nix diff --git a/.gitignore b/.gitignore index 5d8f3a20..022fb51b 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,5 @@ __pycache__/ # py.test stuff .pytest_cache/ +*~ +.#* diff --git a/GNUmakefile b/GNUmakefile index 73be7d4c..3b423f5e 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,10 +1,17 @@ SHELL = /bin/bash PY3 ?= $(shell python3 --version >/dev/null 2>&1 && echo python3 || echo python ) -VERSION = $(shell $(PY3) -c 'from hdwallet import __version__; print( __version__.strip("v"))') +PY3_V = $(shell $(PY3) -c "import sys; print('-'.join((next(iter(filter(None,sys.executable.split('/')))),sys.platform,sys.implementation.cache_tag)))" 2>/dev/null ) +VERSION = $(shell $(PY3) -c 'exec(open("hdwallet/version.py", "r").read()); print( __version__.strip("v"))') WHEEL = dist/hdwallet-$(VERSION)-py3-none-any.whl PY3TEST = $(PY3) -m pytest +GHUB_NAME = python-hdwallet +VENV_DIR = $(abspath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/.. ) +VENV_NAME = $(GHUB_NAME)-$(VERSION)-$(PY3_V) +VENV = $(VENV_DIR)/$(VENV_NAME) +VENV_OPTS = + .PHONY: all test build build-check wheel install-dev install clean FORCE all: build @@ -19,28 +26,30 @@ test-%: unit-%: $(PY3TEST) -k $* -build: clean wheel +nix-%: + nix-shell --pure --run "make $*" -build-check: - @$(PY3) -m build --version \ - || ( \ - echo -e "\n\n!!! Missing Python modules; run:"; \ - echo -e "\n\n $(PY3) -m pip install --upgrade pip setuptools wheel build\n"; \ - false; \ - ) +build: clean wheel wheel: $(WHEEL) -$(WHEEL): build-check FORCE +$(WHEEL): FORCE + $(PY3) -m pip install -r requirements-dev.txt $(PY3) -m build @ls -last dist -# Install from wheel, including all optional extra dependencies (except dev) -install-dev: $(WHEEL) FORCE - $(PY3) -m pip install --upgrade $<[tests] - install: $(WHEEL) FORCE - $(PY3) -m pip install --force-reinstall $<[cli,docs] + $(PY3) -m pip install --force-reinstall .[cli,docs] clean: @rm -rf build dist *.egg-info $(shell find . -name '__pycache__' ) + +venv: $(VENV) + @echo; echo "*** Activating $< VirtualEnv for Interactive $(SHELL)" + @bash --init-file $=8.1.3,<9 +click-aliases >=1.0.1,<2 +tabulate >=0.9.0,<1 diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 00000000..bc210ece --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,4 @@ +build +packaging +setuptools +wheel diff --git a/requirements-docs.txt b/requirements-docs.txt new file mode 100644 index 00000000..c77b2466 --- /dev/null +++ b/requirements-docs.txt @@ -0,0 +1,3 @@ +sphinx >=5.3.0,<6 +furo ==2022.12.7 +sphinx-click >=4.4.0,<5 diff --git a/requirements-tests.txt b/requirements-tests.txt new file mode 100644 index 00000000..7f50a1f2 --- /dev/null +++ b/requirements-tests.txt @@ -0,0 +1,3 @@ +pytest >=7.2.0,<8 +pytest-cov >=4.0.0,<5 +tox ==3.28.0 diff --git a/requirements.txt b/requirements.txt index 5887f801..ad551687 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -ecdsa>=0.13,<1 -mnemonic>=0.19,<1 -pycryptodome>=3.15,<4 -base58>=2.0.1,<3 +ecdsa >=0.19.0,<1 +mnemonic >=0.21,<1 +pycryptodome >=3.21,<4 +base58 >=2.1.1,<3 diff --git a/setup.py b/setup.py index 728237b7..476f4651 100644 --- a/setup.py +++ b/setup.py @@ -11,16 +11,27 @@ } # README.md -with open("README.md", "r", encoding="utf-8") as readme: +with open( "README.md", "r", encoding="utf-8") as readme: long_description: str = readme.read() - -# requirements.txt -with open("requirements.txt", "r") as _requirements: - requirements: list = list(map(str.strip, _requirements.read().split("\n"))) +with open( "requirements.txt" ) as r: + install_requires: list = list( r.readlines() ) +with open( "requirements-tests.txt" ) as rt: + tests_require: list = list( rt.readlines() ) +extras_require: dict = { + option: list( + # Remove whitespace, elide blank lines and comments + ''.join( r.split() ) + for r in open( f"requirements-{option}.txt" ).readlines() + if r.strip() and not r.strip().startswith( '#' ) + ) + for option in ('cli', 'tests', 'docs') +} +with open( "hdwallet/version.py" ) as vpy: + exec( vpy.read() ) setup( name="hdwallet", - version="v2.2.1", + version=__version__, description="Python-based library for the implementation of a hierarchical deterministic wallet " "generator for more than 140+ multiple cryptocurrencies.", long_description=long_description, @@ -38,24 +49,9 @@ }, python_requires=">=3.6,<4", packages=find_packages(), - install_requires=requirements, - extras_require={ - "cli": [ - "click>=8.1.3,<9", - "click-aliases>=1.0.1,<2", - "tabulate>=0.9.0,<1" - ], - "tests": [ - "pytest>=7.2.0,<8", - "pytest-cov>=4.0.0,<5", - "tox==3.28.0" - ], - "docs": [ - "sphinx>=5.3.0,<6", - "furo==2022.12.7", - "sphinx-click>=4.4.0,<5" - ] - }, + install_requires=install_requires, + extras_require=extras_require, + tests_require=tests_require, classifiers=[ "Development Status :: 5 - Production/Stable", "License :: OSI Approved :: ISC License (ISCL)", @@ -64,6 +60,8 @@ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Software Development :: Libraries :: Python Modules" ] ) diff --git a/shell.nix b/shell.nix new file mode 100644 index 00000000..aab28b37 --- /dev/null +++ b/shell.nix @@ -0,0 +1,19 @@ +{ pkgs ? import ./nixpkgs.nix {} }: + +let + targets = import ./default.nix { + inherit pkgs; + }; + targeted = builtins.getEnv "TARGET"; + selected = targeted + pkgs.lib.optionalString (targeted == "") "py312"; +in + +with pkgs; + +mkShell { + buildInputs = lib.getAttrFromPath [ selected "buildInputs" ] targets; + + shellHook = '' + echo "Welcome to the Python ${selected} environment!" + ''; +} From 377f4d03fe0c6fbf286e1a6e0ee6c4e13347aea2 Mon Sep 17 00:00:00 2001 From: Perry Kundert Date: Tue, 5 Nov 2024 07:25:08 -0700 Subject: [PATCH 15/16] Test on python 3.12, 3.13, remove 3.7 --- .github/workflows/pythonpackage.yml | 2 +- hdwallet/version.py | 2 +- setup.py | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index eceed53c..1cfa1afa 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -18,7 +18,7 @@ jobs: strategy: matrix: python-version: [ - "3.7", "3.8", "3.9", "3.10", "3.11" + "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ] steps: - uses: actions/checkout@master diff --git a/hdwallet/version.py b/hdwallet/version.py index 942a546f..f934d459 100644 --- a/hdwallet/version.py +++ b/hdwallet/version.py @@ -1,2 +1,2 @@ -__version_info__ = ( 2, 2, 0 ) +__version_info__ = ( 2, 3, 0 ) __version__ = 'v' + '.'.join( map( str, __version_info__ )) diff --git a/setup.py b/setup.py index 476f4651..7990ca8a 100644 --- a/setup.py +++ b/setup.py @@ -55,7 +55,6 @@ classifiers=[ "Development Status :: 5 - Production/Stable", "License :: OSI Approved :: ISC License (ISCL)", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", From 60d78cc36eaa9fbdf1399da8e224d0741d7f85c1 Mon Sep 17 00:00:00 2001 From: Perry Kundert Date: Mon, 18 Nov 2024 08:12:11 -0700 Subject: [PATCH 16/16] Add PyPI release of hdwallet-slip39 upgrade shim --- .github/workflows/release.yml | 27 +++++++++++++++++++++++++++ GNUmakefile | 4 +++- README.md | 10 ++++++++++ setup.py | 4 ++-- 4 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..db67ce9f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,27 @@ +name: Release + +on: + push: + branches: + - master + +jobs: + pypi-publish: + name: Upload release to PyPI + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/python-hdwallet-slip39 + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + - name: Build + run: | + python -m pip install -r requirements-dev.txt + python -m build . + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/GNUmakefile b/GNUmakefile index 3b423f5e..17b58624 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -12,6 +12,8 @@ VENV_NAME = $(GHUB_NAME)-$(VERSION)-$(PY3_V) VENV = $(VENV_DIR)/$(VENV_NAME) VENV_OPTS = +NIX_OPTS ?= # --pure + .PHONY: all test build build-check wheel install-dev install clean FORCE all: build @@ -27,7 +29,7 @@ unit-%: $(PY3TEST) -k $* nix-%: - nix-shell --pure --run "make $*" + nix-shell $(NIX_OPTS) --run "make $*" build: clean wheel diff --git a/README.md b/README.md index 6bb9af3d..2519395b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,15 @@ # Hierarchical Deterministic Wallet +> Note: This hdwallet-slip39 package is a temporary upgrade shim for the great hdwallet package +> https://pypi.org/project/hdwallet/. + +> Use it only until the upstream hdwallet package merges support for BSC, Nix, etc in : +> https://github.com/meherett/python-hdwallet/pull/1020 + +> Until then, substitute "hdwallet-slip39" for "hdwallet" in your "pip install" or requirements.txt +> Both supply the hdwallet package, eg. "import hdwallet". Specify version >= 2.3 to ensure you are +> using this shim. + [![Build Status](https://app.travis-ci.com/meherett/python-hdwallet.svg?branch=master)](https://app.travis-ci.com/meherett/python-hdwallet) [![PyPI Version](https://img.shields.io/pypi/v/hdwallet.svg?color=blue)](https://pypi.org/project/hdwallet) [![Documentation Status](https://readthedocs.org/projects/hdwallet/badge/?version=master)](https://hdwallet.readthedocs.io) diff --git a/setup.py b/setup.py index 7990ca8a..9912180b 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ exec( vpy.read() ) setup( - name="hdwallet", + name="hdwallet-slip39", version=__version__, description="Python-based library for the implementation of a hierarchical deterministic wallet " "generator for more than 140+ multiple cryptocurrencies.", @@ -39,7 +39,7 @@ license="MIT", author="Meheret Tesfaye Batu", author_email="meherett.batu@gmail.com", - url="https://github.com/meherett/python-hdwallet", + url="https://github.com/pjkundert/python-hdwallet", project_urls=project_urls, keywords=[ "cryptography", "cli", "wallet", "bip32", "bip44", "bip39", "hdwallet", "cryptocurrencies", "bitcoin", "ethereum"