Skip to content

Repository files navigation

Hierarchical Deterministic Wallet

Build StatusPyPI VersionDocumentation StatusPyPI LicensePyPI Python VersionCoverage 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.

For more info see the BIP specs.

BIP'sTitles
BIP39Mnemonic code for generating deterministic keys
BIP85Deterministic Entropy From BIP32 Keychains
BIP32Hierarchical Deterministic Wallets
BIP44Multi-Account Hierarchy for Deterministic Wallets
BIP49Derivation scheme for P2WPKH-nested-in-P2SH based accounts
BIP84Derivation scheme for P2WPKH based accounts
BIP141Segregated 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 python3fromhdwalletimportHDWalletfromhdwallet.utilsimportgenerate_entropyfromhdwallet.symbolsimportBTCasSYMBOLfromtypingimportOptionalimportjson# Choose strength 128, 160, 192, 224 or 256STRENGTH: int=160# Default is 128# Choose language english, french, italian, spanish, chinese_simplified, chinese_traditional, japanese or koreanLANGUAGE: str="korean"# Default is english# Generate new entropy hex stringENTROPY: str=generate_entropy(strength=STRENGTH)
# Secret passphrase for mnemonicPASSPHRASE: Optional[str] =None# "meherett"# Initialize Bitcoin mainnet HDWallethdwallet: HDWallet=HDWallet(symbol=SYMBOL, use_default_path=False)
# Get Bitcoin HDWallet from entropyhdwallet.from_entropy(
entropy=ENTROPY, language=LANGUAGE, passphrase=PASSPHRASE
)
# Derivation from path# hdwallet.from_path("m/44'/0'/0'/0/0")# Or derivation from indexhdwallet.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'sprint(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-CLI wallet look's like:

#!/usr/bin/env python3fromhdwalletimportBIP44HDWalletfromhdwallet.cryptocurrenciesimportEthereumMainnetfromhdwallet.derivationsimportBIP44Derivationfromhdwallet.utilsimportgenerate_mnemonicfromtypingimportOptional# Generate english mnemonic wordsMNEMONIC: str=generate_mnemonic(language="english", strength=128)
# Secret passphrase/password for mnemonicPASSPHRASE: Optional[str] =None# "meherett"# Initialize Ethereum mainnet BIP44HDWalletbip44_hdwallet: BIP44HDWallet=BIP44HDWallet(cryptocurrency=EthereumMainnet)
# Get Ethereum BIP44HDWallet from mnemonicbip44_hdwallet.from_mnemonic(
mnemonic=MNEMONIC, language="english", passphrase=PASSPHRASE
)
# Clean default BIP44 derivation indexes/pathsbip44_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 indexforaddress_indexinrange(10):
# Derivation from Ethereum BIP44 derivation pathbip44_derivation: BIP44Derivation=BIP44Derivation(
cryptocurrency=EthereumMainnet, account=0, change=False, address=address_index
)
# Drive Ethereum BIP44HDWalletbip44_hdwallet.from_path(path=bip44_derivation)
# Print address_index, path, address and private_keyprint(f"({address_index}) {bip44_hdwallet.path()}{bip44_hdwallet.address()} 0x{bip44_hdwallet.private_key()}")
# Clean derivation indexes/pathsbip44_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:

CryptocurrenciesSymbolsMainnetTestnetSegwitCoin TypeDefault Paths
AnonANONYesNoNo220m/44'/220'/0'/0/0
ArgoneumAGMYesNoNo421m/44'/421'/0'/0/0
ArtaxXAXYesNoNo219m/44'/219'/0'/0/0
AryacoinAYAYesNoNo357m/44'/357'/0'/0/0
AsiacoinACYesNoNo51m/44'/51'/0'/0/0
AtomATOMYesNoYes118m/44'/118'/0'/0/0
AuroracoinAURYesNoNo85m/44'/85'/0'/0/0
AxeAXEYesNoNo4242m/44'/4242'/0'/0/0
BataBTAYesNoNo89m/44'/89'/0'/0/0
Beetle CoinBEETYesNoNo800m/44'/800'/0'/0/0
Bela CoinBELAYesNoNo73m/44'/73'/0'/0/0
Bit CloudBTDXYesNoNo218m/44'/218'/0'/0/0
Bit SendBSDYesNoNo91m/44'/91'/0'/0/0
Bitcoin CashBCHYesNoYes145m/44'/145'/0'/0/0
Bitcoin GoldBTGYesNoYes156m/44'/156'/0'/0/0
BitcoinBTC, BTCTESTYesYesYes0m/44'/0'/0'/0/0
Bitcoin PlusXBCYesNoNo65m/44'/65'/0'/0/0
Bitcoin SVBSVYesNoNo236m/44'/236'/0'/0/0
BitcoinZBTCZYesNoNo177m/44'/177'/0'/0/0
BitcoreBTXYesNoYes160m/44'/160'/0'/0/0
BlackcoinBLKYesNoNo10m/44'/10'/0'/0/0
Block StampBSTYesNoYes254m/44'/254'/0'/0/0
BlocknodeBND, BNDTESTYesYesNo2941m/44'/2941'/0'/0/0
BolivarcoinBOLIYesNoNo278m/44'/278'/0'/0/0
Brit CoinBRITYesNoNo70m/44'/70'/0'/0/0
CPU ChainCPUYesNoYes363m/44'/363'/0'/0/0
Canada eCoinCDNYesNoNo34m/44'/34'/0'/0/0
CannacoinCCNYesNoNo19m/44'/19'/0'/0/0
ClamsCLAMYesNoNo23m/44'/23'/0'/0/0
Club CoinCLUBYesNoNo79m/44'/79'/0'/0/0
CompcoinCMPYesNoNo71m/44'/71'/0'/0/0
Crane PayCRPYesNoYes2304m/44'/2304'/0'/0/0
CraveCRAVEYesNoNo186m/44'/186'/0'/0/0
DashDASH, DASHTESTYesYesNo5m/44'/5'/0'/0/0
Deep OnionONIONYesNoYes305m/44'/305'/0'/0/0
DefcoinDFCYesNoNo1337m/44'/1337'/0'/0/0
DenariusDNRYesNoNo116m/44'/116'/0'/0/0
DiamondDMDYesNoNo152m/44'/152'/0'/0/0
Digi ByteDGBYesNoYes20m/44'/20'/0'/0/0
DigitalcoinDGCYesNoNo18m/44'/18'/0'/0/0
DogecoinDOGE, DOGETESTYesYesNo3m/44'/3'/0'/0/0
EDR CoinEDRCYesNoNo56m/44'/56'/0'/0/0
EcoinECNYesNoNo115m/44'/115'/0'/0/0
EinsteiniumEMC2YesNoNo41m/44'/41'/0'/0/0
ElastosELAYesNoNo2305m/44'/2305'/0'/0/0
EnergiNRGYesNoNo9797m/44'/9797'/0'/0/0
EthereumETHYesNoYes60m/44'/60'/0'/0/0
Europe CoinERCYesNoNo151m/44'/151'/0'/0/0
Exclusive CoinEXCLYesNoNo190m/44'/190'/0'/0/0
FIXFIX, FIXTESTYesYesNo336m/44'/336'/0'/0/0
FeathercoinFTCYesNoNo8m/44'/8'/0'/0/0
FirstcoinFRSTYesNoNo167m/44'/167'/0'/0/0
FlashcoinFLASHYesNoNo120m/44'/120'/0'/0/0
Fuji CoinFJCYesNoYes75m/44'/75'/0'/0/0
GCR CoinGCRYesNoNo49m/44'/49'/0'/0/0
Game CreditsGAMEYesNoNo101m/44'/101'/0'/0/0
Go ByteGBXYesNoNo176m/44'/176'/0'/0/0
GridcoinGRCYesNoNo84m/44'/84'/0'/0/0
Groestl CoinGRS, GRSTESTYesYesYes17m/44'/17'/0'/0/0
GuldenNLGYesNoNo87m/44'/87'/0'/0/0
HelleniccoinHNCYesNoNo168m/44'/168'/0'/0/0
HempcoinTHCYesNoNo113m/44'/113'/0'/0/0
HushHUSHYesNoNo197m/44'/197'/0'/0/0
IX CoinIXCYesNoNo86m/44'/86'/0'/0/0
Insane CoinINSNYesNoNo68m/44'/68'/0'/0/0
Internet Of PeopleIOPYesNoNo66m/44'/66'/0'/0/0
JumbucksJBSYesNoNo26m/44'/26'/0'/0/0
KobocoinKOBOYesNoNo196m/44'/196'/0'/0/0
KomodoKMDYesNoNo141m/44'/141'/0'/0/0
LBRY CreditsLBCYesNoNo140m/44'/140'/0'/0/0
LinxLINXYesNoNo114m/44'/114'/0'/0/0
Litecoin CashLCCYesNoNo192m/44'/192'/0'/0/0
LitecoinLTC, LTCTESTYesYesYes2m/44'/2'/0'/0/0
LitecoinZLTZYesNoNo221m/44'/221'/0'/0/0
LkrcoinLKRYesNoNo557m/44'/557'/0'/0/0
LynxLYNXYesNoNo191m/44'/191'/0'/0/0
MazacoinMZCYesNoNo13m/44'/13'/0'/0/0
MegacoinMECYesNoNo217m/44'/217'/0'/0/0
MinexcoinMNXYesNoNo182m/44'/182'/0'/0/0
MonacoinMONAYesNoYes22m/44'/22'/0'/0/0
Monkey ProjectMONKYesNoYes214m/44'/214'/0'/0/0
MyriadcoinXMYYesNoNo90m/44'/90'/0'/0/0
NIXNIXYesNoYes400m/44'/400'/0'/0/0
NamecoinNMCYesNoNo7m/44'/7'/0'/0/0
NavcoinNAVYesNoNo130m/44'/130'/0'/0/0
NeblioNEBLYesNoNo146m/44'/146'/0'/0/0
NeoscoinNEOSYesNoNo25m/44'/25'/0'/0/0
NeurocoinNROYesNoNo110m/44'/110'/0'/0/0
New York CoinNYCYesNoNo179m/44'/179'/0'/0/0
NovacoinNVCYesNoNo50m/44'/50'/0'/0/0
NuBitsNBTYesNoNo12m/44'/12'/0'/0/0
NuSharesNSRYesNoNo11m/44'/11'/0'/0/0
OK CashOKYesNoNo69m/44'/69'/0'/0/0
OmniOMNI, OMNITESTYesYesNo200m/44'/200'/0'/0/0
Onix CoinONXYesNoNo174m/44'/174'/0'/0/0
PeercoinPPCYesNoNo6m/44'/6'/0'/0/0
PesobitPSBYesNoNo62m/44'/62'/0'/0/0
PhorePHRYesNoNo444m/44'/444'/0'/0/0
PinkcoinPINKYesNoNo117m/44'/117'/0'/0/0
PivxPIVX, PIVXTESTYesYesNo119m/44'/119'/0'/0/0
Posw CoinPOSWYesNoNo47m/44'/47'/0'/0/0
PotcoinPOTYesNoNo81m/44'/81'/0'/0/0
Project CoinPRJYesNoNo533m/44'/533'/0'/0/0
PutincoinPUTYesNoNo122m/44'/122'/0'/0/0
QtumQTUM, QTUMTESTYesYesYes2301m/44'/2301'/0'/0/0
RSKRBTC, RBTCTESTYesYesNo137m/44'/137'/0'/0/0
RapidsRPDYesNoNo320m/44'/320'/0'/0/0
RavencoinRVNYesNoNo175m/44'/175'/0'/0/0
ReddcoinRDDYesNoNo4m/44'/4'/0'/0/0
RubycoinRBYYesNoNo16m/44'/16'/0'/0/0
SafecoinSAFEYesNoNo19165m/44'/19165'/0'/0/0
SaluscoinSLSYesNoNo572m/44'/572'/0'/0/0
ScribeSCRIBEYesNoNo545m/44'/545'/0'/0/0
Shadow CashSDC, SDCTESTYesYesNo35m/44'/35'/0'/0/0
SlimcoinSLM, SLMTESTYesYesNo63m/44'/63'/0'/0/0
SmileycoinSMLYYesNoNo59m/44'/59'/0'/0/0
SolarcoinSLRYesNoNo58m/44'/58'/0'/0/0
StashSTASHYesNoNo49344m/44'/49344'/0'/0/0
StratisSTRAT, STRATTESTYesYesNo105m/44'/105'/0'/0/0
SugarchainSUGAR, SUGARTESTYesYesYes408m/44'/408'/0'/0/0
SyscoinSYSYesNoYes57m/44'/57'/0'/0/0
TOA CoinTOAYesNoNo159m/44'/159'/0'/0/0
Thought AITHTYesNoNo502m/44'/502'/0'/0/0
TronTRXYesNoNo195m/44'/195'/0'/0/0
TwinsTWINS, TWINSTESTYesYesNo970m/44'/970'/0'/0/0
Ultimate Secure CashUSCYesNoNo112m/44'/112'/0'/0/0
UnobtaniumUNOYesNoNo92m/44'/92'/0'/0/0
Virtual CashVASHYesNoNo33m/44'/33'/0'/0/0
VcashVCYesNoNo127m/44'/127'/0'/0/0
Verge CurrencyXVGYesNoNo77m/44'/77'/0'/0/0
VertcoinVTCYesNoYes28m/44'/28'/0'/0/0
ViacoinVIA, VIATESTYesYesYes14m/44'/14'/0'/0/0
VivoVIVOYesNoNo166m/44'/166'/0'/0/0
WhitecoinXWCYesNoNo559m/44'/559'/0'/0/0
WincoinWCYesNoNo181m/44'/181'/0'/0/0
XUEZXUEZYesNoNo225m/44'/225'/0'/0/0
XinFinXDCYesNoYes550m/44'/550'/0'/0/0
ZClassicZCLYesNoNo147m/44'/147'/0'/0/0
ZcashZEC, ZECTESTYesYesNo133m/44'/133'/0'/0/0
ZencashZENYesNoNo121m/44'/121'/0'/0/0

Donations

If You found this tool helpful consider making a donation:

CoinsAddresses
Bitcoin BTC3GGNPvgbSpMHShcaZJGDXQn5wUJyTz7uoC
Ethereum ETH, Tether USDT0x342798bbe9731a91e0557fa8ab0bce1eae6d6ae3

License

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

About

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

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages