zpywallet


Namezpywallet JSON
Version 0.6.2 PyPI version JSON
download
home_pagehttps://github.com/ZenulAbidin/pywallet
SummaryMulti-coin BIP32 (HD) wallet creation, transaction listener, creation and broadcasting
upload_time2024-01-30 06:55:29
maintainer
docs_urlNone
authorAli Sherief
requires_python
licenseMIT License
keywords bitcoin wallet litecoin hd-wallet dogecoin dashcoin ethereum address crypto python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
ZPyWallet
===========

.. image:: https://img.shields.io/pypi/pyversions/zpywallet.svg?maxAge=60
    :target: https://pypi.python.org/pypi/zpywallet
    :alt: Python version

.. image:: https://img.shields.io/pypi/v/zpywallet.svg?maxAge=60
    :target: https://pypi.python.org/pypi/zpywallet
    :alt: PyPi version

.. image:: https://img.shields.io/pypi/status/zpywallet.svg?maxAge=60
    :target: https://pypi.python.org/pypi/zpywallet
    :alt: PyPi status

.. image:: https://codecov.io/gh/ZenulAbidin/zpywallet/branch/master/graph/badge.svg?token=G2tC6LpTNm
    :target: https://codecov.io/gh/ZenulAbidin/zpywallet
    :alt: Code coverage


ZPyWallet is a Python-based hierarchical deterministic (HD) wallet generator and transaction manager.
HD wallets allow you to  generate a tree-like structure of cryptographic key pairs from a single
seed phrase, providing a convenient way to manage multiple accounts or addresses securely.

ZPyWallet can generate transactions quickly, because it defers transaction validity to the broadcasting
stage. It can also coordinate the creation and broadcasting of transactions to different nodes,
and can decode transactions as well.

BIP32 (or HD for "hierarchical deterministic") wallets allow you to create
child wallets which can only generate public keys and don't expose a
private key to an insecure server.


Features
========

- Simple BIP32 (HD) wallet creation for BTC, BCH, ETH, LTC, DASH, DOGE, and many other networks
- Generate a hierarchical deterministic wallet from a mnemonic seed phrase.
- Create and broadcast RBF-aware transactions to pre-defined or custom nodes
- Decode existing transactions
- Monitor for incoming transactions
- Get the latest fee rates for mainnet networks
- Derive multiple accounts or addresses from the generated wallet.
- Support for popular cryptocurrencies such as Bitcoin, Ethereum, and more.
- BIP32 and BIP39 compliant.
- Secure key generation using the industry-standard libsecp256k1 library, resistant to side-channel attacks.
- Supports generating P2WPKH (segwit) keys and bech32 addresses for supported networks
- Sign and verify messages in Bitcoin-Qt and RFC2440 format

Limitations
===========

- Address types that use complex scripts such as P2WSH, P2WPKH-P2SH, and Taproot currently can only be decoded but not created.
- Multisig addresses are not supported.
- Transactions cannot be created with timelocks yet.
- In the case of Ethereum, alternate chains (e.g. Testnet) are not supported yet.

History
=======

ZPyWallet started out as a fork of `PyWallet <https://github.com/ranaroussi/pywallet>` with elements of
`Bitmerchant <https://github.com/sbuss/bitmerchant>`, just to simply make these modules run. At the time,
it was just an HD wallet generator. However, as time went by, I discovered serious bugs in both programs,
such as incorrect master private key genration, and the use of ECDSA code that is vulnerable to side-channel
attacks, Thus I have embarked on a complete rewrite of the codebase so that it follows crypto security best
practices. And thus we arrive to the present day: A robust wallet generator that supports altcoins, segwit,
sign/verify, and can be used as a backend to implement custom wallet software.

Enjoy!

--------------

Installation
-------------

Install via PiP:

.. code:: bash

   $ pip install zpywallet

Or build directly:

.. code:: bash

   $ git clone https://github.com/ZenulAbidin/zpywallet
   $ cd zpywallet
   # Developers should also run "pip install -r requirements-dev.txt"
   $ python setup.py install




Example code:
=============

Note that this code is probably out-of-date.

Create HD Wallet
----------------

The following code creates a new Bitcoin HD wallet:

