Giter Site home page Giter Site logo

meherett / python-hdwallet Goto Github PK

View Code? Open in Web Editor NEW
434.0 14.0 142.0 572 KB

Python-based library for the implementation of a hierarchical deterministic wallet generator for more than 140+ multiple cryptocurrencies.

Home Page: https://hdwallet.readthedocs.io

License: MIT License

Python 99.70% Makefile 0.30%
cryptography hd wallet cryptocurrencies bip32 bip44 hdwallet wallet-generator bitcoin btc

python-hdwallet's Introduction

Hierarchical Deterministic Wallet

Build Status PyPI Version Documentation Status PyPI License PyPI Python Version Coverage Status

Python-based library for the implementation of a hierarchical deterministic wallet generator for more than 140+ multiple cryptocurrencies. It allows the handling of multiple coins, multiple accounts, external and internal chains per account and millions of addresses per chain.

HDWallet-CLI

For more info see the BIP specs.

BIP's Titles
BIP39 Mnemonic code for generating deterministic keys
BIP85 Deterministic Entropy From BIP32 Keychains
BIP32 Hierarchical Deterministic Wallets
BIP44 Multi-Account Hierarchy for Deterministic Wallets
BIP49 Derivation scheme for P2WPKH-nested-in-P2SH based accounts
BIP84 Derivation scheme for P2WPKH based accounts
BIP141 Segregated Witness (Consensus layer)

Installation

The easiest way to install hdwallet is via pip:

pip install hdwallet

To install hdwallet command line interface globally, for Linux sudo may be required:

pip install hdwallet[cli]

If you want to run the latest version of the code, you can install from the git:

pip install git+git://github.com/meherett/python-hdwallet.git

For the versions available, see the tags on this repository.

Quick Usage

Simple Bitcoin mainnet HDWallet generator:

#!/usr/bin/env python3

from hdwallet import HDWallet
from hdwallet.utils import generate_entropy
from hdwallet.symbols import BTC as SYMBOL
from typing import Optional

import json

# Choose strength 128, 160, 192, 224 or 256
STRENGTH: int = 160  # Default is 128
# Choose language english, french, italian, spanish, chinese_simplified, chinese_traditional, japanese or korean
LANGUAGE: str = "korean"  # Default is english
# Generate new entropy hex string
ENTROPY: str = generate_entropy(strength=STRENGTH)
# Secret passphrase for mnemonic
PASSPHRASE: Optional[str] = None  # "meherett"

# Initialize Bitcoin mainnet HDWallet
hdwallet: HDWallet = HDWallet(symbol=SYMBOL, use_default_path=False)
# Get Bitcoin HDWallet from entropy
hdwallet.from_entropy(
    entropy=ENTROPY, language=LANGUAGE, passphrase=PASSPHRASE
)

# Derivation from path
# hdwallet.from_path("m/44'/0'/0'/0/0")
# Or derivation from index
hdwallet.from_index(44, hardened=True)
hdwallet.from_index(0, hardened=True)
hdwallet.from_index(0, hardened=True)
hdwallet.from_index(0)
hdwallet.from_index(0)

# Print all Bitcoin HDWallet information's
print(json.dumps(hdwallet.dumps(), indent=4, ensure_ascii=False))
Output
{
    "cryptocurrency": "Bitcoin",
    "symbol": "BTC",
    "network": "mainnet",
    "strength": 160,
    "entropy": "c5b0d0ee698f3f72b6265f1bc591f8f2d7afa6dd",
    "mnemonic": "주일 액수 명단 천둥 해수욕장 전망 추천 직업 그룹 단위 신체 파란색 시청 천천히 스트레스",
    "language": "korean",
    "passphrase": null,
    "seed": "5a9b9667ccd07b3c641b1ba95e9119dd1d5a3034fd46cd2f27fc1f160c7dcd824fc0ab4710a9ae90582dffc3b0803bcbc0a8160feeaab4c70511c5035859decf",
    "root_xprivate_key": "xprv9s21ZrQH143K2qMHU8aghJ4MoQR5g5mowXbeP2vCP937bseZGX929dmJudL7u4xRxtKvh58pxz1PhtCbWW2yUH14jdduKVMV9FkBMpM2Hyw",
    "root_xpublic_key": "xpub661MyMwAqRbcFKRkaA7h4S16MSFa5YVfJkXFBRKowUa6Ufyhp4TGhS5nkvkLXSmdNjoszzDkU26WW2rg1zBsQBt6Pv3T8oLEAExGHD3hcQs",
    "xprivate_key": "xprvA2YyMZWyPK2xo4eZgyypp2CzcHnxNzGbruGg7vmgaAVCtBtrjwzuhXJBNM3FrwBh85ajxHErNR6ByN77WJARpC1HDC7kTwa2yr7Mu9Pz5Qq",
    "xpublic_key": "xpub6FYKm53sDgbG1Yj2o1WqBA9jAKdSnSzTE8CGvKBJ8W2BkzE1HVKAFKcfDcCHKpL5BQRg2HjbNSt55jpFshY7W1KFtp7zjB3DhNAmiFv6kzB",
    "uncompressed": "081016370b45d7e23bd89b07d6886036f5e4df9a129eee3b488c177ba7881856e24d337b280f9d32539a22445e567543b39b708edf5289442f36dcde958a3433",
    "compressed": "03081016370b45d7e23bd89b07d6886036f5e4df9a129eee3b488c177ba7881856",
    "chain_code": "cf9ee427ed8073e009a5743056e8cf19167f67ca5082c2c6635b391e9a4e0b0d",
    "private_key": "f79495fda777197ce73551bcd8e162ceca19167575760d3cc2bced4bf2a213dc",
    "public_key": "03081016370b45d7e23bd89b07d6886036f5e4df9a129eee3b488c177ba7881856",
    "wif": "L5WyVfBu8Sz3iGZtrwJVSP2wDJmu7HThGd1EGekFBnviWgzLXpJd",
    "finger_print": "ac13e305",
    "semantic": "p2pkh",
    "path": "m/44'/0'/0'/0/0",
    "hash": "ac13e305a88bd9968f1c058fcf5d9a6b1b9ef484",
    "addresses": {
        "p2pkh": "1Ggs3kkNrPPWoW17iDFQWgMdw3CD8BzBiv",
        "p2sh": "3GQVUFePz517Hf61Vsa9H2tHj5jw5y6ngV",
        "p2wpkh": "bc1q4sf7xpdg30vedrcuqk8u7hv6dvdeaayy3uw5cj",
        "p2wpkh_in_p2sh": "3JyV5aSgdVYEjQodPWHfvehQ5227EDr3sN",
        "p2wsh": "bc1qnk0s9q4379n6v9vg0lnhdu5qhjyx99u2xm238pmckmjg9v29q54saddzp9",
        "p2wsh_in_p2sh": "3MmsEoP7GLHzuLVgkAtcRtyXLTWh8zNAcd"
    }
}

Ethereum mainnet Ganache wallet look's like:

#!/usr/bin/env python3

from hdwallet import BIP44HDWallet
from hdwallet.cryptocurrencies import EthereumMainnet
from hdwallet.derivations import BIP44Derivation
from hdwallet.utils import generate_mnemonic
from typing import Optional

# Generate english mnemonic words
MNEMONIC: str = generate_mnemonic(language="english", strength=128)
# Secret passphrase/password for mnemonic
PASSPHRASE: Optional[str] = None  # "meherett"

# Initialize Ethereum mainnet BIP44HDWallet
bip44_hdwallet: BIP44HDWallet = BIP44HDWallet(cryptocurrency=EthereumMainnet)
# Get Ethereum BIP44HDWallet from mnemonic
bip44_hdwallet.from_mnemonic(
    mnemonic=MNEMONIC, language="english", passphrase=PASSPHRASE
)
# Clean default BIP44 derivation indexes/paths
bip44_hdwallet.clean_derivation()

print("Mnemonic:", bip44_hdwallet.mnemonic())
print("Base HD Path:  m/44'/60'/0'/0/{address_index}", "\n")

# Get Ethereum BIP44HDWallet information's from address index
for address_index in range(10):
    # Derivation from Ethereum BIP44 derivation path
    bip44_derivation: BIP44Derivation = BIP44Derivation(
        cryptocurrency=EthereumMainnet, account=0, change=False, address=address_index
    )
    # Drive Ethereum BIP44HDWallet
    bip44_hdwallet.from_path(path=bip44_derivation)
    # Print address_index, path, address and private_key
    print(f"({address_index}) {bip44_hdwallet.path()} {bip44_hdwallet.address()} 0x{bip44_hdwallet.private_key()}")
    # Clean derivation indexes/paths
    bip44_hdwallet.clean_derivation()
Output
Mnemonic: bright demand olive glance crater key head glory quantum leisure intact age
Base HD Path:  m/44'/60'/0'/0/{address_index}

(0) m/44'/60'/0'/0/0 0x3a149f0c5dc5c0F1E29e573215C23710dE9c4f87 0xa45f9af43912fdd5e88c492226be082029f257681d4b3e73b68be535d2fb0526
(1) m/44'/60'/0'/0/1 0x9e8A4fD9bA74DbB0c7F465EF56b47489793AA102 0x6e5ab2a3ae20c7b3a1c0645b03689e88e8cdff16f6a39d6a420bfebc20e8a941
(2) m/44'/60'/0'/0/2 0x08Eb0646ddc52E12a03215b94b244B674e9D7a0F 0x938caf07197eda13679bfd88df7e5f6eac3cd9f9248ed445f1a0e084a3e9417c
(3) m/44'/60'/0'/0/3 0x6dB1Ac10bbbE7bdc6bcB246E2Dd36884c346CbE8 0x304e9bebaeef3f4ae7c4d2ef268f40f503d8f47fd2621a575d8f73f49762cbc0
(4) m/44'/60'/0'/0/4 0xd528281f804D950c743Ca48FCcC3D76A3d9AcD5C 0x82a0284b443ec73884806ac9450f09110d8dba024120985431b80a520b3f2911
(5) m/44'/60'/0'/0/5 0xaF24cc02Fd5E0285237677cDDD00ae8E4a9d6E5E 0xb03c61e992f5475222295077a89cf35011984dcdcd1da3666ebffc9ebefe22a9
(6) m/44'/60'/0'/0/6 0x55A972f207DB3498DCBbD97062472A5c10b3266b 0xc003175828a6f768610fb2396b3fcec7fa1957770de2462b9e6d3a0a23346c76
(7) m/44'/60'/0'/0/7 0x7e62C187e597Fc544D5769a38A8e026F5529c81B 0x04bfcff46587fd98e682e3b7acff720051b1b0bee3309fb13703338bbde211cd
(8) m/44'/60'/0'/0/8 0x7aF4A78000032a3FBaF4Ac5a5f64a50FF69f0442 0x1b642b77519cf6e6107827e4773a15975edda6471ff90735e2fc0cf7d8560ac8
(9) m/44'/60'/0'/0/9 0x379a25BB89043f8b875A73eA61aF4F7b70cD73e5 0x4f9fb333faf8ecf8f22d212a0b1c946e4d4c32fa0b7794326038d464b241d771

Click this to see more examples :)

Development

To get started, just fork this repo, clone it locally, and run:

pip install -e .[cli,tests,docs] -r requirements.txt

Testing

You can run the tests with:

pytest

Or use tox to run the complete suite against the full set of build targets, or pytest to run specific tests against a specific version of Python.

Contributing

Feel free to open an issue if you find a problem, or a pull request if you've solved an issue. And also any help in testing, development, documentation and other tasks is highly appreciated and useful to the project. There are tasks for contributors of all experience levels.

For more information, see the CONTRIBUTING.md file.

Available Cryptocurrencies

This library simplifies the process of creating a new hierarchical deterministic wallets for:

