Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
035c717
Merge pull request #13 from coin-tracker/update-readme
meherett May 27, 2021
a2910a8
Merge remote-tracking branch 'origin/master'
meherett Jun 11, 2021
3869c07
Update: Testing doc and added development doc.
meherett Jun 11, 2021
e630169
Add: Root xpublic key derivation cleaner.
meherett Jun 18, 2021
98b15fd
Bump: HDWallet from v1.3.0 to v1.3.1 package.
meherett Jun 18, 2021
749bf8c
Fix: Incorrect output of Base58 decoding.
martinholy Jun 22, 2021
07ace7e
Merge pull request #18 from martinholy/base58_decode_fix
meherett Jun 22, 2021
fcb16c7
add ZECTEST
saloppe73 Jul 22, 2021
697e9e7
update README
saloppe73 Jul 22, 2021
b876ad4
fix LTC/LTCTEST
saloppe73 Jul 22, 2021
aeda29b
Merge pull request #19 from saloppe73/master
meherett Jul 24, 2021
a480596
Update README.md
meherett Jul 26, 2021
e79db28
Fixed BIP141 link
sokripon Aug 12, 2021
d75afc9
Merge pull request #23 from sokripon/patch-1
meherett Aug 12, 2021
78517c5
Fixed link for BIP84
sokripon Aug 12, 2021
8da78de
Fixed link for BIP141
sokripon Aug 12, 2021
8a4924a
Merge pull request #24 from sokripon/patch-1
meherett Aug 12, 2021
71620d2
Bump: HDWallet from v1.3.1 to v1.3.2 package.
meherett Sep 2, 2021
0fa4a52
Fix: Zcash symbol ticker and added symbols tester.
meherett Sep 2, 2021
d7488ef
Bump: HDWallet from v1.3.1 to v1.3.2 package.
meherett Sep 2, 2021
500d840
Change: Coveralls runner python package version to 3.8
meherett Sep 2, 2021
3b76caf
Change: Coveralls runner python form v3.8 to v3.9 package.
meherett Sep 2, 2021
41b6a01
Added version info
bombs-kim Sep 13, 2021
cd8c4f5
Merge pull request #26 from bombs-kim/master
meherett Sep 13, 2021
b8ce968
Fix derivation from xpubs
alecov Oct 8, 2021
01aa683
Add a testcase for xpub derivation
alecov Oct 8, 2021
30330b8
Add support for DeSo
alecov Jan 19, 2022
aa0c4a3
Convert bytes to str in *_base58check()
alecov Jan 26, 2022
075f739
Updates
alecov Feb 24, 2022
166f7ae
Add missing check in `private_key_base58check()`
alecov Mar 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 33 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![Coverage Status](https://coveralls.io/repos/github/meherett/python-hdwallet/badge.svg?branch=master)](https://coveralls.io/github/meherett/python-hdwallet?branch=master)

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 the chain.
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.

Expand All @@ -19,8 +19,8 @@ For more info see the BIP specs.
| [BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) | Hierarchical Deterministic Wallets |
| [BIP44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki) | Multi-Account Hierarchy for Deterministic Wallets |
| [BIP49](https://github.com/bitcoin/bips/blob/master/bip-0049.mediawiki) | Derivation scheme for P2WPKH-nested-in-P2SH based accounts |
| [BIP84](https://github.com/bitcoin/bips/blob/master/bip-0048.mediawiki) | Derivation scheme for P2WPKH based accounts |
| [BIP141](https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki) | Segregated Witness (Consensus layer) |
| [BIP84](https://github.com/bitcoin/bips/blob/master/bip-0084.mediawiki) | Derivation scheme for P2WPKH based accounts |
| [BIP141](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki) | Segregated Witness (Consensus layer) |

## Installation

Expand Down Expand Up @@ -168,7 +168,7 @@ for address_index in range(10):

```shell script
Mnemonic: bright demand olive glance crater key head glory quantum leisure intact age
Base HD Path: m/44'/60'/0'/0/{address_index}
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
Expand All @@ -185,18 +185,37 @@ Base HD Path: m/44'/60'/0'/0/{address_index}

[Click this to see more examples :)](https://github.com/meherett/python-hdwallet/blob/master/examples)

## Development

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

```
pip install -e .[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](https://github.com/meherett/hdwallet/issues) 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.
Feel free to open an [issue](https://github.com/meherett/hdwallet/issues) 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](https://github.com/meherett/hdwallet/blob/master/CONTRIBUTING.md) file.

## Available Cryptocurrencies

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

| Cryptocurrencies | Symbols | Mainnet | Testnet | Segwit | Coin Type | Default Paths |
| :---------------------------------------------------------------- | :------------------: | :-----: | :-----: | :----: | :-------: | :------------------: |
Expand Down Expand Up @@ -337,24 +356,17 @@ This library simplifies the process of creating a new HDWallet's for:
| XUEZ | `XUEZ` | Yes | No | No | 225 | `m/44'/225'/0'/0/0` |
| [XinFin](https://github.com/XinFinOrg/XDPoSChain) | `XDC` | Yes | No | Yes | 550 | `m/44'/550'/0'/0/0` |
| ZClassic | `ZCL` | Yes | No | No | 147 | `m/44'/147'/0'/0/0` |
| Zcash | `ZEC` | Yes | No | No | 133 | `m/44'/133'/0'/0/0` |
| [Zcash](https://github.com/zcash/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:

Ethereum (ETH) or Tether (USDT-ERC20) address:
If You found this tool helpful consider making a donation:

```text
0x342798bbe9731a91e0557fa8ab0bce1eae6d6ae3
```

Bitcoin (BTC) address:

```text
3GGNPvgbSpMHShcaZJGDXQn5wUJyTz7uoC
```
| Coins | Addresses |
| ----------------------------- | :----------------------------------------: |
| Bitcoin `BTC` | 3GGNPvgbSpMHShcaZJGDXQn5wUJyTz7uoC |
| Ethereum `ETH`, Tether `USDT` | 0x342798bbe9731a91e0557fa8ab0bce1eae6d6ae3 |

## License

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
author = "Meheret Tesfaye"

# The full version, including alpha/beta/rc tags
release = "1.3.0"
release = "1.3.2"

# The master toctree document.
master_doc = "toctree"
Expand Down
7 changes: 7 additions & 0 deletions docs/cryptocurrencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,13 @@ This library simplifies the process of generating a new HDWallet's for:
- No
- 116
- m/44'/116'/0'/0/0
* - `DeSo <https://github.com/deso-protocol>`_
- DESO, DESOTEST
- Yes
- Yes
- Yes
- 0
- m/44'/0'/0'/0/0
* - Diamond
- DMD
- Yes
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ For more info see the BIP specs.
- Derivation scheme for P2WPKH-nested-in-P2SH based accounts
* - `BIP84 <https://github.com/bitcoin/bips/blob/master/bip-0084.mediawiki>`_
- Derivation scheme for P2WPKH based accounts
* - `BIP141 <https://github.com/bitcoin/bips/blob/master/bip-00141.mediawiki>`_
* - `BIP141 <https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki>`_
- Segregated Witness (Consensus layer)
2 changes: 2 additions & 0 deletions hdwallet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
__all__ = [
"HDWallet", "BIP32HDWallet", "BIP44HDWallet", "BIP49HDWallet", "BIP84HDWallet", "BIP141HDWallet"
]

__version__ = "1.3.2"
143 changes: 119 additions & 24 deletions hdwallet/cryptocurrencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,19 @@ class Cryptocurrency(NestedNamespace):
SOURCE_CODE: Optional[str]
COIN_TYPE: CoinType

SCRIPT_ADDRESS: int
PUBLIC_KEY_ADDRESS: int
SEGWIT_ADDRESS: SegwitAddress
SCRIPT_ADDRESS: Optional[int] = None
PUBLIC_KEY_ADDRESS: int = 0
PRIVATE_KEY_ADDRESS: int = 0
SEGWIT_ADDRESS: Optional[SegwitAddress] = None

EXTENDED_PRIVATE_KEY: ExtendedPrivateKey
EXTENDED_PUBLIC_KEY: ExtendedPublicKey

MESSAGE_PREFIX: Optional[str]
DEFAULT_PATH: str
WIF_SECRET_KEY: int
WIF_SECRET_KEY: Optional[int] = None

DEFAULT_SEMANTIC: str = "p2pkh"


class AnonMainnet(Cryptocurrency):
Expand Down Expand Up @@ -712,6 +715,7 @@ class BitcoinMainnet(Cryptocurrency):
MESSAGE_PREFIX = "\x18Bitcoin Signed Message:\n"
DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0"
WIF_SECRET_KEY = 0x80
DEFAULT_SEMANTIC = "p2wpkh"


class BitcoinPlusMainnet(Cryptocurrency):
Expand Down Expand Up @@ -832,6 +836,7 @@ class BitcoinTestnet(Cryptocurrency):
MESSAGE_PREFIX = "\x18Bitcoin Signed Message:\n"
DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0"
WIF_SECRET_KEY = 0xef
DEFAULT_SEMANTIC = "p2wpkh"


class BitcoinZMainnet(Cryptocurrency):
Expand Down Expand Up @@ -1674,6 +1679,56 @@ class DenariusMainnet(Cryptocurrency):
WIF_SECRET_KEY = 0x9e


class DeSoMainnet(Cryptocurrency):

NAME = "DeSo"
SYMBOL = "DESO"
NETWORK = "mainnet"
SOURCE_CODE = "https://github.com/deso-protocol"
COIN_TYPE = CoinType({
"INDEX": 0,
"HARDENED": True
})

PUBLIC_KEY_ADDRESS = 0xCD1400
PRIVATE_KEY_ADDRESS = 0x350000
EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({
"BASE58CHECK": 0x0488ade4
})
EXTENDED_PUBLIC_KEY = ExtendedPublicKey({
"BASE58CHECK": 0x0488b21e
})

MESSAGE_PREFIX = "\x18DeSo Signed Message:\n"
DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0"
DEFAULT_SEMANTIC = "base58check"


class DeSoTestnet(Cryptocurrency):

NAME = "DeSo"
SYMBOL = "DESOTEST"
NETWORK = "testnet"
SOURCE_CODE = "https://github.com/deso-protocol"
COIN_TYPE = CoinType({
"INDEX": 0,
"HARDENED": True
})

PUBLIC_KEY_ADDRESS = 0x11C200
PRIVATE_KEY_ADDRESS = 0x4F061B
EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({
"BASE58CHECK": 0x04358394
})
EXTENDED_PUBLIC_KEY = ExtendedPublicKey({
"BASE58CHECK": 0x043587cf
})

MESSAGE_PREFIX = "\x18DeSo Signed Message:\n"
DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0"
DEFAULT_SEMANTIC = "base58check"


class DiamondMainnet(Cryptocurrency):

NAME = "Diamond"
Expand Down Expand Up @@ -3213,18 +3268,18 @@ class LitecoinMainnet(Cryptocurrency):
})

EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({
"P2PKH": 0x019d9cfe,
"P2SH": 0x019d9cfe,
"P2WPKH": 0x04b2430c,
"P2WPKH_IN_P2SH": 0x01b26792,
"P2PKH": 0x488ade4,
"P2SH": 0x488ade4,
"P2WPKH": None,
"P2WPKH_IN_P2SH": None,
"P2WSH": None,
"P2WSH_IN_P2SH": None
})
EXTENDED_PUBLIC_KEY = ExtendedPublicKey({
"P2PKH": 0x019da462,
"P2SH": 0x019da462,
"P2WPKH": 0x04b24746,
"P2WPKH_IN_P2SH": 0x01b26ef6,
"P2PKH": 0x488b21e,
"P2SH": 0x488b21e,
"P2WPKH": None,
"P2WPKH_IN_P2SH": None,
"P2WSH": None,
"P2WSH_IN_P2SH": None
})
Expand All @@ -3245,33 +3300,33 @@ class LitecoinTestnet(Cryptocurrency):
"HARDENED": True
})

SCRIPT_ADDRESS = 0xc4
SCRIPT_ADDRESS = 0x3a
PUBLIC_KEY_ADDRESS = 0x6f
SEGWIT_ADDRESS = SegwitAddress({
"HRP": "litecointestnet",
"HRP": "tltc",
"VERSION": 0x00
})

EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({
"P2PKH": 0x0436ef7d,
"P2SH": 0x0436ef7d,
"P2WPKH": 0x04358394,
"P2WPKH_IN_P2SH": 0x04358394,
"P2PKH": 0x04358394,
"P2SH": 0x04358394,
"P2WPKH": None,
"P2WPKH_IN_P2SH": None,
"P2WSH": None,
"P2WSH_IN_P2SH": None
})
EXTENDED_PUBLIC_KEY = ExtendedPublicKey({
"P2PKH": 0x0436f6e1,
"P2SH": 0x0436f6e1,
"P2WPKH": 0x043587cf,
"P2WPKH_IN_P2SH": 0x043587cf,
"P2PKH": 0x043587cf,
"P2SH": 0x043587cf,
"P2WPKH": None,
"P2WPKH_IN_P2SH": None,
"P2WSH": None,
"P2WSH_IN_P2SH": None
})

MESSAGE_PREFIX = "\x19Litecoin Signed Message:\n"
DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0"
WIF_SECRET_KEY = 0xb0
WIF_SECRET_KEY = 0xef


class LitecoinZMainnet(Cryptocurrency):
Expand Down Expand Up @@ -6239,7 +6294,7 @@ class ZcashMainnet(Cryptocurrency):
NAME = "Zcash"
SYMBOL = "ZEC"
NETWORK = "mainnet"
SOURCE_CODE = None
SOURCE_CODE = "https://github.com/zcash/zcash"
COIN_TYPE = CoinType({
"INDEX": 133,
"HARDENED": True
Expand Down Expand Up @@ -6274,6 +6329,46 @@ class ZcashMainnet(Cryptocurrency):
WIF_SECRET_KEY = 0x80


class ZcashTestnet(Cryptocurrency):

NAME = "Zcash"
SYMBOL = "ZECTEST"
NETWORK = "testnet"
SOURCE_CODE = "https://github.com/zcash/zcash"
COIN_TYPE = CoinType({
"INDEX": 1,
"HARDENED": True
})

SCRIPT_ADDRESS = 0x1cba
PUBLIC_KEY_ADDRESS = 0x1d25
SEGWIT_ADDRESS = SegwitAddress({
"HRP": None,
"VERSION": 0x00
})

EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({
"P2PKH": 0x4358394,
"P2SH": 0x4358394,
"P2WPKH": None,
"P2WPKH_IN_P2SH": None,
"P2WSH": None,
"P2WSH_IN_P2SH": None
})
EXTENDED_PUBLIC_KEY = ExtendedPublicKey({
"P2PKH": 0x43587cf,
"P2SH": 0x43587cf,
"P2WPKH": None,
"P2WPKH_IN_P2SH": None,
"P2WSH": None,
"P2WSH_IN_P2SH": None
})

MASSAGE_PREFIX = "\x18Zcash Signed Message:\n"
DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0"
WIF_SECRET_KEY = 0xef


class ZencashMainnet(Cryptocurrency):

NAME = "Zencash"
Expand Down
4 changes: 2 additions & 2 deletions hdwallet/derivations.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ class BIP84Derivation(BIP32Derivation):
>>> BIP84Derivation(cryptocurrency=BitcoinMainnet)
<hdwallet.derivations.Derivation object at 0x000001EBC58E9F70>
>>> str(BIP84Derivation(cryptocurrency=BitcoinMainnet))
"m/49'/0'/0'/0/0"
"m/84'/0'/0'/0/0"
"""

PURPOSE: int = 84
Expand Down Expand Up @@ -547,7 +547,7 @@ class BIP141Derivation(Derivation):
>>> BIP141Derivation(cryptocurrency=BitcoinMainnet)
<hdwallet.derivations.Derivation object at 0x000001EBC58E9F70>
>>> str(BIP141Derivation(cryptocurrency=BitcoinMainnet))
"m/49'/0'/0'/0/0"
"m/44'/0'/0'/0/0"
"""

def __init__(self, cryptocurrency: Any, path: Union[str, Derivation] = None, semantic: str = "p2wpkh"):
Expand Down
Loading