.. code:: python

    # create_btc_wallet.py

    from zpywallet import wallet

    # creates a wallet with a new, random mnemonic phrase.
    # By default, it creates Bitcoin Mainnet wallets.
    w = wallet.create_wallet_json(children=1)

    print(w)

Output looks like this:

.. code:: bash

    $ python create_btc_wallet.py

    {
        'address': 'bc1qjvugs62gt5w97rv4sw3kkhnmv2s2kg58lucmux',
        'children': [{'address': 'bc1q5vyxj4a6c2v4p9dxrd59vztfussg9hdywr5yrn',
                    'bip32_path': "m/44'/0'/0'/0",
                    'path': 'm/0',
                    'xpublic_key': 'xpub68yG1oCYQLpAKxj3DPo6cvqAzNEeUFMhMfEhXcEyem1vqK87QeaQH8o7uUw8fYkhtuVcMiJrxbLFDyESnK8YPQ97fSzPpPLTiauEWyqTX76'}],
        'coin': 'BTC',
        'private_key': '45471d4504a3631425371a590d168fa0df4f01c7fe5df2b355da6434145b6915',
        'public_key': '0286e42376ab09ce71b2be8174f2ebbf2f79fef9ca0c255838c2016951b7b4411f',
        'seed': 'spring ahead flat scheme can opera genre tribe airport friend nurse '
                'exclude',
        'wif': '5JLoBxMCZCAqnue56GZZLquzPwob6XHdJttKJn19qGShKQgE2xM',
        'xprivate_key': 'xprv9s21ZrQH143K28nnAjfgJ9eRCmQMYuBtbKWVZLqsEc7aBYh81uLFHQoKt2dZdSyKAu6KaFSiqjWyZejrtx3FmRjRaf1KsBFgkNM4CMm66Jh',
        'xpublic_key': 'xpub661MyMwAqRbcEcsFGmCgfHb9koEqxMujxYS6MjFUnweZ4M2GZSeVqD7ojJAE5QvmbXn16QPHcHLk5bkdkqXtcV1nj1aVyRqax9NeaTAnhH6',
        'xpublic_key_prime': 'xpub68yG1oCgk1M8XBxmkp6f6JgRdTyX6XJd7a6LmDG14DomrswTMkxGiByKiwpf5p6szSqDciybesxjDC7yKBrgbaczQe6q1puBHbvfKxg1uqr'
    }

Similarly, you can do the same for an Ethereum wallet:

.. code:: python

    # create_eth_wallet.py

    from zpywallet import wallet
    
    w = wallet.create_wallet_json(network="ETH", children=1)

    print(w)

Output looks like this (no WIF or xpub/prv for Ethereum as its not supported):

.. code:: bash

    $ python create_eth_wallet.py

    {
        'address': '0x8dbe02c146eacbe410f63348f489a16160deb6f0',
        'children': [{'address': '0xdd030270458ad17b125c200bb2f11d0fdbf7e05c',
                    'path': 'm/0'}],
        'coin': 'ETH',
        'private_key': '85b41c45f425dd1f7f431326449afc0564b2d110f7f89563f1a1ee4055a4ce39',
        'public_key': '026e93d77ee81bd28e2d2e0962928a00ee27a20f0da2b7437db8bce39e23c6d873',
        'seed': 'admit push digital opinion system snap announce help gas business '
                'trigger please',
        'wif': '',
        'xprivate_key': '',
        'xpublic_key': ''}

Consult the documentation for more information about the API.

Create Child Wallet
-------------------

You can create child-wallets (BIP32 wallets) from the HD wallet's
**Extended Public Key** to generate new public addresses without
revealing your private key.

Example:

.. code-block:: python

    # create_child_wallet.py

    from zpywallet import wallet
    from zpywallet.utils.bip32 import Wallet

    w = Wallet.from_mnemonic(wallet.generate_mnemonic())

    # generate address for specific user (id = 10)
    child_w = w.get_child_for_path("m/10")
    user_addr = child_w.address()

    print(f"User Address: {user_addr}")

Output looks like this:

.. code:: bash

    $ python create_child_wallet.py

    User Address: bc1qdwfh4duva4hvzva9cdyguh9c9k2hez3r7taerg


CONTRIBUTING
============

Bugfixes and enhancements are welcome. Please read CONTRIBUTING.md for contributing instructions.

At the moment, I'm not accepting pull requests for new coins unless they are big and historic coins such as Tether (ERC20), BNB and XMR.

