{ "info": { "author": "", "author_email": "", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8" ], "description": "[![Package version](https://img.shields.io/pypi/v/python-bitcointx.svg)](https://pypi.python.org/pypi/python-bitcointx)\n[![Package license](https://img.shields.io/pypi/l/python-bitcointx.svg)](https://pypi.python.org/pypi/python-bitcointx)\n[![Python versions](https://img.shields.io/pypi/pyversions/python-bitcointx.svg)](https://pypi.python.org/pypi/python-bitcointx)\n[![Build Status](https://travis-ci.org/Simplexum/python-bitcointx.svg?branch=master)](https://pypi.python.org/pypi/python-bitcointx)\n\n# python-bitcointx\n\nThis Python3 library provides an easy interface to the bitcoin transaction data\nstructures. This is based on https://github.com/petertodd/python-bitcoinlib,\nbut is focused only on providing the tools to build, manipulate and sign\nbitcoin transactions, and related data structures.\n\n## Notable differences from python-bitcoinlib\n\n* Network-related code that deals with network messages and blocks is removed.\n* Some API have changed and may be not compatible with old code (see below)\n* libsecp256k1 is used for signing and verifying.\n Signing by libsecp256k1 is deterministic, per RFC6979.\n* HD keys support\n* Easier to build code that supports and interacts with other bitcoin-based blockchains\n (see https://github.com/Simplexum/python-litecointx and https://github.com/Simplexum/python-elementstx)\n* A wrapper for `libbitcoinconsensus`'s script verification function is included\n\n## Note on v1.0.0 release\n\nThe switch to v1.0.0 does not signify that the library is in any way more\n'mature' or 'stable' or 'production-ready' than the v0.10.x.The switch to the\nnew major version was done purely because of the big refactoring effort\nthat was made to improve the consistency of the library API,\nmake it more composeable and maintainable. This required significant API\nbreakage, and it made sense to bump the version.\nIf anything, the first release of the v1.0.x version should be viewed as less\nmature than the v0.10.x, because of the amount of new code that was introduced.\n\n## Requirements\n\n- Python >= 3.6\n- [libsecp256k1](https://github.com/bitcoin-core/secp256k1)\n- [libbitcoinconsensus](https://github.com/bitcoin/bitcoin/blob/master/doc/shared-libraries.md) (optional, for consensus-compatible script verification)\n- [openssl](https://github.com/openssl/openssl) (optional, only for historical signatures verification)\n\n## Installation\n\n```\n$ pip install python-bitcointx\n```\n\n```\n$ pipenv install python-bitcointx\n```\n\n```\n$ poetry add python-bitcointx\n```\n\n## Structure\n\nEverything consensus critical is found in the modules under bitcointx.core. This\nrule is followed pretty strictly, for instance chain parameters are split into\nconsensus critical and non-consensus-critical.\n\n bitcointx.core - Basic core definitions, datastructures, and\n (context-independent) validation\n bitcointx.core.key - ECC pubkeys\n bitcointx.core.script - Scripts and opcodes\n bitcointx.core.scripteval - Script evaluation/verification\n bitcointx.core.serialize - Serialization\n bitcointx.core.secp256k1 - functions to interface with secp256k1 C library\n (Note: to safely use it, experience with C\n and understanting of python-C interop is a must)\n bitcointx.core.sha256 - (Slow) python implementation of SHA256,\n but with ability to get SHA256 mid-state\n bitcointx.core.bitcoinconsensus\n - ctypes wrapping code for libbitcoinconsensus script\n verification function, with interface compatible\n with VerifyScript from bitcointx.core.scripteval\n\nNote that this code is does not aim to be fully consensus-compatible with current\nbitcoin core codebase. Corner cases that is not relevant to creating valid bitcoin\ntransactions is unlikely to be considered. See also note on VerifyScript usage below.\n\nNon-consensus critical modules include the following:\n\n bitcointx - Chain selection\n bitcointx.base58 - Base58 encoding\n bitcointx.bech32 - Bech32 encoding\n bitcointx.rpc - Bitcoin Core RPC interface support\n bitcointx.wallet - Wallet-related code, currently Bitcoin address and\n private key support\n bitcointx.util - various code-related utitlity classes and functions\n\nEffort has been made to follow the Satoshi source relatively closely, for\ninstance Python code and classes that duplicate the functionality of\ncorresponding Satoshi C++ code uses the same naming conventions: CTransaction,\nCPubKey, nValue etc. Otherwise Python naming conventions are followed.\n\n## Mutable vs. Immutable objects\n\nLike the Bitcoin Core codebase CTransaction is immutable and\nCMutableTransaction is mutable; unlike the Bitcoin Core codebase this\ndistinction also applies to COutPoint, CTxIn, CTxOut and CTxWitness.\n\n\n## Endianness Gotchas\n\nRather confusingly Bitcoin Core shows transaction and block hashes as\nlittle-endian hex rather than the big-endian the rest of the world uses for\nSHA256. python-bitcointx provides the convenience functions x() and lx() in\nbitcointx.core to convert from big-endian and little-endian hex to raw bytes to\naccomodate this. In addition see b2x() and b2lx() for conversion from bytes to\nbig/little-endian hex.\n\n## API changes vs python-bitcoinlib\n\nNote: only public API changes is listed here\n\n* `CBitcoinAddress()` won't work: you will need to use `CCoinAddress` (universal, the class of returned instance depends on current chain params), or `CBitcoinTestnetAddress`/`CBitcoinRegtestAddress` directly. `CBitcoinAddress` is used only for Bitcoin mainnet addresses.\n* `rpc.Proxy` removed, `rpc.RPCCaller` added (same as old `rpc.RawProxy`, but `btc_conf_file` kwarg renamed to just `conf_file`). If old rpc.Proxy functionality is desired, it should be implemented as a separate library.\n* `CTransaction` default version changed to 2\n* `CKey.is_valid`, `CKey.is_fullyvalid` and `CKey.is_compressed` should now be called as methods: `key.is_valid()`, not `key.is_valid`.\n* `CBitcoinAddressError` is removed, `CCoinAddressError` should be used instead\n* Chain params for bitcoin is renamed, instead of 'mainnet', 'testnet', 'regtest' it is now 'bitcoin', 'bitcoin/testnet', 'bitcoin/mainnet'\n* `CBech32Data.from_bytes` - changed arg order, witver is now kwarg\n* `CTxWitness` is now immutable, `CMutableTxWitness` is added.\n* If mutable components supplied to CTransaction, they will be internally converted to immutable, and vise versa with CMutableTransaction\n* string representations (returned by `repr` and `str`) of various objects will often differ from that of python-bitcoinlib's.\n* `COIN`, `MAX_MONEY`, etc. moved to `CoreCoinParams` class, that can be\nsubclassed and will be dispatched similar to `CTransaction` and friends. It is recommended to use `MoneyRange()` and `coins_to_satoshi()`, `satoshi_to_coins()` functions. The two former functions will also raise ValueError if supplied/returned value is outside of MoneyRange. (unless `check_range=False` is passed)\n* `MoneyRange()` function does not accept `params=` argument anymore. To get money range for different params, you can use `with ChainParams():`.\n\n## Note on VerifyScript() usage\n\n`VerifyScript()` in `bitcointx.core.scripteval` is (incomplete) python implementation\nof Bitcoin script interpreter. It may be useful for debugging purposes.\n\nBut! Bitcoin Core should _always_ remain the authoritative source on bitcoin\ntransaction inputs validity.\n\nIf you want script verification with consensus rules, you should use libbitcoinconsensus\n(https://github.com/bitcoin/bitcoin/blob/master/doc/shared-libraries.md), available\nvia `ConsensusVerifyScript()` in `bitcointx.core.bitcoinconensus`.\n\nScript evaluation code of VerifyScript() is NOT in sync with Bitcoin Core code,\nand lacks some features. While some effort was made to make it behave closer\nto the code in Bitcoin Core, full compatibility is far away, and most likely\nwill not be ever achieved.\n\n**WARNING**: DO NOT rely on VerifyScript() in deciding if certain signed\ntransaction input is valid. In some corner cases (non-standard signature encoding,\nunhandled script evaluation flags, etc) it may deem something invalid that bitcoind\nwould accept as valid. More importanty, it could accept something as valid\nthat bitcoind would deem invalid. `ConsensusVerifyScript()` should be suitable for\nthat purpose, as it is just a thin wrapper over the C library `libbitcoinconsensus`.\n\n## Module import style\n\nWhile not always good style, it's often convenient for quick scripts if\n`import *` can be used. To support that all the modules have `__all__` defined\nappropriately.\n\n\n# Example Code\n\nSee `examples/` directory. For instance this example creates a transaction\nspending a pay-to-script-hash transaction output:\n\n $ PYTHONPATH=. examples/spend-pay-to-script-hash-txout.py\n \n\n\n## Selecting the chain to use\n\nDo the following:\n\n import bitcointx\n bitcointx.select_chain_params(NAME)\n\nWhere NAME is one of 'bitcoin', 'bitcoin/testnet', or 'bitcoin/regtest'.\nThe chain parameters currently selected is a thread-local variable that changes\nbehavior everywhere. If you need to change the parameters temporary, you can use\n`ChainParams` context manager. To get current chain params, you can use\n`get_current_chain_params()`:\n\n```python\nfrom bitcointx import ChainParams, get_current_chain_params\nwith ChainParams('bitcoin/testnet'):\n params = get_current_chain_params()\n print(f\"{params.readable_name} params ({params.name}) are in effect\")\n```\nwill print\n\n```\nBitcoin testnet params (bitcoin/testnet) are in effect\n```\n\n## Unit tests\n\nUnder bitcointx/tests using test data from Bitcoin Core. To run them:\n\n python3 -m unittest discover\n\nAlternately, if Tox (see https://tox.readthedocs.org/) is available on your\nsystem, you can run unit tests for multiple Python versions:\n\n ./runtests.sh\n\nCurrently, the following implementations are tried (any not installed are\nskipped):\n\n * CPython 3.6\n * CPython 3.7\n * CPython 3.8-dev\n * PyPy3\n\nHTML coverage reports can then be found in the htmlcov/ subdirectory.\n\n## Documentation\n\nSphinx documentation is in the \"doc\" subdirectory. Run \"make help\" from there\nto see how to build. You will need the Python \"sphinx\" package installed.\n\nCurrently this is just API documentation generated from the code and\ndocstrings. Higher level written docs would be useful, perhaps starting with\nmuch of this README. Pages are written in reStructuredText and linked from\nindex.rst.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Simplexum/python-bitcointx", "keywords": "bitcoin", "license": "", "maintainer": "", "maintainer_email": "", "name": "python-bitcointx", "package_url": "https://pypi.org/project/python-bitcointx/", "platform": "", "project_url": "https://pypi.org/project/python-bitcointx/", "project_urls": { "Homepage": "https://github.com/Simplexum/python-bitcointx" }, "release_url": "https://pypi.org/project/python-bitcointx/1.0.1/", "requires_dist": null, "requires_python": ">=3.6", "summary": "The Swiss Army Knife of the Bitcoin transactions.", "version": "1.0.1" }, "last_serial": 5855625, "releases": { "0.10.2": [ { "comment_text": "", "digests": { "md5": "3c9f09cb7280cf2b3e39cecbdf3757f1", "sha256": "055adfb2f7ed06b774f004f03587c3dd9ad2799c6b6d9aaf6f6ce9102299f171" }, "downloads": -1, "filename": "python-bitcointx-0.10.2.tar.gz", "has_sig": false, "md5_digest": "3c9f09cb7280cf2b3e39cecbdf3757f1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 194111, "upload_time": "2018-12-08T21:27:28", "url": "https://files.pythonhosted.org/packages/5c/70/b7b9f9e5fd582104def3bafaa9e16b282f90de5739082d2f12b898f2a2f4/python-bitcointx-0.10.2.tar.gz" } ], "0.10.3": [ { "comment_text": "", "digests": { "md5": "e3031244076a9ef9bc5a2549e6e9cf26", "sha256": "9b1d41a1795a327d3cb3fa14f767f98523b84a08b831cecb87aef017a3bb7235" }, "downloads": -1, "filename": "python-bitcointx-0.10.3.tar.gz", "has_sig": false, "md5_digest": "e3031244076a9ef9bc5a2549e6e9cf26", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 195937, "upload_time": "2018-12-14T23:13:06", "url": "https://files.pythonhosted.org/packages/1c/e3/cf20a663b0361d0605eaa965cdaf1c54a68d986b100222f0a3ea22633d02/python-bitcointx-0.10.3.tar.gz" } ], "0.10.3.post0": [ { "comment_text": "", "digests": { "md5": "72df8e4464fd16a58163a0b92cbff998", "sha256": "6ed11b931940cf3199313c729e2ce3127cead4b33c7022fbbdfe0ce94d6d2d88" }, "downloads": -1, "filename": "python-bitcointx-0.10.3.post0.tar.gz", "has_sig": false, "md5_digest": "72df8e4464fd16a58163a0b92cbff998", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 196021, "upload_time": "2018-12-16T18:58:01", "url": "https://files.pythonhosted.org/packages/e0/ff/3e9a81ff59c06786cbc6cca316e58f12efbb68d4987170ac673d906f8ec1/python-bitcointx-0.10.3.post0.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "69425813299d10d8db20240b0f2f7bf5", "sha256": "f8866d5a33139378278842fd28f3bdbb12444ab0c1d0778e2a46e1768043ceef" }, "downloads": -1, "filename": "python-bitcointx-1.0.0.tar.gz", "has_sig": false, "md5_digest": "69425813299d10d8db20240b0f2f7bf5", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 200078, "upload_time": "2019-09-13T14:34:35", "url": "https://files.pythonhosted.org/packages/9a/b2/c8ef276e7dfedc9db7230f0ad371f201d0bfa81db5d7380e7c69ab096b1a/python-bitcointx-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "94b730319aa063f38fc456e352343027", "sha256": "40ef74c64000dcc0790b38ed3ffbde1916ea67b6cd40f4f5fa41866e9397fedf" }, "downloads": -1, "filename": "python-bitcointx-1.0.1.tar.gz", "has_sig": false, "md5_digest": "94b730319aa063f38fc456e352343027", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 200267, "upload_time": "2019-09-19T11:13:38", "url": "https://files.pythonhosted.org/packages/f3/05/b966ca0e25f040584c5b41abbf4b05f06c3f0a98f501007a46f97b541361/python-bitcointx-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "94b730319aa063f38fc456e352343027", "sha256": "40ef74c64000dcc0790b38ed3ffbde1916ea67b6cd40f4f5fa41866e9397fedf" }, "downloads": -1, "filename": "python-bitcointx-1.0.1.tar.gz", "has_sig": false, "md5_digest": "94b730319aa063f38fc456e352343027", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 200267, "upload_time": "2019-09-19T11:13:38", "url": "https://files.pythonhosted.org/packages/f3/05/b966ca0e25f040584c5b41abbf4b05f06c3f0a98f501007a46f97b541361/python-bitcointx-1.0.1.tar.gz" } ] }