From 208754460a86f83c4a85f1eee3ab01f305739cdb Mon Sep 17 00:00:00 2001 From: Mike Cho Date: Tue, 4 Jun 2019 15:18:18 +0800 Subject: [PATCH 01/15] Update readme examples --- README.rst | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index f1b6e70..de4bb7d 100644 --- a/README.rst +++ b/README.rst @@ -162,6 +162,7 @@ All methods are otherwise the same as the HttpApiClient from binance_chain.http import AsyncHttpApiClient from binance_chain.environment import BinanceEnvironment + import asyncio loop = None @@ -292,6 +293,8 @@ General case from binance_chain.http import HttpApiClient from binance_chain.messages import NewOrderMsg from binance_chain.wallet import Wallet + from binance_chain.constants import TimeInForce, OrderSide, OrderType + import Decimal wallet = Wallet('private_key_string') client = HttpApiClient() @@ -300,7 +303,7 @@ General case new_order_msg = NewOrderMsg( wallet=wallet, symbol="ANN-457_BNB", - time_in_force=TimeInForce.GTE, + time_in_force=TimeInForce.GOOD_TILL_EXPIRE, order_type=OrderType.LIMIT, side=OrderSide.BUY, price=Decimal(0.000396000), @@ -363,6 +366,7 @@ General case from binance_chain.http import HttpApiClient from binance_chain.messages import FreezeMsg from binance_chain.wallet import Wallet + import Decimal wallet = Wallet('private_key_string') client = HttpApiClient() @@ -384,6 +388,7 @@ General case from binance_chain.http import HttpApiClient from binance_chain.messages import UnFreezeMsg from binance_chain.wallet import Wallet + import Decimal wallet = Wallet('private_key_string') client = HttpApiClient() @@ -577,6 +582,7 @@ All methods are the same as the binance_chain.node_rpc.http.HttpRpcClient. from binance_chain.node_rpc.http import AsyncHttpRpcClient from binance_chain.http import AsyncHttpApiClient, PeerType from binance_chain.environment import BinanceEnvironment + import asyncio loop = None @@ -836,6 +842,7 @@ to create our own signing service. from binance_chain.messages import NewOrderMsg from binance_chain.signing.http import HttpApiSigningClient + from binance_chain.constants import TimeInForce, OrderSide, OrderType signing_client = HttpApiSigningClient('http://localhost:8000', username='sam', password='mypass') @@ -880,6 +887,7 @@ To sign and broadcast an order use the `broadcast_order` method. This returns th from binance_chain.messages import NewOrderMsg from binance_chain.signing.http import HttpApiSigningClient + from binance_chain.constants import TimeInForce, OrderSide, OrderType signing_client = HttpApiSigningClient('http://localhost:8000', username='sam', password='mypass') @@ -906,6 +914,8 @@ Like all other libraries there is an async version. from binance_chain.signing.http import AsyncHttpApiSigningClient from binance_chain.http import AsyncHttpApiClient, PeerType from binance_chain.environment import BinanceEnvironment + from binance_chain.constants import TimeInForce, OrderSide, OrderType + import asyncio loop = None From dc9632a34ae2c6d05c47db53d951f82c6c99aba2 Mon Sep 17 00:00:00 2001 From: Mike Cho Date: Tue, 4 Jun 2019 15:22:37 +0800 Subject: [PATCH 02/15] Update import decimal --- README.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index de4bb7d..ebfa887 100644 --- a/README.rst +++ b/README.rst @@ -294,7 +294,7 @@ General case from binance_chain.messages import NewOrderMsg from binance_chain.wallet import Wallet from binance_chain.constants import TimeInForce, OrderSide, OrderType - import Decimal + from decimal import Decimal wallet = Wallet('private_key_string') client = HttpApiClient() @@ -366,7 +366,7 @@ General case from binance_chain.http import HttpApiClient from binance_chain.messages import FreezeMsg from binance_chain.wallet import Wallet - import Decimal + from decimal import Decimal wallet = Wallet('private_key_string') client = HttpApiClient() @@ -388,7 +388,7 @@ General case from binance_chain.http import HttpApiClient from binance_chain.messages import UnFreezeMsg from binance_chain.wallet import Wallet - import Decimal + from decimal import Decimal wallet = Wallet('private_key_string') client = HttpApiClient() From e0c93d940618ab6de332accb5499ef79e87e00b8 Mon Sep 17 00:00:00 2001 From: Mike Cho Date: Tue, 4 Jun 2019 17:45:32 +0800 Subject: [PATCH 03/15] Update description --- README.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index ebfa887..5e8e229 100644 --- a/README.rst +++ b/README.rst @@ -128,16 +128,16 @@ If using the production server there is no need to pass the environment variable # get open orders open_orders = client.get_open_orders('tbnb185tqzq3j6y7yep85lncaz9qeectjxqe5054cgn') - # get open orders + # get ticker ticker = client.get_ticker('NNB-0AD_BNB') - # get open orders + # get trades trades = client.get_trades(limit=2) - # get open orders + # get order order = client.get_order('9D0537108883C68B8F43811B780327CE97D8E01D-2') - # get open orders + # get trades trades = client.get_trades() # get transactions From 02eb7a567c92099e99b79171bc3152baae5e0878 Mon Sep 17 00:00:00 2001 From: Sam McHardy Date: Sat, 29 Jun 2019 21:15:56 +1000 Subject: [PATCH 04/15] Update to v0.1.20 --- README.rst | 2 +- binance_chain/__init__.py | 2 +- docs/changelog.rst | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index d7ab837..9fc1e41 100644 --- a/README.rst +++ b/README.rst @@ -1,5 +1,5 @@ ======================================= -Welcome to python-binance-chain v0.1.19 +Welcome to python-binance-chain v0.1.20 ======================================= .. image:: https://img.shields.io/pypi/v/python-binance-chain.svg diff --git a/binance_chain/__init__.py b/binance_chain/__init__.py index 069c74c..5c65c53 100644 --- a/binance_chain/__init__.py +++ b/binance_chain/__init__.py @@ -4,4 +4,4 @@ """ -__version__ = '0.1.19' +__version__ = '0.1.20' diff --git a/docs/changelog.rst b/docs/changelog.rst index 142436e..946800b 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,6 +1,17 @@ Changelog ========= +v0.1.20 - 2019-06-29 +^^^^^^^^^^^^^^^^^^^^ + +**Added** + +- Multi Transfer Msg option + +**Fixed** + +- Response code of 0 for http requests + v0.1.19 - 2019-04-30 ^^^^^^^^^^^^^^^^^^^^ From 28d86dc82aa19605fb99f06d60e4f9cd88920cde Mon Sep 17 00:00:00 2001 From: Sam McHardy Date: Thu, 11 Jul 2019 20:50:43 +1000 Subject: [PATCH 05/15] Remove docs around custom api_url --- README.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 9fc1e41..490cdb2 100644 --- a/README.rst +++ b/README.rst @@ -89,8 +89,7 @@ If using the production server there is no need to pass the environment variable # Alternatively pass no env to get production prod_client = HttpApiClient() - # connect client to different URL - client = HttpApiClient(api_url='https://yournet.com') + # connect client to different URL using custom environments, see below # get node time time = client.get_time() From 12c32ea17a87f36058448ea012439999d5ba4463 Mon Sep 17 00:00:00 2001 From: Sam McHardy Date: Thu, 11 Jul 2019 20:51:44 +1000 Subject: [PATCH 06/15] Update Kucoin link --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 490cdb2..4baae7f 100644 --- a/README.rst +++ b/README.rst @@ -1103,7 +1103,7 @@ Other Exchanges If you use `Binance `_ check out my `python-binance `_ library. -If you use `Kucoin `_ check out my `python-kucoin `_ library. +If you use `Kucoin `_ check out my `python-kucoin `_ library. If you use `Allcoin `_ check out my `python-allucoin `_ library. From 6c23fac4192493ae78ae440be76d4894c277744d Mon Sep 17 00:00:00 2001 From: Adam Crowder Date: Mon, 7 Oct 2019 21:11:11 -0700 Subject: [PATCH 07/15] remove pywallet and replace with pycoin for bip32 --- binance_chain/wallet.py | 10 ++++++---- requirements.txt | 2 +- setup.py | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/binance_chain/wallet.py b/binance_chain/wallet.py index 8df1498..c601ded 100644 --- a/binance_chain/wallet.py +++ b/binance_chain/wallet.py @@ -4,7 +4,7 @@ from secp256k1 import PrivateKey from mnemonic import Mnemonic -from pywallet.utils.bip32 import Wallet as Bip32Wallet +from pycoin.symbols.btc import network from binance_chain.utils.segwit_addr import address_from_public_key, decode_address from binance_chain.environment import BinanceEnvironment @@ -131,9 +131,11 @@ def create_wallet_from_mnemonic(cls, mnemonic: str, env: Optional[BinanceEnviron :return: """ seed = Mnemonic.to_seed(mnemonic) - new_wallet = Bip32Wallet.from_master_secret(seed=seed, network='BTC') - child = new_wallet.get_child_for_path(Wallet.HD_PATH) - return cls(child.get_private_key_hex().decode(), env=env) + parent_wallet = network.keys.bip32_seed(seed) + child_wallet = parent_wallet.subkey_for_path(Wallet.HD_PATH) + # convert secret exponent (private key) int to hex + key_hex = format(child_wallet.secret_exponent(), 'x') + return cls(key_hex, env=env) @property def private_key(self): diff --git a/requirements.txt b/requirements.txt index 64a8a9b..fe4195d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -pywallet>=0.1.0 +pycoin>=0.90.20190630 requests>=2.21.0 aiohttp>=3.5.4 websockets>=7.0 diff --git a/setup.py b/setup.py index 1358da2..7810e9c 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ def find_version(*file_paths): def install_requires(): requires = [ - 'pywallet>=0.1.0', 'requests>=2.21.0', 'websockets>=7.0', 'aiohttp>=3.5.4', + 'pycoin>=0.90.20190630', 'requests>=2.21.0', 'websockets>=7.0', 'aiohttp>=3.5.4', 'secp256k1>=0.13.2', 'protobuf>=3.6.1', 'mnemonic>=0.18', 'ujson>=1.35' ] return requires From f35a9e5323c6207e8338afcf97ad5c3cfb977f21 Mon Sep 17 00:00:00 2001 From: Oliver Zehentleitner <47597331+oliver-zehentleitner@users.noreply.github.com> Date: Sun, 2 Feb 2020 00:38:14 +0100 Subject: [PATCH 08/15] Update README.rst fixing a small typo related to [issue#28](https://github.com/sammchardy/python-binance-chain/issues/28) --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 4baae7f..f47c01e 100644 --- a/README.rst +++ b/README.rst @@ -509,7 +509,7 @@ See `API Date: Mon, 27 Apr 2020 22:46:04 +0300 Subject: [PATCH 09/15] Add BIP39 passphrase and child wallets --- binance_chain/wallet.py | 50 ++++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/binance_chain/wallet.py b/binance_chain/wallet.py index 8df1498..cb012d5 100644 --- a/binance_chain/wallet.py +++ b/binance_chain/wallet.py @@ -23,7 +23,7 @@ class MnemonicLanguage(str, Enum): class BaseWallet: - HD_PATH = "44'/714'/0'/0/0" + HD_PATH = "44'/714'/0'/0/{id}" def __init__(self, env: Optional[BinanceEnvironment] = None): self._env = env or BinanceEnvironment.get_production_env() @@ -103,8 +103,21 @@ def sign_message(self, msg_bytes): class Wallet(BaseWallet): + """ + Usage example: - HD_PATH = "44'/714'/0'/0/0" + m = Wallet.create_random_mnemonic() # 12 words + p = 'my secret passphrase' # bip39 passphrase + + # Store and

somewhere safe + + wallet1 = Wallet.create_wallet_from_mnemonic(m, passphrase=p, child=0, env=testnet_env) + wallet2 = Wallet.create_wallet_from_mnemonic(m, passphrase=p, child=1, env=testnet_env) + ... + + """ + + HD_PATH = "44'/714'/0'/0/{id}" def __init__(self, private_key, env: Optional[BinanceEnvironment] = None): super().__init__(env) @@ -118,22 +131,37 @@ def create_random_wallet(cls, language: MnemonicLanguage = MnemonicLanguage.ENGL env: Optional[BinanceEnvironment] = None): """Create wallet with random mnemonic code - :return: + :return: initialised Wallet """ - m = Mnemonic(language.value) - phrase = m.generate() + phrase = cls.create_random_mnemonic(language) return cls.create_wallet_from_mnemonic(phrase, env=env) @classmethod - def create_wallet_from_mnemonic(cls, mnemonic: str, env: Optional[BinanceEnvironment] = None): - """Create wallet with random mnemonic code + def create_wallet_from_mnemonic(cls, mnemonic: str, + passphrase: Optional[str] = '', + child: Optional[int] = 0, + env: Optional[BinanceEnvironment] = None): + """Create wallet from mnemonic, passphrase and child wallet id - :return: + :return: initialised Wallet """ - seed = Mnemonic.to_seed(mnemonic) + if type(child) != int: + raise TypeError("Child wallet id should be of type int") + + seed = Mnemonic.to_seed(mnemonic, passphrase) new_wallet = Bip32Wallet.from_master_secret(seed=seed, network='BTC') - child = new_wallet.get_child_for_path(Wallet.HD_PATH) - return cls(child.get_private_key_hex().decode(), env=env) + child_wallet = new_wallet.get_child_for_path(Wallet.HD_PATH.format(id=child)) + return cls(child_wallet.get_private_key_hex().decode(), env=env) + + @classmethod + def create_random_mnemonic(cls, language: MnemonicLanguage = MnemonicLanguage.ENGLISH): + """Create random mnemonic code + + :return: str, mnemonic phrase + """ + m = Mnemonic(language.value) + phrase = m.generate() + return phrase @property def private_key(self): From b416e1564a5b5f00611fcfacf0b94529b6afa446 Mon Sep 17 00:00:00 2001 From: mistdale Date: Mon, 27 Apr 2020 22:56:36 +0300 Subject: [PATCH 10/15] Update Wallet docs --- README.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 4baae7f..4346e59 100644 --- a/README.rst +++ b/README.rst @@ -225,6 +225,8 @@ You may also use the `Ledger Wallet class <#ledger>`_ to utilise your Ledger Har It can be initialised with your private key or your mnemonic phrase. +You can additionally provide BIP39 passphrase and derived wallet id. + Note that the BinanceEnvironment used for the wallet must match that of the HttpApiClient, testnet addresses will not work on the production system. @@ -253,7 +255,10 @@ see examples below from binance_chain.environment import BinanceEnvironment testnet_env = BinanceEnvironment.get_testnet_env() - wallet = Wallet.create_wallet_from_mnemonic('mnemonic word string', env=testnet_env) + wallet = Wallet.create_wallet_from_mnemonic('mnemonic word string', + passphrase='optional passphrase', + child=0, + env=testnet_env) print(wallet.address) print(wallet.private_key) print(wallet.public_key_hex) From fa490f9f1d7bfef227b4111bbaf6c5d323cd0015 Mon Sep 17 00:00:00 2001 From: Son of Odin <2700975-son-of-odin@users.noreply.gitlab.com> Date: Tue, 1 Sep 2020 22:30:49 +0200 Subject: [PATCH 11/15] set limit to 1000 of get_markets --- binance_chain/http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binance_chain/http.py b/binance_chain/http.py index 3c45e62..69eeeb7 100644 --- a/binance_chain/http.py +++ b/binance_chain/http.py @@ -289,7 +289,7 @@ def get_markets(self): :return: API Response """ - return self._get("markets") + return self._get("markets?limit=1000") def get_fees(self): """Gets the current trading fees settings From de8bcd015b4b1e184739590dcabc94f47dc0cbdf Mon Sep 17 00:00:00 2001 From: Son of Odin <2700975-son-of-odin@users.noreply.gitlab.com> Date: Tue, 8 Sep 2020 00:17:28 +0200 Subject: [PATCH 12/15] fix encode_number --- binance_chain/utils/encode_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binance_chain/utils/encode_utils.py b/binance_chain/utils/encode_utils.py index eb02c6b..ce5ed3b 100644 --- a/binance_chain/utils/encode_utils.py +++ b/binance_chain/utils/encode_utils.py @@ -12,7 +12,7 @@ def encode_number(num: Union[float, Decimal]) -> int: if type(num) == Decimal: return int(num * (Decimal(10) ** 8)) else: - return int(num * math.pow(10, 8)) + return int(round(num * 1e8)) def varint_encode(num): From 16d94239c8fd6e7ddae075242d6363bb17f67c40 Mon Sep 17 00:00:00 2001 From: Sam McHardy Date: Thu, 29 Apr 2021 15:54:19 +1000 Subject: [PATCH 13/15] Update requirements.txt --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index fe4195d..93c63e6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ -pycoin>=0.90.20190630 +pycoin>=0.90.20201031 requests>=2.21.0 aiohttp>=3.5.4 websockets>=7.0 secp256k1>=0.13.2 mnemonic>=0.18 -protobuf>=3.6.1 \ No newline at end of file +protobuf>=3.6.1 From 3792a8b1b118bb12fd48fdd4de1527216aa20148 Mon Sep 17 00:00:00 2001 From: Sam McHardy Date: Thu, 29 Apr 2021 15:54:33 +1000 Subject: [PATCH 14/15] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 7810e9c..598059d 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ def find_version(*file_paths): def install_requires(): requires = [ - 'pycoin>=0.90.20190630', 'requests>=2.21.0', 'websockets>=7.0', 'aiohttp>=3.5.4', + 'pycoin>=0.90.20201031', 'requests>=2.21.0', 'websockets>=7.0', 'aiohttp>=3.5.4', 'secp256k1>=0.13.2', 'protobuf>=3.6.1', 'mnemonic>=0.18', 'ujson>=1.35' ] return requires From 19d7d639cc912a27ec86831338c2a2dc96289d50 Mon Sep 17 00:00:00 2001 From: Sam McHardy Date: Tue, 1 Jun 2021 13:14:25 +1000 Subject: [PATCH 15/15] Update README.rst --- README.rst | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.rst b/README.rst index 1363b56..a977f26 100644 --- a/README.rst +++ b/README.rst @@ -1120,10 +1120,4 @@ If you use `Binance `_ check out my `pyth If you use `Kucoin `_ check out my `python-kucoin `_ library. -If you use `Allcoin `_ check out my `python-allucoin `_ library. - If you use `IDEX `_ check out my `python-idex `_ library. - -If you use `BigONE `_ check out my `python-bigone `_ library. - -.. image:: https://analytics-pixel.appspot.com/UA-111417213-1/github/python-kucoin?pixel