SECURITY
========

This module has been hardened against various types of attacks:

- Runtime dependencies are kept to an absolute minimum. Only modules that have compile-time native
  code are installed using pip. The rest are hardcoded directly into ZPyWallet. This prevents many kinds
  of supply chain attacks.
- Coincurve is using libsecp256k1, which protects keys from various power and RF frequency analysis side-channels.


NO WARRANTY
===========

ZPyWallet is provided without any sort of warranty of any kind. Additionally, I am not responsible for damages caused by the use of this program, including but not limited to lost coins. Read the license file for full details.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ZenulAbidin/pywallet",
    "name": "zpywallet",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "bitcoin,wallet,litecoin,hd-wallet,dogecoin,dashcoin,ethereum,address,crypto,python",
    "author": "Ali Sherief",
    "author_email": "ali@notatether.com",
    "download_url": "https://files.pythonhosted.org/packages/a4/bc/d1da63baaf02fd2847933c4f0d605fa8bdb271aa964878d2dc0af528ebd9/zpywallet-0.6.2.tar.gz",
    "platform": "any",
    "description": "\nZPyWallet\n===========\n\n.. image:: https://img.shields.io/pypi/pyversions/zpywallet.svg?maxAge=60\n    :target: https://pypi.python.org/pypi/zpywallet\n    :alt: Python version\n\n.. image:: https://img.shields.io/pypi/v/zpywallet.svg?maxAge=60\n    :target: https://pypi.python.org/pypi/zpywallet\n    :alt: PyPi version\n\n.. image:: https://img.shields.io/pypi/status/zpywallet.svg?maxAge=60\n    :target: https://pypi.python.org/pypi/zpywallet\n    :alt: PyPi status\n\n.. image:: https://codecov.io/gh/ZenulAbidin/zpywallet/branch/master/graph/badge.svg?token=G2tC6LpTNm\n    :target: https://codecov.io/gh/ZenulAbidin/zpywallet\n    :alt: Code coverage\n\n\nZPyWallet is a Python-based hierarchical deterministic (HD) wallet generator and transaction manager.\nHD wallets allow you to  generate a tree-like structure of cryptographic key pairs from a single\nseed phrase, providing a convenient way to manage multiple accounts or addresses securely.\n\nZPyWallet can generate transactions quickly, because it defers transaction validity to the broadcasting\nstage. It can also coordinate the creation and broadcasting of transactions to different nodes,\nand can decode transactions as well.\n\nBIP32 (or HD for \"hierarchical deterministic\") wallets allow you to create\nchild wallets which can only generate public keys and don't expose a\nprivate key to an insecure server.\n\n\nFeatures\n========\n\n- Simple BIP32 (HD) wallet creation for BTC, BCH, ETH, LTC, DASH, DOGE, and many other networks\n- Generate a hierarchical deterministic wallet from a mnemonic seed phrase.\n- Create and broadcast RBF-aware transactions to pre-defined or custom nodes\n- Decode existing transactions\n- Monitor for incoming transactions\n- Get the latest fee rates for mainnet networks\n- Derive multiple accounts or addresses from the generated wallet.\n- Support for popular cryptocurrencies such as Bitcoin, Ethereum, and more.\n- BIP32 and BIP39 compliant.\n- Secure key generation using the industry-standard libsecp256k1 library, resistant to side-channel attacks.\n- Supports generating P2WPKH (segwit) keys and bech32 addresses for supported networks\n- Sign and verify messages in Bitcoin-Qt and RFC2440 format\n\nLimitations\n===========\n\n- Address types that use complex scripts such as P2WSH, P2WPKH-P2SH, and Taproot currently can only be decoded but not created.\n- Multisig addresses are not supported.\n- Transactions cannot be created with timelocks yet.\n- In the case of Ethereum, alternate chains (e.g. Testnet) are not supported yet.\n\nHistory\n=======\n\nZPyWallet started out as a fork of `PyWallet <https://github.com/ranaroussi/pywallet>` with elements of\n`Bitmerchant <https://github.com/sbuss/bitmerchant>`, just to simply make these modules run. At the time,\nit was just an HD wallet generator. However, as time went by, I discovered serious bugs in both programs,\nsuch as incorrect master private key genration, and the use of ECDSA code that is vulnerable to side-channel\nattacks, Thus I have embarked on a complete rewrite of the codebase so that it follows crypto security best\npractices. And thus we arrive to the present day: A robust wallet generator that supports altcoins, segwit,\nsign/verify, and can be used as a backend to implement custom wallet software.\n\nEnjoy!\n\n--------------\n\nInstallation\n-------------\n\nInstall via PiP:\n\n.. code:: bash\n\n   $ pip install zpywallet\n\nOr build directly:\n\n.. code:: bash\n\n   $ git clone https://github.com/ZenulAbidin/zpywallet\n   $ cd zpywallet\n   # Developers should also run \"pip install -r requirements-dev.txt\"\n   $ python setup.py install\n\n\n\n\nExample code:\n=============\n\nNote that this code is probably out-of-date.\n\nCreate HD Wallet\n----------------\n\nThe following code creates a new Bitcoin HD wallet:\n\n.. code:: python\n\n    # create_btc_wallet.py\n\n    from zpywallet import wallet\n\n    # creates a wallet with a new, random mnemonic phrase.\n    # By default, it creates Bitcoin Mainnet wallets.\n    w = wallet.create_wallet_json(children=1)\n\n    print(w)\n\nOutput looks like this:\n\n.. code:: bash\n\n    $ python create_btc_wallet.py\n\n    {\n        'address': 'bc1qjvugs62gt5w97rv4sw3kkhnmv2s2kg58lucmux',\n        'children': [{'address': 'bc1q5vyxj4a6c2v4p9dxrd59vztfussg9hdywr5yrn',\n                    'bip32_path': \"m/44'/0'/0'/0\",\n                    'path': 'm/0',\n                    'xpublic_key': 'xpub68yG1oCYQLpAKxj3DPo6cvqAzNEeUFMhMfEhXcEyem1vqK87QeaQH8o7uUw8fYkhtuVcMiJrxbLFDyESnK8YPQ97fSzPpPLTiauEWyqTX76'}],\n        'coin': 'BTC',\n        'private_key': '45471d4504a3631425371a590d168fa0df4f01c7fe5df2b355da6434145b6915',\n        'public_key': '0286e42376ab09ce71b2be8174f2ebbf2f79fef9ca0c255838c2016951b7b4411f',\n        'seed': 'spring ahead flat scheme can opera genre tribe airport friend nurse '\n                'exclude',\n        'wif': '5JLoBxMCZCAqnue56GZZLquzPwob6XHdJttKJn19qGShKQgE2xM',\n        'xprivate_key': 'xprv9s21ZrQH143K28nnAjfgJ9eRCmQMYuBtbKWVZLqsEc7aBYh81uLFHQoKt2dZdSyKAu6KaFSiqjWyZejrtx3FmRjRaf1KsBFgkNM4CMm66Jh',\n        'xpublic_key': 'xpub661MyMwAqRbcEcsFGmCgfHb9koEqxMujxYS6MjFUnweZ4M2GZSeVqD7ojJAE5QvmbXn16QPHcHLk5bkdkqXtcV1nj1aVyRqax9NeaTAnhH6',\n        'xpublic_key_prime': 'xpub68yG1oCgk1M8XBxmkp6f6JgRdTyX6XJd7a6LmDG14DomrswTMkxGiByKiwpf5p6szSqDciybesxjDC7yKBrgbaczQe6q1puBHbvfKxg1uqr'\n    }\n\nSimilarly, you can do the same for an Ethereum wallet:\n\n.. code:: python\n\n    # create_eth_wallet.py\n\n    from zpywallet import wallet\n    \n    w = wallet.create_wallet_json(network=\"ETH\", children=1)\n\n    print(w)\n\nOutput looks like this (no WIF or xpub/prv for Ethereum as its not supported):\n\n.. code:: bash\n\n    $ python create_eth_wallet.py\n\n    {\n        'address': '0x8dbe02c146eacbe410f63348f489a16160deb6f0',\n        'children': [{'address': '0xdd030270458ad17b125c200bb2f11d0fdbf7e05c',\n                    'path': 'm/0'}],\n        'coin': 'ETH',\n        'private_key': '85b41c45f425dd1f7f431326449afc0564b2d110f7f89563f1a1ee4055a4ce39',\n        'public_key': '026e93d77ee81bd28e2d2e0962928a00ee27a20f0da2b7437db8bce39e23c6d873',\n        'seed': 'admit push digital opinion system snap announce help gas business '\n                'trigger please',\n        'wif': '',\n        'xprivate_key': '',\n        'xpublic_key': ''}\n\nConsult the documentation for more information about the API.\n\nCreate Child Wallet\n-------------------\n\nYou can create child-wallets (BIP32 wallets) from the HD wallet's\n**Extended Public Key** to generate new public addresses without\nrevealing your private key.\n\nExample:\n\n.. code-block:: python\n\n    # create_child_wallet.py\n\n    from zpywallet import wallet\n    from zpywallet.utils.bip32 import Wallet\n\n    w = Wallet.from_mnemonic(wallet.generate_mnemonic())\n\n    # generate address for specific user (id = 10)\n    child_w = w.get_child_for_path(\"m/10\")\n    user_addr = child_w.address()\n\n    print(f\"User Address: {user_addr}\")\n\nOutput looks like this:\n\n.. code:: bash\n\n    $ python create_child_wallet.py\n\n    User Address: bc1qdwfh4duva4hvzva9cdyguh9c9k2hez3r7taerg\n\n\nCONTRIBUTING\n============\n\nBugfixes and enhancements are welcome. Please read CONTRIBUTING.md for contributing instructions.\n\nAt the moment, I'm not accepting pull requests for new coins unless they are big and historic coins such as Tether (ERC20), BNB and XMR.\n\nSECURITY\n========\n\nThis module has been hardened against various types of attacks:\n\n- Runtime dependencies are kept to an absolute minimum. Only modules that have compile-time native\n  code are installed using pip. The rest are hardcoded directly into ZPyWallet. This prevents many kinds\n  of supply chain attacks.\n- Coincurve is using libsecp256k1, which protects keys from various power and RF frequency analysis side-channels.\n\n\nNO WARRANTY\n===========\n\nZPyWallet is provided without any sort of warranty of any kind. Additionally, I am not responsible for damages caused by the use of this program, including but not limited to lost coins. Read the license file for full details.\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Multi-coin BIP32 (HD) wallet creation, transaction listener, creation and broadcasting",
    "version": "0.6.2",
    "project_urls": {
        "Homepage": "https://github.com/ZenulAbidin/pywallet"
    },
    "split_keywords": [
        "bitcoin",
        "wallet",
        "litecoin",
        "hd-wallet",
        "dogecoin",
        "dashcoin",
        "ethereum",
        "address",
        "crypto",
        "python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f435ce89dcdc29ba962c7c7e3cb03d7342013a69815ba7e5ace890875175fda4",
                "md5": "9a69c1f0dbbabf99c273e7e55cf3a19a",
                "sha256": "264345ac4013d4b8452089af0ee13cdb6e4e20b399007fa29101bd4efbb7ccf9"
            },
            "downloads": -1,
            "filename": "zpywallet-0.6.2-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9a69c1f0dbbabf99c273e7e55cf3a19a",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 234810,
            "upload_time": "2024-01-30T06:55:28",
            "upload_time_iso_8601": "2024-01-30T06:55:28.165381Z",
            "url": "https://files.pythonhosted.org/packages/f4/35/ce89dcdc29ba962c7c7e3cb03d7342013a69815ba7e5ace890875175fda4/zpywallet-0.6.2-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a4bcd1da63baaf02fd2847933c4f0d605fa8bdb271aa964878d2dc0af528ebd9",
                "md5": "66e27df398668400f97e68a4f19c72cc",
                "sha256": "a038ccd12fdb3973ec387952097a57423c057de42184f67015d8a0dd8cbac23f"
            },
            "downloads": -1,
            "filename": "zpywallet-0.6.2.tar.gz",
            "has_sig": false,
            "md5_digest": "66e27df398668400f97e68a4f19c72cc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 185858,
            "upload_time": "2024-01-30T06:55:29",
            "upload_time_iso_8601": "2024-01-30T06:55:29.587837Z",
            "url": "https://files.pythonhosted.org/packages/a4/bc/d1da63baaf02fd2847933c4f0d605fa8bdb271aa964878d2dc0af528ebd9/zpywallet-0.6.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-30 06:55:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ZenulAbidin",
    "github_project": "pywallet",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "zpywallet"
}
        
Elapsed time: 0.17763s