Cryptocurrencies Symbols Mainnet Testnet Segwit Coin Type Default Paths
Anon ANON Yes No No 220 m/44'/220'/0'/0/0
Argoneum AGM Yes No No 421 m/44'/421'/0'/0/0
Artax XAX Yes No No 219 m/44'/219'/0'/0/0
Aryacoin AYA Yes No No 357 m/44'/357'/0'/0/0
Asiacoin AC Yes No No 51 m/44'/51'/0'/0/0
Atom ATOM Yes No Yes 118 m/44'/118'/0'/0/0
Auroracoin AUR Yes No No 85 m/44'/85'/0'/0/0
Axe AXE Yes No No 4242 m/44'/4242'/0'/0/0
Bata BTA Yes No No 89 m/44'/89'/0'/0/0
Beetle Coin BEET Yes No No 800 m/44'/800'/0'/0/0
Bela Coin BELA Yes No No 73 m/44'/73'/0'/0/0
Bit Cloud BTDX Yes No No 218 m/44'/218'/0'/0/0
Bit Send BSD Yes No No 91 m/44'/91'/0'/0/0
Bitcoin Cash BCH Yes No Yes 145 m/44'/145'/0'/0/0
Bitcoin Gold BTG Yes No Yes 156 m/44'/156'/0'/0/0
Bitcoin BTC, BTCTEST Yes Yes Yes 0 m/44'/0'/0'/0/0
Bitcoin Plus XBC Yes No No 65 m/44'/65'/0'/0/0
Bitcoin SV BSV Yes No No 236 m/44'/236'/0'/0/0
BitcoinZ BTCZ Yes No No 177 m/44'/177'/0'/0/0
Bitcore BTX Yes No Yes 160 m/44'/160'/0'/0/0
Blackcoin BLK Yes No No 10 m/44'/10'/0'/0/0
Block Stamp BST Yes No Yes 254 m/44'/254'/0'/0/0
Blocknode BND, BNDTEST Yes Yes No 2941 m/44'/2941'/0'/0/0
Bolivarcoin BOLI Yes No No 278 m/44'/278'/0'/0/0
Brit Coin BRIT Yes No No 70 m/44'/70'/0'/0/0
CPU Chain CPU Yes No Yes 363 m/44'/363'/0'/0/0
Canada eCoin CDN Yes No No 34 m/44'/34'/0'/0/0
Cannacoin CCN Yes No No 19 m/44'/19'/0'/0/0
Clams CLAM Yes No No 23 m/44'/23'/0'/0/0
Club Coin CLUB Yes No No 79 m/44'/79'/0'/0/0
Compcoin CMP Yes No No 71 m/44'/71'/0'/0/0
Crane Pay CRP Yes No Yes 2304 m/44'/2304'/0'/0/0
Crave CRAVE Yes No No 186 m/44'/186'/0'/0/0
Dash DASH, DASHTEST Yes Yes No 5 m/44'/5'/0'/0/0
Deep Onion ONION Yes No Yes 305 m/44'/305'/0'/0/0
Defcoin DFC Yes No No 1337 m/44'/1337'/0'/0/0
Denarius DNR Yes No No 116 m/44'/116'/0'/0/0
Diamond DMD Yes No No 152 m/44'/152'/0'/0/0
Digi Byte DGB Yes No Yes 20 m/44'/20'/0'/0/0
Digitalcoin DGC Yes No No 18 m/44'/18'/0'/0/0
Dogecoin DOGE, DOGETEST Yes Yes No 3 m/44'/3'/0'/0/0
EDR Coin EDRC Yes No No 56 m/44'/56'/0'/0/0
Ecoin ECN Yes No No 115 m/44'/115'/0'/0/0
Einsteinium EMC2 Yes No No 41 m/44'/41'/0'/0/0
Elastos ELA Yes No No 2305 m/44'/2305'/0'/0/0
Energi NRG Yes No No 9797 m/44'/9797'/0'/0/0
Ethereum ETH Yes No Yes 60 m/44'/60'/0'/0/0
Europe Coin ERC Yes No No 151 m/44'/151'/0'/0/0
Exclusive Coin EXCL Yes No No 190 m/44'/190'/0'/0/0
FIX FIX, FIXTEST Yes Yes No 336 m/44'/336'/0'/0/0
Feathercoin FTC Yes No No 8 m/44'/8'/0'/0/0
Firstcoin FRST Yes No No 167 m/44'/167'/0'/0/0
Flashcoin FLASH Yes No No 120 m/44'/120'/0'/0/0
Flux FLUX Yes No No 19167 m/44'/19167'/0'/0/0
Fuji Coin FJC Yes No Yes 75 m/44'/75'/0'/0/0
GCR Coin GCR Yes No No 49 m/44'/49'/0'/0/0
Game Credits GAME Yes No No 101 m/44'/101'/0'/0/0
Go Byte GBX Yes No No 176 m/44'/176'/0'/0/0
Gridcoin GRC Yes No No 84 m/44'/84'/0'/0/0
Groestl Coin GRS, GRSTEST Yes Yes Yes 17 m/44'/17'/0'/0/0
Gulden NLG Yes No No 87 m/44'/87'/0'/0/0
Helleniccoin HNC Yes No No 168 m/44'/168'/0'/0/0
Hempcoin THC Yes No No 113 m/44'/113'/0'/0/0
Hush HUSH Yes No No 197 m/44'/197'/0'/0/0
IX Coin IXC Yes No No 86 m/44'/86'/0'/0/0
Insane Coin INSN Yes No No 68 m/44'/68'/0'/0/0
Internet Of People IOP Yes No No 66 m/44'/66'/0'/0/0
Jumbucks JBS Yes No No 26 m/44'/26'/0'/0/0
Kobocoin KOBO Yes No No 196 m/44'/196'/0'/0/0
Komodo KMD Yes No No 141 m/44'/141'/0'/0/0
LBRY Credits LBC Yes No No 140 m/44'/140'/0'/0/0
Linx LINX Yes No No 114 m/44'/114'/0'/0/0
Litecoin Cash LCC Yes No No 192 m/44'/192'/0'/0/0
Litecoin LTC, LTCTEST Yes Yes Yes 2 m/44'/2'/0'/0/0
LitecoinZ LTZ Yes No No 221 m/44'/221'/0'/0/0
Lkrcoin LKR Yes No No 557 m/44'/557'/0'/0/0
Lynx LYNX Yes No No 191 m/44'/191'/0'/0/0
Mazacoin MZC Yes No No 13 m/44'/13'/0'/0/0
Megacoin MEC Yes No No 217 m/44'/217'/0'/0/0
Minexcoin MNX Yes No No 182 m/44'/182'/0'/0/0
Monacoin MONA Yes No Yes 22 m/44'/22'/0'/0/0
Monkey Project MONK Yes No Yes 214 m/44'/214'/0'/0/0
Myriadcoin XMY Yes No No 90 m/44'/90'/0'/0/0
NIX NIX Yes No Yes 400 m/44'/400'/0'/0/0
Namecoin NMC Yes No No 7 m/44'/7'/0'/0/0
Navcoin NAV Yes No No 130 m/44'/130'/0'/0/0
Neblio NEBL Yes No No 146 m/44'/146'/0'/0/0
Neoscoin NEOS Yes No No 25 m/44'/25'/0'/0/0
Neurocoin NRO Yes No No 110 m/44'/110'/0'/0/0
New York Coin NYC Yes No No 179 m/44'/179'/0'/0/0
Novacoin NVC Yes No No 50 m/44'/50'/0'/0/0
NuBits NBT Yes No No 12 m/44'/12'/0'/0/0
NuShares NSR Yes No No 11 m/44'/11'/0'/0/0
OK Cash OK Yes No No 69 m/44'/69'/0'/0/0
Omni OMNI, OMNITEST Yes Yes No 200 m/44'/200'/0'/0/0
Onix Coin ONX Yes No No 174 m/44'/174'/0'/0/0
Peercoin PPC Yes No No 6 m/44'/6'/0'/0/0
Pesobit PSB Yes No No 62 m/44'/62'/0'/0/0
Phore PHR Yes No No 444 m/44'/444'/0'/0/0
Pinkcoin PINK Yes No No 117 m/44'/117'/0'/0/0
Pivx PIVX, PIVXTEST Yes Yes No 119 m/44'/119'/0'/0/0
Posw Coin POSW Yes No No 47 m/44'/47'/0'/0/0
Potcoin POT Yes No No 81 m/44'/81'/0'/0/0
Project Coin PRJ Yes No No 533 m/44'/533'/0'/0/0
Putincoin PUT Yes No No 122 m/44'/122'/0'/0/0
Qtum QTUM, QTUMTEST Yes Yes Yes 2301 m/44'/2301'/0'/0/0
RSK RBTC, RBTCTEST Yes Yes No 137 m/44'/137'/0'/0/0
Rapids RPD Yes No No 320 m/44'/320'/0'/0/0
Ravencoin RVN Yes No No 175 m/44'/175'/0'/0/0
Reddcoin RDD Yes No No 4 m/44'/4'/0'/0/0
Ripple XRP Yes No No 144 m/44'/144'/0'/0/0
Rubycoin RBY Yes No No 16 m/44'/16'/0'/0/0
Safecoin SAFE Yes No No 19165 m/44'/19165'/0'/0/0
Saluscoin SLS Yes No No 572 m/44'/572'/0'/0/0
Scribe SCRIBE Yes No No 545 m/44'/545'/0'/0/0
Shadow Cash SDC, SDCTEST Yes Yes No 35 m/44'/35'/0'/0/0
Slimcoin SLM, SLMTEST Yes Yes No 63 m/44'/63'/0'/0/0
Smileycoin SMLY Yes No No 59 m/44'/59'/0'/0/0
Solarcoin SLR Yes No No 58 m/44'/58'/0'/0/0
Stash STASH Yes No No 49344 m/44'/49344'/0'/0/0
Stratis STRAT, STRATTEST Yes Yes No 105 m/44'/105'/0'/0/0
Sugarchain SUGAR, SUGARTEST Yes Yes Yes 408 m/44'/408'/0'/0/0
Syscoin SYS Yes No Yes 57 m/44'/57'/0'/0/0
TOA Coin TOA Yes No No 159 m/44'/159'/0'/0/0
Thought AI THT Yes No No 502 m/44'/502'/0'/0/0
Tron TRX Yes No No 195 m/44'/195'/0'/0/0
Twins TWINS, TWINSTEST Yes Yes No 970 m/44'/970'/0'/0/0
Ultimate Secure Cash USC Yes No No 112 m/44'/112'/0'/0/0
Unobtanium UNO Yes No No 92 m/44'/92'/0'/0/0
Virtual Cash VASH Yes No No 33 m/44'/33'/0'/0/0
Vcash VC Yes No No 127 m/44'/127'/0'/0/0
Verge Currency XVG Yes No No 77 m/44'/77'/0'/0/0
Vertcoin VTC Yes No Yes 28 m/44'/28'/0'/0/0
Viacoin VIA, VIATEST Yes Yes Yes 14 m/44'/14'/0'/0/0
Vivo VIVO Yes No No 166 m/44'/166'/0'/0/0
Whitecoin XWC Yes No No 559 m/44'/559'/0'/0/0
Wincoin WC Yes No No 181 m/44'/181'/0'/0/0
XUEZ XUEZ Yes No No 225 m/44'/225'/0'/0/0
XinFin XDC Yes No Yes 550 m/44'/550'/0'/0/0
Ycash YEC Yes No No 347 m/44'/347'/0'/0/0
ZClassic ZCL Yes No No 147 m/44'/147'/0'/0/0
Zcash ZEC, ZECTEST Yes Yes No 133 m/44'/133'/0'/0/0
Zencash ZEN Yes No No 121 m/44'/121'/0'/0/0

