{ "info": { "author": "The Exonum Team", "author_email": "contact@exonum.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Topic :: Security :: Cryptography" ], "description": "# Exonum Python Light Client\n\n[![Travis Build Status](https://travis-ci.com/exonum/exonum-python-client.svg?branch=master)](https://travis-ci.com/exonum/exonum-python-client)\n[![codecov](https://codecov.io/gh/exonum/exonum-python-client/branch/master/graph/badge.svg)](https://codecov.io/gh/exonum/exonum-python-client)\n\nPython client for the [Exonum Framework][exonum].\n\n## Overview\n\nExonum Light Client is a Python library for working with Exonum blockchain\nfrom the client side. It can be easily integrated to an existing\napplication. Also, Exonum Light Client provides access to common utils\ntoolkit which contains some helpful functions for hashing, cryptography,\nserialization, etc.\n\n## Capabilities\n\nBy using the client you are able to perform the following operations:\n\n- Submit transactions to the node\n- Receive information on transactions\n- Receive information on blockchain blocks\n- Receive information on the node system\n- Receive information on the node status\n\n## Compatibility\n\nThe following table shows versions compatibility: \n\n| Light Client | Exonum |\n|--------------|-------------------------|\n| 0.1 | 0.9.* |\n| 0.2 | 0.10.* |\n| 0.3.1 | 0.12.* |\n| 1.0.x | 1.0.* |\n| master | `exonum` master branch |\n\n## System Dependencies\n\n- Python 3.5 or above.\n- Package installer for Python3 (pip3)\n\n## Examples\n\nThe following example shows how to create an instance of the Exonum client\nwhich will be able to work with an Exonum node with the\nCryptocurrency Advanced service mounted on it, at `http://localhost:8080`\naddress:\n\n### Installing Python Light Client\n\nFirst of all we need to install our client library:\n\n```shell\ngit clone git@github.com:exonum/exonum-python-client.git\npip3 install -e exonum-python-client --no-binary=protobuf\n```\n\n### Exonum Client Initialization\n\n```python\nfrom exonum_client import ExonumClient, ModuleManager, MessageGenerator\nfrom exonum_client.crypto import KeyPair\n\nclient = ExonumClient(hostname=\"localhost\", public_api_port=8080, private_api_port=8081, ssl=False)\n```\n\n### Compiling Proto Files\n\nTo compile proto files into the Python analogues we need a protobuf loader:\n\n```python\nwith client.protobuf_loader() as loader:\n # Your code goes here.\n```\n\nSince loader acquires resources on initialization, creating via context manager is recommended.\nOtherwise you should initialize and deinitialize client manually:\n\n```python\nloader = client.protobuf_loader()\nloader.initialize()\n# ... Some usage\nloader.deinitialize()\n```\n\nThen we need to run the following code:\n\n```python\nloader.load_main_proto_files() # Load and compile main proto files, such as `runtime.proto`, `consensus.proto`, etc.\nloader.load_service_proto_files(runtime_id=0, service_name='exonum-supervisor:1.0.0') # Same for specific service.\n```\n\n- runtime_id=0 here means, that service works in Rust runtime.\n\n### Creating Transaction Messages\n\nThe following example shows how to create a transaction message:\n\n```python\nalice_keys = KeyPair.generate()\n\ncryptocurrency_artifact_name = \"exonum-cryptocurrency-advanced\"\ncryptocurrency_artifact_version = \"1.0.0\"\nloader.load_service_proto_files(\n runtime_id=0, \n artifact_name=cryptocurrency_artifact_name, \n artifact_version=cryptocurrency_artifact_version\n)\n\ncryptocurrency_module = ModuleManager.import_service_module(\n cryptocurrency_artifact_name, cryptocurrency_artifact_version, \"service\"\n)\n\ncryptocurrency_message_generator = MessageGenerator(\n instance_id=1024, \n artifact_name=cryptocurrency_artifact_name, \n artifact_version=cryptocurrency_artifact_version\n)\n\ncreate_wallet_alice = cryptocurrency_module.CreateWallet()\ncreate_wallet_alice.name = 'Alice'\n\ncreate_wallet_alice_tx = cryptocurrency_message_generator.create_message(create_wallet_alice)\ncreate_wallet_alice_tx.sign(alice_keys)\n```\n\n- 1024 - service instance ID.\n- alice_keys - public and private keys of the ed25519 public-key signature\nsystem.\n\nAfter invoking the sign method, we get a signed transaction.\nThis transaction is ready for sending to the Exonum node.\n\n### Sending Transaction to the Exonum Node\n\nAfter successfully sending the message, we'll get a response which will\ncontain a hash of the transaction:\n\n```python\nresponse = client.public_api.send_transaction(create_wallet_alice_tx)\n```\n\n```json\n{\n \"tx_hash\": \"3541201bb7f367b802d089d8765cc7de3b7dfc253b12330b8974268572c54c01\"\n}\n```\n\n### Subscribing to events\n\nIf you want to subscribe to events (subscription_type: \"transactions\" or \"blocks\"), use the following code:\n\n```python\nwith client.create_subscriber(subscription_type=\"blocks\") as subscriber:\n subscriber.wait_for_new_event()\n subscriber.wait_for_new_event()\n```\n\nContext manager will automatically create a connection and will disconnect after use.\nOr you can manually do the same:\n\n```python\nsubscriber = client.create_subscriber(subscription_type=\"blocks\")\nsubscriber.connect()\n# ... Your code\nsubscriber.stop()\n```\n\nKeep in mind that if you forget to stop the subscriber, you may discover HTTP\nerrors when you try to use Exonum API.\n\n### Getting Data on the Available Services\n\n```python\nclient.public_api.available_services().json()\n```\n\nThe code will show a list of the artifacts available for the start and a list of\nworking services:\n\n```python\n{\n \"artifacts\": [\n {\n \"runtime_id\": 0,\n \"name\": \"exonum-supervisor\",\n \"version\": \"1.0.0\"\n },\n {\n \"runtime_id\": 0,\n \"name\": \"exonum-explorer-service\",\n \"version\": \"1.0.0\"\n }\n ],\n \"services\": [\n {\n \"spec\": {\n \"id\": 2,\n \"name\": \"explorer\",\n \"artifact\": {\n \"runtime_id\": 0,\n \"name\": \"exonum-explorer-service\",\n \"version\": \"1.0.0\"\n }\n },\n \"status\": \"Active\",\n \"pending_status\": null\n },\n {\n \"spec\": {\n \"id\": 0,\n \"name\": \"supervisor\",\n \"artifact\": {\n \"runtime_id\": 0,\n \"name\": \"exonum-supervisor\",\n \"version\": \"1.0.0\"\n }\n },\n \"status\": \"Active\",\n \"pending_status\": null\n }\n ]\n}\n```\n\n### More Examples\n\nTo see more examples and find out how to work with proofs go [here][proof].\n\nAlso you can find the sample scripts at the [examples](examples) section.\n\n### Testing\n\nTo run tests, use the following command:\n\n```sh\npython3 -m unittest\n```\n\n### Contributing\n\nYou can see notes for developers in the [Contribution Guide](CONTRIBUTING.md)\npage.\n\n### Known Problems\n\nIf within use you discover the following error:\n\n```sh\nTypeError: Couldn't build proto file into descriptor pool!\n```\n\nIt is due to the issue with Protobuf binary wheels. The only work around is to\ninstall the pure Python implementation.\n\n```sh\npip uninstall protobuf\npip install --no-binary=protobuf protobuf\n```\n\n## License\n\nApache 2.0 - see [LICENSE](LICENSE) for more information.\n\n[exonum]: https://github.com/exonum/exonum\n[protoc]: https://developers.google.com/protocol-buffers/docs/reference/python-generated\n[proof]: PROOF.md", "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/exonum/exonum-python-client", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "exonum-python-client", "package_url": "https://pypi.org/project/exonum-python-client/", "platform": "", "project_url": "https://pypi.org/project/exonum-python-client/", "project_urls": { "Homepage": "https://github.com/exonum/exonum-python-client" }, "release_url": "https://pypi.org/project/exonum-python-client/1.0.1/", "requires_dist": null, "requires_python": ">=3.4", "summary": "Exonum Python Light Client", "version": "1.0.1", "yanked": false, "yanked_reason": null }, "last_serial": 6934981, "releases": { "0.3.1": [ { "comment_text": "", "digests": { "md5": "f50737f7fc10967c8bf916022c67bc29", "sha256": "8d145affd8f54f381366595b9677b12381e572c18b9df97128e03ae906a14f27" }, "downloads": -1, "filename": "exonum-python-client-0.3.1.tar.gz", "has_sig": false, "md5_digest": "f50737f7fc10967c8bf916022c67bc29", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4", "size": 33880, "upload_time": "2019-10-03T11:36:11", "upload_time_iso_8601": "2019-10-03T11:36:11.908917Z", "url": "https://files.pythonhosted.org/packages/66/62/84c25b97fe5d788cb59298031f30c1a229b3bb8fcc71755ea4f1c98c9c11/exonum-python-client-0.3.1.tar.gz", "yanked": false, "yanked_reason": null } ], "0.4.0.dev1": [ { "comment_text": "", "digests": { "md5": "1359beef2e72a839a8008ffe31ce4253", "sha256": "b99e046d24019d13eab1238543215c44bb4b0cdc7bc758a3ec6aa34727c65cf6" }, "downloads": -1, "filename": "exonum-python-client-0.4.0.dev1.tar.gz", "has_sig": false, "md5_digest": "1359beef2e72a839a8008ffe31ce4253", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4", "size": 32895, "upload_time": "2019-10-23T09:36:50", "upload_time_iso_8601": "2019-10-23T09:36:50.526100Z", "url": "https://files.pythonhosted.org/packages/57/c7/392a0afe78d5bacaa8f01d63bb0ebf3415e09378ef200a268ee42801dc34/exonum-python-client-0.4.0.dev1.tar.gz", "yanked": false, "yanked_reason": null } ], "0.4.0.dev2": [ { "comment_text": "", "digests": { "md5": "33b841b610674bef7c0a4503d2dfbc05", "sha256": "206a26f730e871d1b25010a6b6bd2bf7a10eb8071ca5ab9d11144af5c1fb11d6" }, "downloads": -1, "filename": "exonum-python-client-0.4.0.dev2.tar.gz", "has_sig": false, "md5_digest": "33b841b610674bef7c0a4503d2dfbc05", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4", "size": 30889, "upload_time": "2019-11-22T08:44:51", "upload_time_iso_8601": "2019-11-22T08:44:51.596918Z", "url": "https://files.pythonhosted.org/packages/a3/d6/39b51d1ba63dd473ad3ef1c54843d7e5faba327f9c7038430ae8004d9030/exonum-python-client-0.4.0.dev2.tar.gz", "yanked": false, "yanked_reason": null } ], "0.4.0.dev3": [ { "comment_text": "", "digests": { "md5": "59f6ec8e71fe4414f3cb96bb4d608cf0", "sha256": "a01ce0fc1ef2d3391c28d4ed13fd7c4e74d7e884c8e91338699efe1ca194cae2" }, "downloads": -1, "filename": "exonum-python-client-0.4.0.dev3.tar.gz", "has_sig": false, "md5_digest": "59f6ec8e71fe4414f3cb96bb4d608cf0", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4", "size": 31396, "upload_time": "2019-11-27T12:49:06", "upload_time_iso_8601": "2019-11-27T12:49:06.419647Z", "url": "https://files.pythonhosted.org/packages/a4/c1/1ccfad2b2b3f4ba32d24dcc287796837efe14557de0a3880995d3a600f02/exonum-python-client-0.4.0.dev3.tar.gz", "yanked": false, "yanked_reason": null } ], "0.4.0.dev4": [ { "comment_text": "", "digests": { "md5": "58208c11c6d4b609c2601612734c8a26", "sha256": "0e6434676f6c4bc769b0fbc1178517ac2b89cb37029dc97d3294a25d8e4c228e" }, "downloads": -1, "filename": "exonum-python-client-0.4.0.dev4.tar.gz", "has_sig": false, "md5_digest": "58208c11c6d4b609c2601612734c8a26", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4", "size": 32610, "upload_time": "2019-12-03T09:28:28", "upload_time_iso_8601": "2019-12-03T09:28:28.415734Z", "url": "https://files.pythonhosted.org/packages/83/7b/22eb5b352c0d9f74e4ad9c0d63960af0e56affbaa8376de0d12a973999a4/exonum-python-client-0.4.0.dev4.tar.gz", "yanked": false, "yanked_reason": null } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "34068d25280f33f21fa6fef33b3774e0", "sha256": "2ddc52c8dfd47f1b10c6e97cb3ff497315a6c7d68f0c8ca5356442c9b257e557" }, "downloads": -1, "filename": "exonum-python-client-1.0.1.tar.gz", "has_sig": false, "md5_digest": "34068d25280f33f21fa6fef33b3774e0", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4", "size": 41203, "upload_time": "2020-04-02T11:22:06", "upload_time_iso_8601": "2020-04-02T11:22:06.037912Z", "url": "https://files.pythonhosted.org/packages/53/c3/b40669915ddc0fc9df41647c88816048a39649627888c2ec40d027c5ae05/exonum-python-client-1.0.1.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "34068d25280f33f21fa6fef33b3774e0", "sha256": "2ddc52c8dfd47f1b10c6e97cb3ff497315a6c7d68f0c8ca5356442c9b257e557" }, "downloads": -1, "filename": "exonum-python-client-1.0.1.tar.gz", "has_sig": false, "md5_digest": "34068d25280f33f21fa6fef33b3774e0", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4", "size": 41203, "upload_time": "2020-04-02T11:22:06", "upload_time_iso_8601": "2020-04-02T11:22:06.037912Z", "url": "https://files.pythonhosted.org/packages/53/c3/b40669915ddc0fc9df41647c88816048a39649627888c2ec40d027c5ae05/exonum-python-client-1.0.1.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }