{ "info": { "author": "Jinhwan Choi", "author_email": "jinhwanlazy@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "[![Build Status](https://travis-ci.org/StellarCN/py-stellar-base.svg)](https://travis-ci.org/StellarCN/py-stellar-base)\n\n# Note\nPython libraries that allow you to interface with the Boscoin horizon interface.\nBoscoin-base library consists of classes to read, write, hash, and sign the xdr structures that are used in boscoin-core.\nCurrently testnet is connected to that of stellar, but it will be fixed once\nBoscoin starts to run thier own.\n\n\n# Installation\n \u00a0 \u00a0`pip install boscoin-base`\n# Quick Start\n\n## 1. Create a Stellar key pair\nThere are 2 methods for generating a key pair in `py-boscoin-base`.\n\n### 1.1 Random generation\n```python\n from boscoin_base.keypair import Keypair\n kp = Keypair.random()\n``` \n\n### 1.2 Deterministic generation\nOr we may generate from a Unicode mnemonic string:\n```python\n from boscoin_base.utils import StellarMnemonic\n sm = StellarMnemonic(\"chinese\") # here we use chinese, but default language is 'english'\n m = sm.generate() \n # or m = u'\u57df \u76d1 \u60dc \u56fd \u671f \u78b1 \u73cd \u7ee7 \u9020 \u76d1 \u5265 \u7535' (must add u'' before the string if using Python 2)\n kp = Keypair.deterministic(m, lang='chinese')\n```\nAfter the key pair generation, we can get a public key/seed from it:\n ```python\n publickey = kp.address().decode()\n seed = kp.seed().decode()\n``` \nThe public key is also your account address. If someone needs to send you a transaction, you should share with them this key.\nThe seed is your secret. For safety, please keep it local and never send it through the Internet.\n\nWhenever we forget/lose your public key, we can regenerate the key pair from the seed:\n```python\n from boscoin_base.keypair import Keypair\n kp = Keypair.from_seed(seed)\n``` \nThis is my favorite key pair in TESTNET, let's use them in the following steps.\n```python\n publickey = 'GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG'\n seed = 'SCVLSUGYEAUC4MVWJORB63JBMY2CEX6ATTJ5MXTENGD3IELUQF4F6HUB'\n``` \n\n## 2.Create Account\nAfter the key pair generation, you have already got the address, but it is not activated until someone transfers at least 20 lumen into it. \n\n### 2.1 Testnet\nIf you want to play in the Stellar test network, you can ask our Friendbot to create an account for you as shown below:\n```python\n import requests\n publickey=kp.address().decode()\n r=requests.get('https://horizon-testnet.stellar.org/friendbot?addr='+publickey)\n```\n### 2.2 Livenet\nOn the other hand, if you would like to create an account in the livenet, you should buy some BOS from an exchange.\nWhen you withdraw the BOS into your new account, the exchange will automatically create the account for you.\nHowever, if you want to create an account from another account of your own, you may run the following code:\n```python\n from boscoin_base.keypair import Keypair\n from boscoin_base.asset import Asset\n from boscoin_base.operation import Payment\n from boscoin_base.operation import CreateAccount\n from boscoin_base.transaction import Transaction\n from boscoin_base.transaction_envelope import TransactionEnvelope as Te\n from boscoin_base.memo import TextMemo\n from boscoin_base.horizon import horizon_testnet, horizon_livenet\n\n oldAccountSeed = \"SCVLSUGYEAUC4MVWJORB63JBMY2CEX6ATTJ5MXTENGD3IELUQF4F6HUB\"\n newAccountAddress = \"XXX\"\n amount = '25' # Any amount higher than 0.1\n kp = Keypair.from_seed(oldAccountSeed)\n horizon = horizon_livenet()\n asset = Asset(\"BOS\")\n # create op \n op = CreateAccount({\n 'destination': newAccountAddress,\n 'starting_balance': amount\n })\n # create a memo\n msg = TextMemo('')\n # get sequence of new account address\n sequence = horizon.account(kp.address()).get('sequence')\n # construct the transaction\n tx = Transaction(\n source=kp.address().decode(),\n opts={\n 'sequence': sequence,\n #'timeBounds': [],\n 'memo': msg,\n #'fee': 10000,\n 'operations': [\n op,\n ],\n },\n )\n # build envelope\n envelope = Te(tx=tx, opts={\"network_id\": \"PUBLIC\"})\n # sign \n envelope.sign(kp)\n # submit\n xdr = envelope.xdr()\n response = horizon.submit(xdr)\n\n```\nThen, you can check the status of this operation with the response.\n\n## 3. Check account\n### 3.1 Basic info\nAfter creating the account, we may check the basic information of the account.\n```python\n from boscoin_base.address import Address\n publickey = 'GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG'\n address = Address(address=publickey) # address = Address(address=publickey,network='public') for livenet\n address.get() # get the updated information\n```\nNow you can check the address `balance`, `sequence`, `flags`, `signers`, `data` etc.\n```python\n print \"balances: \" + address.balances\n print \"sequence: \" + address.sequence\n print \"flags: \" + address.flags\n print \"signers: \" + address.signers\n print \"data: \" + address.data\n```\n\n### 3.2 Check payments\nWe can check the most recent payments by:\n`address.payments()`\n\nWe can use three parameters to customize the query: `limit`, `order`, and `cursor` (`paging_token`), and the default value for them are respectively: `limit=10, order=\"asc\", cursor=0`.\n\nSo if you need to check payments after a specific cursor, try:\n`address.payments(cursor='4225135422738433', limit=20, order='asc')`\n\nHorizon has SSE support for push data, if you really want to, use it like this: `address.payments(sse=True, cursor='4225135422738433')`\n\n### 3.3 Check others\nJust like payments, we can check `transactions`, `effects`, `offers`, and `operations` by:\n```python\n address.transactions()\n address.effects()\n address.offers()\n address.operations()\n```\nBy the way, offers do not have SSE support.\n\n## 4. Building transaction\nWe can build a transaction with a wrapper or from scratch.\n\n### 4.1 Build with a wrapper\n```python\n from boscoin_base.builder import Builder\n seed = \"SCVLSUGYEAUC4MVWJORB63JBMY2CEX6ATTJ5MXTENGD3IELUQF4F6HUB\"\n builder = Builder(secret=seed) # builder = Builder(secret=seed, network='public') for LIVENET\n```\nHow about sending Bob a payment?\n```python\n bob_address = 'XXX'\n builder.append_payment_op(bob_address,'100','BOS')\n```\nOr if you want to pay him with CNY:\n```python\n CNY_ISSUER = 'GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG'# Just a Stellar address which issues asset CNY\n builder.append_payment_op(bob_address, '100', 'CNY', CNY_ISSUER)\n```\nAnd maybe you need to carry a message:\n```python\n builder.add_text_memo('Buy yourself a beer!') # string length <= 28 bytes\n``` \nAt last, sign & submit\n ```python \n builder.sign()\n builder.submit()\n```\nDone.\n\nSometimes, we need to deal with multi-signature transactions. Especially when you get a xdr string (or transaction envelope xdr) from a friend or partner, which describes a multi-sig transaction. They may need you to sign on it too. \n```python\n builder = Builder(secret=seed) # or builder = Builder(secret=secret, network='public') for LIVENET.\n builder.import_from_xdr(xdr_string) # the xdr_string come from your friend\n builder.sign()\n builder.to_xdr() # generate new xdr string \n # or builder.submit() # submit to Stellar network\n```\n\n### 4.2 Build from scratch\n```python \n from boscoin_base.keypair import Keypair\n from boscoin_base.asset import Asset\n from boscoin_base.operation import Payment\n from boscoin_base.transaction import Transaction\n from boscoin_base.transaction_envelope import TransactionEnvelope as Te\n from boscoin_base.memo import TextMemo\n from boscoin_base.horizon import horizon_testnet, horizon_pubic\n\n alice_seed = 'SAZJ3EDATROKTNNN4WZBZPRC34AN5WR43VEHAFKT5D66UEZTKDNKUHOK'\n bob_address = 'GDLP3SP4WP72L4BAJWZUDZ6SAYE4NAWILT5WQDS7RWC4XCUNUQDRB2A4'\n CNY_ISSUER = 'GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG'\n amount = '100'\n\n Alice = Keypair.from_seed(alice_seed)\n horizon = horizon_testnet()# horizon = horizon_pubic() for LIVENET\n\n asset = Asset('CNY', CNY_ISSUER) \n # create op \n op = Payment({\n # 'source' : Alice.address().decode(),\n 'destination': bob_address,\n 'asset': asset,\n 'amount': amount\n })\n # create a memo\n msg = TextMemo('Buy yourself a beer !')\n\n # get sequence of Alice\n sequence = horizon.account(Alice.address()).get('sequence') \n\n # construct Tx\n tx = Transaction(\n source=Alice.address().decode(),\n opts={\n 'sequence': sequence,\n # 'timeBounds': [],\n 'memo': msg,\n # 'fee': 10000,\n 'operations': [\n op,\n ],\n },\n )\n\n\n # build envelope\n envelope = Te(tx=tx, opts={\"network_id\": \"TESTNET\"}) # envelope = Te(tx=tx, opts={\"network_id\": \"PUBLIC\"}) for LIVENET\n # sign \n envelope.sign(Alice)\n # submit\n xdr = envelope.xdr()\n response=horizon.submit(xdr)\n```\n\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/jinhwanlazy/py-boscoin-base/", "keywords": "", "license": "Apache", "maintainer": "", "maintainer_email": "", "name": "boscoin-base", "package_url": "https://pypi.org/project/boscoin-base/", "platform": "", "project_url": "https://pypi.org/project/boscoin-base/", "project_urls": { "Homepage": "http://github.com/jinhwanlazy/py-boscoin-base/" }, "release_url": "https://pypi.org/project/boscoin-base/0.1.5/", "requires_dist": [ "SSEClient", "crc16", "ed25519", "mnemonic", "numpy", "requests", "toml" ], "requires_python": "", "summary": "boscoin-base in python.", "version": "0.1.5" }, "last_serial": 3430451, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "ff6ef51957b5bb214db7fe0bd842a327", "sha256": "c29932799b58cb29dec36095395ccee6db60744ab7f13d951a6b03cef539bc3d" }, "downloads": -1, "filename": "boscoin_base-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ff6ef51957b5bb214db7fe0bd842a327", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 82211, "upload_time": "2017-11-03T16:05:51", "url": "https://files.pythonhosted.org/packages/bc/24/9c21c8d5ab42b44c2e5bef0eb3ad5015cf00f894a9a6c35208cc0a19bfd8/boscoin_base-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "946deefa8d6d31aa7fe2d8b9578dc485", "sha256": "d822788d55588503414769a6493905a0e449733a001f8181183b606d75b73990" }, "downloads": -1, "filename": "boscoin_base-0.1.1-py3.5.egg", "has_sig": false, "md5_digest": "946deefa8d6d31aa7fe2d8b9578dc485", "packagetype": "bdist_egg", "python_version": "3.5", "requires_python": null, "size": 192124, "upload_time": "2017-11-03T16:40:15", "url": "https://files.pythonhosted.org/packages/14/90/8fe34f70ae560f5efe69476dc3fb396b68c96d9cbafda7815853f8b8fbc4/boscoin_base-0.1.1-py3.5.egg" }, { "comment_text": "", "digests": { "md5": "772a7005254dcf453300648d6e280fe4", "sha256": "ad57b02f498ba015a375846c83ed0964b4418b3f97a37f31875d26701be8cc93" }, "downloads": -1, "filename": "boscoin-base-0.1.1.tar.gz", "has_sig": false, "md5_digest": "772a7005254dcf453300648d6e280fe4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 69399, "upload_time": "2017-11-03T16:07:35", "url": "https://files.pythonhosted.org/packages/4e/db/e8264307fafc68f0c77be8c757335b842957ae9b7f7aebff41a96fe1c9b6/boscoin-base-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "3c02ecb951cdaa1f28f62cea017d973a", "sha256": "73bf19f87369428ee3c5dc35c3ff785a58d458c25e1c5caa1f891371c6d0486b" }, "downloads": -1, "filename": "boscoin_base-0.1.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3c02ecb951cdaa1f28f62cea017d973a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 82502, "upload_time": "2017-11-03T16:40:13", "url": "https://files.pythonhosted.org/packages/04/af/4dfe4b7d7f684b7a418e225aa094111f8467e5ed98ecf0136937cc6903a7/boscoin_base-0.1.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d24b760c056adc3b2fc0ad6af27c4c86", "sha256": "fae72e39df33c2f4c770c4472faabfc21a6109b86bd0ca49013e36eb9cd772fd" }, "downloads": -1, "filename": "boscoin_base-0.1.2-py3.6.egg", "has_sig": false, "md5_digest": "d24b760c056adc3b2fc0ad6af27c4c86", "packagetype": "bdist_egg", "python_version": "3.6", "requires_python": null, "size": 337316, "upload_time": "2017-12-16T20:54:58", "url": "https://files.pythonhosted.org/packages/06/fb/2df381ced169edc48f899b37d960a9e09f5c9d4748984be307e2fc56d63c/boscoin_base-0.1.2-py3.6.egg" }, { "comment_text": "", "digests": { "md5": "df82f5026756daaf5d6aa86824b925e7", "sha256": "936c2a6a58fe29704c44f19736dfcf5afbc191b4d2896e0a06b7ad1bac9d68e6" }, "downloads": -1, "filename": "boscoin-base-0.1.2.tar.gz", "has_sig": false, "md5_digest": "df82f5026756daaf5d6aa86824b925e7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 69729, "upload_time": "2017-11-03T16:40:17", "url": "https://files.pythonhosted.org/packages/f2/4f/62957934b9d82c437c61d76a42c623af4a7e1999fa81b498e10c9505a95a/boscoin-base-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "a735b3e6c192d91ba1f6fea69e129771", "sha256": "0f97c9d6aa616fc420537c0b6a134082a38f5ead41603cd92c02bb877f09a1f8" }, "downloads": -1, "filename": "boscoin_base-0.1.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a735b3e6c192d91ba1f6fea69e129771", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 82509, "upload_time": "2017-12-01T12:48:54", "url": "https://files.pythonhosted.org/packages/8e/48/eb1d24a2b0d1fc7e728a1ff67a0d2a86f42a812e3f509c7d339f2547ca92/boscoin_base-0.1.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "29d57504e32dafb79664ba6e858719c3", "sha256": "6ba822a57a4b272d91953dfb8cb7d204dfa43c7ede43a26a2f10e2d71fca092d" }, "downloads": -1, "filename": "boscoin-base-0.1.3.tar.gz", "has_sig": false, "md5_digest": "29d57504e32dafb79664ba6e858719c3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 69749, "upload_time": "2017-12-01T12:48:56", "url": "https://files.pythonhosted.org/packages/3f/01/80addf5588275ac84ebfd3184d37dcef96aa97e272efe857d46bb716cb66/boscoin-base-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "23433b7a78745afdf12321b4106d70c4", "sha256": "14bbfe5775ce82b4a3d91145217c8954fe1b5dc35854a36d9950d84ae3fdd9f3" }, "downloads": -1, "filename": "boscoin_base-0.1.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "23433b7a78745afdf12321b4106d70c4", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 142143, "upload_time": "2017-12-16T20:54:55", "url": "https://files.pythonhosted.org/packages/d2/e2/274cec7f9446daa0b68b805ecc133355026dc4bd3510d5ef2f5fce78eb07/boscoin_base-0.1.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1db27b7aa6d4045f1142d4f10c989899", "sha256": "a8f3601ace02ae36b8ffe019fbec8d4aa1ec7887982f338ee243d2e6530ec125" }, "downloads": -1, "filename": "boscoin-base-0.1.4.tar.gz", "has_sig": false, "md5_digest": "1db27b7aa6d4045f1142d4f10c989899", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 67559, "upload_time": "2017-12-16T20:54:56", "url": "https://files.pythonhosted.org/packages/21/74/aa4a397b6fad373af0007e866dd94bbea5689c84e9df3d1606fd225e66ce/boscoin-base-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "38bf6854d0b5fd9a434689730c666f08", "sha256": "f5e80c9d02a8b051ead85573e9e8b3477c34af9b782e7c75330eba9c2929b892" }, "downloads": -1, "filename": "boscoin_base-0.1.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "38bf6854d0b5fd9a434689730c666f08", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 82509, "upload_time": "2017-12-20T06:41:38", "url": "https://files.pythonhosted.org/packages/77/94/06188500a7ab12dd10024006f226fe121bdc7a732c4e823df45641a6a091/boscoin_base-0.1.5-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "38bf6854d0b5fd9a434689730c666f08", "sha256": "f5e80c9d02a8b051ead85573e9e8b3477c34af9b782e7c75330eba9c2929b892" }, "downloads": -1, "filename": "boscoin_base-0.1.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "38bf6854d0b5fd9a434689730c666f08", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 82509, "upload_time": "2017-12-20T06:41:38", "url": "https://files.pythonhosted.org/packages/77/94/06188500a7ab12dd10024006f226fe121bdc7a732c4e823df45641a6a091/boscoin_base-0.1.5-py2.py3-none-any.whl" } ] }