Donations

If You found this tool helpful consider making a donation:

Coins Addresses
Bitcoin BTC 3GGNPvgbSpMHShcaZJGDXQn5wUJyTz7uoC
Ethereum ETH, Tether USDT 0x342798bbe9731a91e0557fa8ab0bce1eae6d6ae3

License

Distributed under the MIT license. See LICENSE for more information.

python-hdwallet's People

Contributors

alimohammad1995 avatar bombs-kim avatar bracteat avatar git-infinianti avatar martinholy avatar meherett avatar nultinator avatar pjkundert avatar saloppe73 avatar sokripon avatar xmasapple avatar yawhide avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-hdwallet's Issues

Cannot be derived from xpublic_key

Hi! How are you?
Thank you very much in advance for the work! It is an excellent library.

I report a problem:
You can only make derivations from root_xplublic_key and from root_xprivate_key. You get the error:
"PermissionError: You can't drive this master key."
But not from xpublic_key (BIP32):

Example: BIP32 Derivation Path: m / 44 '/ 0' / 0 '/ 0

as if you can see it on this site:
https://iancoleman.io/bip39/

Thank you very much again. Greetings

Invalid derivation paths in the documentation

DISCLAIMER: I tried editing the documentation myself but github forces me to fork the project first and when I try to do that I get 404 page. I have no time to diagnose that, so please someone either with direct access or who just knows better than me how to work with github, fix the below.

The documentation page under this address specifically https://hdwallet.readthedocs.io/en/v2.2.1/hdwallet.html on multiple occasions include invalid derivation paths. Please double check all of them, I just copied one example to the code I'm working on and stumbled upon this m/44'/0'/'0/0/0 which is obviously broken as there is hardening symbol before second zero from the left instead of being after it. If you ctrl+f and search for it in the article, you will find that such a broken path is used 7 times. The proper path is m/44'/0'/0'/0/0.

Get indexes of ACCOUNT, CHANGE, ADDRESS.

how can i know how many addresses exist in a wallt?

#!/usr/bin/env python3

from hdwallet import HDWallet
from hdwallet.utils import generate_entropy
from hdwallet.symbols import BTC
from typing import Optional

import json

# Choose strength 128, 160, 192, 224 or 256
STRENGTH: int = 160  # Default is 128
# Choose language english, french, italian, spanish, chinese_simplified, chinese_traditional, japanese or korean
LANGUAGE: str = "korean"  # Default is english
# Generate new entropy hex string
ENTROPY: str = generate_entropy(strength=STRENGTH)
# Secret passphrase for mnemonic
PASSPHRASE: Optional[str] = None  # "meherett"

# Initialize Bitcoin mainnet HDWallet
hdwallet: HDWallet = HDWallet(symbol=BTC)
# Get Bitcoin HDWallet from entropy
hdwallet.from_entropy(
    entropy=ENTROPY, language=LANGUAGE, passphrase=PASSPHRASE
)

# Derivation from path
# hdwallet.from_path("m/44'/0'/0'/0/0")
# Or derivation from index
hdwallet.from_index(44, harden=True)
hdwallet.from_index(0, harden=True)
hdwallet.from_index(0, harden=True)
hdwallet.from_index(0)
hdwallet.from_index(0)

# Print all Bitcoin HDWallet information's
print(json.dumps(hdwallet.dumps(), indent=4, ensure_ascii=False))

with above code i just can address in index 0.
but i want to know how many index are there in the wallet.

Add public_key_uncompressed method

Please add a method "public_key_uncompressed" so that we can get the long version of the public key, if needed.

If someone falls here searching how to get the long key before the feature request is implemented, you need to locate hdwallet.py file in your python3 library path and clone the public_key method by changing the return statement to return self.uncompressed() .

Multi currency support?

(I'm new to all this)

Looking at the docs and source, it seems this was built in a way that a user could only have a single passphrase/mnemonic for each currency/wallet, meaning that this does not have a so called "multi-coin" wallet support. By multi-coin what I mean is that the user would have a single recovery phrase, and that would generate different keys for different chains (using the different derivation schemes).

From the TrustWallet docs there's something like:

Multi-Coin Wallet
The Multi-Coin Wallet is a structure allowing accounts for many coins, all controlled by a single recovery phrase. It is a standard HD Wallet (Hierarchically Derived), employing the standard derivation schemes, interoperable with many other wallets: BIP39 for recovery phrase, BIP44/BIP84 for account derivation.

Wondering if I'm interpreting things right, and whether there is a way to have multi currency support.
Thanks!

p2sh address different from those generated by the Ian Coleman bip39 tools and other tools

mnemonic: "all all all all all all all all all all all all"
no passphrase

derivation path: "m/49'/0'/0'/1/0
correct address: 3Jdnbtqg3f8YberUzEirLLAumsp7RYt4Kw

incorrect address returned by HDWallet: 3K7n6sivDyYPgkkmBcQMWhLxJvH2AuaHVy

Note: I confirmed the correct address also with bip_utils

Also, i think that wallet.address() should still be defined as an alias to wallet.p2pkh_address(), to keep old scripts compatible (and also the example of this page still uses address() )

Attempt to generate watch-only wallets fails

Theoretically, it should be possible to generate watch-only addresses from xpublic_key.

However, the code errors when attempting something like this

bip44_hdwallet: BIP44HDWallet = BIP44HDWallet(cryptocurrency=BitcoinMainnet)
bip44_hdwallet.from_xpublic_key(xpublic_key=XPUB_KEY)

for address_index in range(10):
    bip44_derivation = BIP44Derivation(
        cryptocurrency=BitcoinMainnet, account=0, change=False, address=address_index
    )
    bip44_hdwallet.from_path(path=bip44_derivation)
    print(f"({address_index}) {bip44_hdwallet.path()} {bip44_hdwallet.address()}")
    bip44_hdwallet.clean_derivation()

The error is thrown by _derive_key_by_index function.

    437         i_str = struct.pack(">L", index)
    438         if index & BIP32KEY_HARDEN:
--> 439             data = b"\0" + self._key.to_string() + i_str
    440         else:
    441             data = unhexlify(self.public_key()) + i_str

AttributeError: 'NoneType' object has no attribute 'to_string'

Of course, in watch-only wallets, private key would be null, and it's trying to access _key which is empty as expected. Hence the failure.

[Bug] ModuleNotFoundError: No module named 'click_aliases' (on RPi)

Hi, I am using hdwallet on a RPi (Raspberry OS).

I get the following error:

# e.g.
hdwallet generate addresses --symbol ETH
>>
Traceback (most recent call last):
  File "/home/pi/.local/bin/hdwallet", line 5, in <module>
    from hdwallet.cli.__main__ import main
  File "/home/pi/.local/lib/python3.9/site-packages/hdwallet/cli/__main__.py", line 3, in <module>
    from click_aliases import ClickAliasedGroup

Installation of the tool already gave me a suspicious alert (although the installation completed):

pip install hdwallet
>>
[...]
--- Logging error ---
Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/utils/logging.py", line 177, in emit
    self.console.print(renderable, overflow="ignore", crop=False, style=style)
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_vendor/rich/console.py", line 1673, in print
    extend(render(renderable, render_options))
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_vendor/rich/console.py", line 1305, in render
    for render_output in iter_render:
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/utils/logging.py", line 134, in __rich_console__
    for line in lines:
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_vendor/rich/segment.py", line 249, in split_lines
    for segment in segments:
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_vendor/rich/console.py", line 1283, in render
    renderable = rich_cast(renderable)
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_vendor/rich/protocol.py", line 36, in rich_cast
    renderable = cast_method()
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/self_outdated_check.py", line 130, in __rich__
    pip_cmd = get_best_invocation_for_this_pip()
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/utils/entrypoints.py", line 58, in get_best_invocation_for_this_pip
    if found_executable and os.path.samefile(
  File "/usr/lib/python3.9/genericpath.py", line 101, in samefile
    s2 = os.stat(f2)
FileNotFoundError: [Errno 2] Datei oder Verzeichnis nicht gefunden: '/usr/bin/pip3.9'
Call stack:
  File "/home/pi/.local/bin/pip", line 8, in <module>
    sys.exit(main())
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/cli/main.py", line 70, in main
    return command.main(cmd_args)
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 101, in main
    return self._main(args)
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 223, in _main
    self.handle_pip_version_check(options)
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 190, in handle_pip_version_check
    pip_self_version_check(session, options)
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/self_outdated_check.py", line 236, in pip_self_version_check
    logger.warning("[present-rich] %s", upgrade_prompt)
  File "/usr/lib/python3.9/logging/__init__.py", line 1454, in warning
    self._log(WARNING, msg, args, **kwargs)
  File "/usr/lib/python3.9/logging/__init__.py", line 1585, in _log
    self.handle(record)
  File "/usr/lib/python3.9/logging/__init__.py", line 1595, in handle
    self.callHandlers(record)
  File "/usr/lib/python3.9/logging/__init__.py", line 1657, in callHandlers
    hdlr.handle(record)
  File "/usr/lib/python3.9/logging/__init__.py", line 948, in handle
    self.emit(record)
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/utils/logging.py", line 179, in emit
    self.handleError(record)
Message: '[present-rich] %s'
Arguments: (UpgradePrompt(old='22.2.2', new='22.3.1'),)

Some local environment infos:

cat /etc/os-release
>>
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

#--

python --version
>>
Python 3.9.2

#--
pip --version
>>
pip 22.2.2 from /home/pi/.local/lib/python3.9/site-packages/pip (python 3.9)

Typing issue in get_semantic and downstream consequences

Hi, thanks for building this library! We recently upgraded from version 1.3.2 to 2.2.1 and some of our tests are now failing. For example if we do

xpub_key="drkvjRAvbKRoPGwQKSY4bSbbDrUv1zTH8bUTQDeyEBNGws5BZUwec5wNeNwJqzYSSqC5CTsD7AMvun5RMmi39GjMfELNfF4cwB6DhLG7aTQfUST"
symbol="DASH"
is_root_xpublic_key(xpublic_key=xpub_key, symbol=symbol)

This raises an exception here because get_semantic returns None.

According to the type annotation get_semantic returns a non-optional string and therefore should not return None. Is the type annotation wrong? How should the code handle the above case?

Performance Degradation from 0.2.0 to 1.1.0

I've been using this wallet to generate vanity public addresses and have found a degradation in performance from version 0.2.0 to 1.1.0

Steps to reproduce
generate a list of 1,000 mnemomics (not using this wallet for)
convert those mnemonics to public addresses via below methods

hdwallet: HDWallet = HDWallet(cryptocurrency=EthereumMainnet)
def getAddress(seed, path):
	hdwallet.clean_derivation()
	hdwallet.from_mnemonic(mnemonic=seed)
	hdwallet.from_path(path)
	address = str(hdwallet.address()).strip()
	return address

you will see that just by going from version 0.2.0 to 1.1.0 it's about 33% slower

Note - I did change the import statement to the newer version to make the code work...

from hdwallet.derivations import BIP44Derivation
hdwallet: BIP44HDWallet = BIP44HDWallet(cryptocurrency=EthereumMainnet)

Cardano (ADA) Blockchain Suport

Hey,
Thank you for this useful python package. I wonder why don't you add some important blockchains like ADA or SOL to this HD wallet?

Get addresses from xpublic key

Hi,

I'm trying the example https://github.com/meherett/python-hdwallet/blob/master/examples/from_xpublic_key.py to use with my Ledger Hardware Wallet to get all addresses to watch my balances.

From Ledger Live I go to my Bitcoin account and go to the account settings where I get the following:

{
  "xpub": "xpub[xPub-key]",
  "index": 0,
  "freshAddressPath": "84'/0'/0'/0/9",
  "id": "js:2:bitcoin:xpub[xPub-key]:native_segwit",
  "blockHeight": 748956
}

And use the following code:

#!/usr/bin/env python3
from hdwallet import HDWallet as HDWallet
from hdwallet.utils import is_root_xpublic_key
from hdwallet.symbols import BTC as SYMBOL

# Strict for root xpublic key
STRICT: bool = False
# Bitcoin root xpublic key
XPUBLIC_KEY: str = "xpub[xPub-key]"

if STRICT:
    # Check root xpublic key
    assert is_root_xpublic_key(
        xpublic_key=XPUBLIC_KEY, symbol=SYMBOL), "Invalid Root XPublic Key."

# Initialize Bitcoin mainnet HDWallet
hdwallet: HDWallet = HDWallet(symbol=SYMBOL)
# Get Bitcoin HDWallet from xpublic key
hdwallet.from_xpublic_key(xpublic_key=XPUBLIC_KEY, strict=False)

for i in range(10):
    print('Index {}'.format(str(i)))
    hdwallet.from_path("m/84/0/0/0/{}".format(str(i)))
    # hdwallet.from_path("m/0/{}".format(str(i)))
    print("P2WPKH Address:", hdwallet.p2wpkh_address())
    print('')

When I set the STRICT variable to True I get the message "Invalid Root Xpublic Key." When I set it to False I'm able to generate addresses, however I don't get addresses that where generated by Ledger Live.

Did get anyone working code for the xpub with Ledger Live?

Add BIP84 LTC support

Hi. Thanks for this very usefull lib!
In one of my project I need to create LTC HD wallet and get error:
NotImplementedError: BIP84HDWallet is not implemented for Litecoin mainnet cryptocurrency.
Can you add support for it?
Or maybe param "P2WPKH" for ExtendedPublicKey and ExtendedPrivateKey params is the same as in BTC and I can populate it to LTC ?

Incorrect deriving in any custom HDWallet [bug]

Hello. I noticed that any custom deriving with CUSTOMHDWallet.from_path function raise gluing old init path and new submitted path. So the result is absolutely different keys. I tried to find problem by myself but code is too difficult to me.
2022-09-27 05_16_17-C__python_polygon_test json - Notepad++  Administrator

I'm absolutely sure that it is a bug, cuz if I forbid your (module) deriving and place my own required path, everything working fine and I get correct keys.
2022-09-27 05_17_25-C__Users_hope_AppData_Local_Programs_Python_Python38_Lib_site-packages_hdwallet_

Hm, this will cause RFCs book to use 0.4.8 probably almost indefinitely this way. Maybe good, but definitely a different from the previous setup. Haven't had a keypad for a week on my phone been trying everything I need it I can't log into Google I can't get my emails I can't do anything fortunately I have one of these looping no good

Hm, this will cause RFCs book to use 0.4.8 probably almost indefinitely this way. Maybe good, but definitely a different from the previous setup.

Originally posted by @nagisa in rust-lang/rfcs#3136 (comment)

How to spend sats sent to various types of addresses derived from same priv key?

So, I used this to get all different addresses - https://github.com/meherett/python-hdwallet/blob/master/examples/from_private_key.py

I got the priv key from Exodus app. And verified the address shown on Exodus matched with one of the public addresses generated with that script. It matched and when I sent sats to that address, I was able to access them in Exodus and spend. I assumed when I sent to other address, they'll be visible in Exodus. So, I send small amounts to other addresses as well. But I couldn't see them on Exodus.

I can see the txs on blockchain. But dunno how to spend those sats from that address.

I've used these libs to spend but I couldn't figure out any ways to select which address (public key) to use to send those sats.

  1. https://github.com/blockstack/pybitcoin
  2. https://github.com/ofek/bit
  3. https://github.com/1200wd/bitcoinlib

Any help?

Move click, click-aliases, and tabulate to extras_require

As of version hdwallet==2.1.0, click, click-aliases, and tabulate are considered must-have dependencies for hdwallet package.
But actually, they're necessary only in case hdwallet's CLI is used, but it's not always a case.

This creates some problems in case other dependencies or the project itself which uses hdwallet have different version range for these dependencies, e.g. click<8.0.0.

It's proposed to move the aforementioned dependencies from install_requires to extras_require in setup.py to be able to include them only if CLI part of package is considered to be used.
cli is the proposed key for these list of packages in extras_require dictionary.

Cannot create HDWallet from a `zpub` extended public key

Howdy again,

I am having trouble created an HDWallet instance using this zpub address.
I am pretty confident this is a real zpub because I can go to blockchair and see the history of transactions https://blockchair.com/bitcoin/xpub/zpub6oN4tLvpVbb3setcn6eStWCFSqpxMBYn7XkCgyERhg8ccW8tU8RCe4NTzNpH6nPgxiy1du5sDdzPdt6Q2vQmPsYy2gmV1M4NY3CscMgqsJZ
I'll show you a list of things I tried:

>>> from hdwallet import HDWallet, BIP84HDWallet

>>> zpub = 'zpub6oN4tLvpVbb3setcn6eStWCFSqpxMBYn7XkCgyERhg8ccW8tU8RCe4NTzNpH6nPgxiy1du5sDdzPdt6Q2vQmPsYy2gmV1M4NY3CscMgqsJZ'

>>> hdwallet = HDWallet(symbol='BTC')
>>> hdwallet.from_xpublic_key(xpublic_key=zpub)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "~/env/lib/python3.6/site-packages/hdwallet/hdwallet.py", line 296, in from_xpublic_key
    _deserialize_xpublic_key[5], curve=SECP256k1
  File "~/env/lib/python3.6/site-packages/ecdsa/keys.py", line 46, in from_string
    curve.verifying_key_length, len(string)))
ecdsa.keys.MalformedPointError: Malformed encoding of public point. Expected string 64 bytes long, received 33 bytes long string

I then tried to use BIP84HDWallet

>>> hdwallet84 = BIP84HDWallet(symbol='BTC')
>>> hdwallet84.from_xpublic_key(xpublic_key=zpub)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "~/env/lib/python3.6/site-packages/hdwallet/hdwallet.py", line 296, in from_xpublic_key
    _deserialize_xpublic_key[5], curve=SECP256k1
  File "~/env/lib/python3.6/site-packages/ecdsa/keys.py", line 46, in from_string
    curve.verifying_key_length, len(string)))
ecdsa.keys.MalformedPointError: Malformed encoding of public point. Expected string 64 bytes long, received 33 bytes long string

I am using hdwallet v1.2.0

Any ideas why this isnt working?

Generate New Wallet

Hey, this code creates a new wallet or just generate a random mnemonic?

MNEMONIC= generate_mnemonic(language="english", strength=128)
PASSPHRASE: Optional[str] = None # "meherett"
bip44_hdwallet: BIP44HDWallet = BIP44HDWallet(cryptocurrency=EthereumMainnet)
bip44_hdwallet.from_mnemonic(
mnemonic=MNEMONIC, language="english", passphrase=PASSPHRASE

How can i initialize a wallet with my mnemonic words?

Thanks!

Incorrect private key

Hi there,

I'm trying to use this library for BTC, LTC, DOGE, and DASH, but generated private keys for DOGE don't work.

Any specific reason for it?

Best,
Marko

Allow derivations from extended public keys

Hello again :)

It looks like HDWallet only allows deriving extended public keys when you have the private key. I believe it is possible to derive extended public keys when you do not have the private key.

I am trying to get ALL sorts of bip32/44/49/84 extended public keys that are from various cryptocurrencies (like btc, doge, ltc, dash, zcash) and then trying to derive some extended public keys from them.

I am trying to do as follows:

hdwallet = HDWallet(symbol='DASH')
hdwallet.from_xpublic_key(xpublic_key='drkpRykits4vMCKnaJsr4e6z1pSAkHtWzx9ZFiZJzRaq3xo2Ug9eFVBdQ9HAMSMUehRk4ANkeyzbtEXVY91LM4RkojPzN3eTaHQLtquM6LRypUm')
addresses = []
i = 0
while i <= 2:
    hdwallet.from_path(path=f'm/0/{i}')
    addresses.append(hdwallet.address())
    hdwallet.clean_derivation()
    i += 1
print(addresses) # ['XbTRLsLqMviTsow6g4y3apHZNCc3XudymK', 'XkDJ5Vg5nJz9FSbTHxqAZ1kjmoZfNZYo86', 'XcG6n92PP9mco6hJFNfRA5KkMVSRmEETwk']

but I get the following exception:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/toor/coin-tracker/coin-tracker-server/env/lib/python3.6/site-packages/hdwallet/hdwallet.py", line 398, in from_path
    self._derive_key_by_index(int(index))
  File "/home/toor/coin-tracker/coin-tracker-server/env/lib/python3.6/site-packages/hdwallet/hdwallet.py", line 452, in _derive_key_by_index
    pvt_int = string_to_int(self._key.to_string())
AttributeError: 'NoneType' object has no attribute 'to_string'

thanks again!

Hello

READC: END CONTROL

Incorrect output of Base58 decoding

When calling function 'base58.decode' with '1' as starting character(s), returned output is incorrect.

# test vector from <https://tools.ietf.org/id/draft-msporny-base58-02.html#name-test-vectors>
assert hdwallet.libs.base58.decode("111233QC4") == b'\x00\x00\x00(\x7f\xb4\xcd' # fails

P2PKH address for the uncompressed public key

Code:

from hdwallet import HDWallet
from hdwallet.symbols import BTC as SYMBOL
hdwallet: HDWallet = HDWallet(symbol=SYMBOL)
PRIVATE_KEY: str = hashlib.sha256(b"asdasd").hexdigest()
hdwallet.from_private_key(PRIVATE_KEY)
print("Uncompressed:", hdwallet.uncompressed())
print("P2PKH Address:", hdwallet.p2pkh_address())

Result:

Uncompressed: fb2b1bf2bcb92b11db6caee48f4a0656dddb0104abc8583a67be81581868ae31551a7aeb83a4004d4b169d4d8020f0b1fd4ae977e4bd9da0d9f3414a0c0353c5
P2PKH Address: 1AQYRDSw3eUo3LuWbdENKdLudxJ2ENuUwN

Problems:

  1. Shouldn't you add 04 to the beginning of the uncompressed key?
  2. The address P2PKH Address: 1AQYRDSw3eUo3LuWbdENKdLudxJ2ENuUwN is the address of the compressed public key, can you add the P2PKH Address for the uncompressed public key?
    For the example above, from my calculation the P2PKH address for the uncompressed public key is 1Mw7FXN7D7du9umtbkhov2ftELKQw1wFor

Does it support MATIC cryptocurrency

I want create wallets on Polygon Mainnet and Testnet (Mumbai) using currency MATIC. But so far, I haven't seen MATIC on the list of available currencies.
So, my query is if python-hdwallet supports MATIC as currency in Polygon Mainnet and Testnet (Mumbai)?
If yes, then how can I do that? Any reference doc link is much appreciated.
Or, is it possible to add custom currencies to generate wallets using python-hdwallet?
Thanks in advance.
@meherett

pysha3 no longer works

Attempting to use python-hdwallet in Python 3.11 fails, with:

× Running setup.py install for pysha3 did not run successfully.
  │ exit code: 1
  ╰─> [20 lines of output]
      running install
      /opt/hostedtoolcache/Python/3.11.0/x64/lib/python3.11/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.linux-x[86](https://github.com/pjkundert/python-slip39/actions/runs/3411849600/jobs/5676582611#step:4:87)_64-cpython-311
      copying sha3.py -> build/lib.linux-x86_64-cpython-311
      running build_ext
      building '_pysha3' extension
      creating build/temp.linux-x86_64-cpython-311
      creating build/temp.linux-x86_64-cpython-311/Modules
      creating build/temp.linux-x86_64-cpython-311/Modules/_sha3
      gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPY_WITH_KECCAK=1 -I/opt/hostedtoolcache/Python/3.11.0/x64/include/python3.11 -c Modules/_sha3/sha3module.c -o build/temp.linux-x86_64-cpython-311/Modules/_sha3/sha3module.o
      In file included from Modules/_sha3/sha3module.c:20:
      Modules/_sha3/backport.inc:78:10: fatal error: pystrhex.h: No such file or directory
         78 | #include "pystrhex.h"
            |          ^~~~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]

The pysha3 module is used only for Keccak hashing, so can be replaced by the pycrptodome modules's Crypto.Hash.keccak. I've added tests to ensure this transition results in the same hashes.

In the future, it might be possible to also eliminate the edcsa module and use pycryptodome for ECDSA as well.

Fixed in #69

difference between address keys

what is the difference between root_xprivate_key and xprivate_key OR root_xpublic_key and xpublic_key ?
where is account extended private key and account extended public key ?

{
    "cryptocurrency": "Bitcoin",
    "symbol": "BTC",
    "network": "mainnet",
    "strength": 160,
    "entropy": "c5b0d0ee698f3f72b6265f1bc591f8f2d7afa6dd",
    "mnemonic": "주일 액수 명단 천둥 해수욕장 전망 추천 직업 그룹 단위 신체 파란색 시청 천천히 스트레스",
    "language": "korean",
    "passphrase": null,
    "seed": "5a9b9667ccd07b3c641b1ba95e9119dd1d5a3034fd46cd2f27fc1f160c7dcd824fc0ab4710a9ae90582dffc3b0803bcbc0a8160feeaab4c70511c5035859decf",
    "root_xprivate_key": "xprv9s21ZrQH143K2qMHU8aghJ4MoQR5g5mowXbeP2vCP937bseZGX929dmJudL7u4xRxtKvh58pxz1PhtCbWW2yUH14jdduKVMV9FkBMpM2Hyw",
    "root_xpublic_key": "xpub661MyMwAqRbcFKRkaA7h4S16MSFa5YVfJkXFBRKowUa6Ufyhp4TGhS5nkvkLXSmdNjoszzDkU26WW2rg1zBsQBt6Pv3T8oLEAExGHD3hcQs",
    "xprivate_key": "xprvA2YyMZWyPK2xo4eZgyypp2CzcHnxNzGbruGg7vmgaAVCtBtrjwzuhXJBNM3FrwBh85ajxHErNR6ByN77WJARpC1HDC7kTwa2yr7Mu9Pz5Qq",
    "xpublic_key": "xpub6FYKm53sDgbG1Yj2o1WqBA9jAKdSnSzTE8CGvKBJ8W2BkzE1HVKAFKcfDcCHKpL5BQRg2HjbNSt55jpFshY7W1KFtp7zjB3DhNAmiFv6kzB",
    "uncompressed": "081016370b45d7e23bd89b07d6886036f5e4df9a129eee3b488c177ba7881856e24d337b280f9d32539a22445e567543b39b708edf5289442f36dcde958a3433",
    "compressed": "03081016370b45d7e23bd89b07d6886036f5e4df9a129eee3b488c177ba7881856",
    "chain_code": "cf9ee427ed8073e009a5743056e8cf19167f67ca5082c2c6635b391e9a4e0b0d",
    "private_key": "f79495fda777197ce73551bcd8e162ceca19167575760d3cc2bced4bf2a213dc",
    "public_key": "03081016370b45d7e23bd89b07d6886036f5e4df9a129eee3b488c177ba7881856",
    "wif": "L5WyVfBu8Sz3iGZtrwJVSP2wDJmu7HThGd1EGekFBnviWgzLXpJd",
    "finger_print": "ac13e305",
    "semantic": "p2pkh",
    "path": "m/44'/0'/0'/0/0",
    "hash": "ac13e305a88bd9968f1c058fcf5d9a6b1b9ef484",
    "addresses": {
        "p2pkh": "1Ggs3kkNrPPWoW17iDFQWgMdw3CD8BzBiv",
        "p2sh": "3GQVUFePz517Hf61Vsa9H2tHj5jw5y6ngV",
        "p2wpkh": "bc1q4sf7xpdg30vedrcuqk8u7hv6dvdeaayy3uw5cj",
        "p2wpkh_in_p2sh": "3JyV5aSgdVYEjQodPWHfvehQ5227EDr3sN",
        "p2wsh": "bc1qnk0s9q4379n6v9vg0lnhdu5qhjyx99u2xm238pmckmjg9v29q54saddzp9",
        "p2wsh_in_p2sh": "3MmsEoP7GLHzuLVgkAtcRtyXLTWh8zNAcd"
    }
}

Question

how i can get address of CKD account. I mean regular one for Etherum? You have only :
p2pkh=self.p2pkh_address(),
p2sh=self.p2sh_address(),
p2wpkh=self.p2wpkh_address(),
p2wpkh_in_p2sh=self.p2wpkh_in_p2sh_address(),
p2wsh=self.p2wsh_address(),
p2wsh_in_p2sh=self.p2wsh_in_p2sh_address()

, but don't have regular one. I miss something?

implementing transactions

Hi,
Thanks once again for this useful tool. I have been able to integrate hdwallet with my app.

I am stucked at signing, verifying and broadcasting of transactions. Please I need help.

Generate independent Mnemonic Phrase for address

I want to generate a independent Mnemonic Phrase, but with the code generate the same Mnemonic Phrase:

import mnemonic
import threading
from hdwallet import BIP44HDWallet
from hdwallet.cryptocurrencies import EthereumMainnet
from hdwallet.derivations import BIP44Derivation
from hdwallet.utils import generate_mnemonic
from typing import Optional
from  etherscan import Etherscan
from requests import get
from matplotlib import pyplot as plt
from datetime import datetime
import time
import os
import sys

MNEMONIC: str = generate_mnemonic(language="english", strength=128)
PASSPHRASE: Optional[str] = None  # "meherett"
bip44_hdwallet: BIP44HDWallet = BIP44HDWallet(cryptocurrency=EthereumMainnet)
bip44_hdwallet.from_mnemonic(
mnemonic=MNEMONIC, language="english", passphrase=PASSPHRASE
)

bip44_hdwallet.clean_derivation()
for address_index in range(2): # Mnemonic Quantity to generate 
    bip44_derivation: BIP44Derivation = BIP44Derivation(
        cryptocurrency=EthereumMainnet, account=0, change=False, address=address_index
    )
    bip44_hdwallet.from_path(path=bip44_derivation)
    bip44_hdwallet.clean_derivation()
    print(f"{bip44_hdwallet.mnemonic()}")

    os.system(f'echo {bip44_hdwallet.mnemonic()} >> /home/mnemonic.txt')

Create BitcoinCash from privatekey [bitcoincash:qr...]

How create bitcoincash address (bitcoincash:qr...) from this package ???
used this source , not worked to this type address :

from hdwallwet import HDWallet
from hdwallet.symbols import BCH as SYMBOL
hdwallet: HDWallet = HDWallet(symbol=SYMBOL)
hdwallet.from_private_key(private_key=private_key)
addr = hdwallet.p2wpkh_address()
print(addr)
# out: bc1qgrdf2l6z6u78zpdj4excxp44r4amquxlalcnpd

i need this address type : bitcoincash:q....

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.