diff --git a/.gitignore b/.gitignore index 0e66a3d..bec7a72 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,6 @@ coverage.xml *.log *.pot .idea/ + +# IDEs +.vscode/ \ No newline at end of file diff --git a/blockcypher/__init__.py b/blockcypher/__init__.py index 83a9fa9..8f09e30 100644 --- a/blockcypher/__init__.py +++ b/blockcypher/__init__.py @@ -6,85 +6,174 @@ """ # Main methods used -from .api import get_token_info -from .api import get_address_details -from .api import get_addresses_details -from .api import get_address_overview -from .api import get_address_full -from .api import get_transaction_details -from .api import get_transactions_details -from .api import get_block_overview -from .api import get_blocks_overview -from .api import get_block_details -from .api import get_blockchain_overview -from .api import get_blockchain_fee_estimates -from .api import get_blockchain_high_fee -from .api import get_blockchain_medium_fee -from .api import get_blockchain_low_fee -from .api import get_latest_block_height -from .api import get_latest_block_hash -from .api import get_total_balance -from .api import get_unconfirmed_balance -from .api import get_confirmed_balance -from .api import get_num_confirmed_transactions -from .api import get_num_unconfirmed_transactions -from .api import get_total_num_transactions -from .api import generate_new_address -from .api import derive_hd_address -from .api import get_num_confirmations -from .api import get_confidence -from .api import get_miner_preference -from .api import get_receive_count -from .api import get_satoshis_transacted -from .api import get_satoshis_in_fees -from .api import get_merkle_root -from .api import get_bits -from .api import get_nonce -from .api import get_prev_block_hash -from .api import get_block_hash -from .api import get_block_height -from .api import get_broadcast_transactions -from .api import get_broadcast_transaction_hashes -from .api import subscribe_to_address_webhook -from .api import subscribe_to_wallet_webhook -from .api import list_webhooks -from .api import get_webhook_info -from .api import unsubscribe_from_webhook -from .api import pushtx -from .api import decodetx -from .api import get_forwarding_address -from .api import create_forwarding_address -from .api import create_forwarding_address_with_details -from .api import get_forwarding_address_details -from .api import list_forwarding_addresses -from .api import delete_forwarding_address -from .api import send_faucet_coins -from .api import list_wallet_names -from .api import create_wallet_from_address -from .api import create_hd_wallet -from .api import get_wallet_addresses -from .api import get_wallet_balance -from .api import get_wallet_transactions -from .api import get_latest_paths_from_hd_wallet_addresses -from .api import add_address_to_wallet -from .api import remove_address_from_wallet -from .api import delete_wallet -from .api import generate_multisig_address -from .api import create_unsigned_tx -from .api import verify_unsigned_tx -from .api import get_input_addresses -from .api import make_tx_signatures -from .api import broadcast_signed_transaction -from .api import simple_spend -from .api import simple_spend_p2sh -from .api import embed_data -from .api import get_metadata -from .api import put_metadata -from .api import delete_metadata +from .api import ( + get_token_info, + get_address_details, + get_addresses_details, + get_address_overview, + get_address_full, + get_transaction_details, + get_transactions_details, + get_block_overview, + get_blocks_overview, + get_block_details, + get_blockchain_overview, + get_blockchain_fee_estimates, + get_blockchain_high_fee, + get_blockchain_medium_fee, + get_blockchain_low_fee, + get_latest_block_height, + get_latest_block_hash, + get_total_balance, + get_unconfirmed_balance, + get_confirmed_balance, + get_num_confirmed_transactions, + get_num_unconfirmed_transactions, + get_total_num_transactions, + generate_new_address, + derive_hd_address, + get_num_confirmations, + get_confidence, + get_miner_preference, + get_receive_count, + get_satoshis_transacted, + get_satoshis_in_fees, + get_merkle_root, + get_bits, + get_nonce, + get_prev_block_hash, + get_block_hash, + get_block_height, + get_broadcast_transactions, + get_broadcast_transaction_hashes, + subscribe_to_address_webhook, + subscribe_to_wallet_webhook, + list_webhooks, + get_webhook_info, + unsubscribe_from_webhook, + pushtx, + decodetx, + get_forwarding_address, + create_forwarding_address, + create_forwarding_address_with_details, + get_forwarding_address_details, + list_forwarding_addresses, + delete_forwarding_address, + send_faucet_coins, + list_wallet_names, + create_wallet_from_address, + create_hd_wallet, + get_wallet_addresses, + get_wallet_balance, + get_wallet_transactions, + get_latest_paths_from_hd_wallet_addresses, + add_address_to_wallet, + remove_address_from_wallet, + delete_wallet, + generate_multisig_address, + create_unsigned_tx, + verify_unsigned_tx, + get_input_addresses, + make_tx_signatures, + broadcast_signed_transaction, + simple_spend, + simple_spend_p2sh, + embed_data, + get_metadata, + put_metadata, + delete_metadata, +) -from .utils import from_base_unit -from .utils import satoshis_to_btc -from .utils import wei_to_ether -from .utils import is_valid_hash -from .utils import is_valid_address -from .utils import is_valid_eth_address +from .utils import ( + from_base_unit, + satoshis_to_btc, + wei_to_ether, + is_valid_hash, + is_valid_address, + is_valid_eth_address, +) + + +__all__ = [ + "get_token_info", + "get_address_details", + "get_addresses_details", + "get_address_overview", + "get_address_full", + "get_transaction_details", + "get_transactions_details", + "get_block_overview", + "get_blocks_overview", + "get_block_details", + "get_blockchain_overview", + "get_blockchain_fee_estimates", + "get_blockchain_high_fee", + "get_blockchain_medium_fee", + "get_blockchain_low_fee", + "get_latest_block_height", + "get_latest_block_hash", + "get_total_balance", + "get_unconfirmed_balance", + "get_confirmed_balance", + "get_num_confirmed_transactions", + "get_num_unconfirmed_transactions", + "get_total_num_transactions", + "generate_new_address", + "derive_hd_address", + "get_num_confirmations", + "get_confidence", + "get_miner_preference", + "get_receive_count", + "get_satoshis_transacted", + "get_satoshis_in_fees", + "get_merkle_root", + "get_bits", + "get_nonce", + "get_prev_block_hash", + "get_block_hash", + "get_block_height", + "get_broadcast_transactions", + "get_broadcast_transaction_hashes", + "subscribe_to_address_webhook", + "subscribe_to_wallet_webhook", + "list_webhooks", + "get_webhook_info", + "unsubscribe_from_webhook", + "pushtx", + "decodetx", + "get_forwarding_address", + "create_forwarding_address", + "create_forwarding_address_with_details", + "get_forwarding_address_details", + "list_forwarding_addresses", + "delete_forwarding_address", + "send_faucet_coins", + "list_wallet_names", + "create_wallet_from_address", + "create_hd_wallet", + "get_wallet_addresses", + "get_wallet_balance", + "get_wallet_transactions", + "get_latest_paths_from_hd_wallet_addresses", + "add_address_to_wallet", + "remove_address_from_wallet", + "delete_wallet", + "generate_multisig_address", + "create_unsigned_tx", + "verify_unsigned_tx", + "get_input_addresses", + "make_tx_signatures", + "broadcast_signed_transaction", + "simple_spend", + "simple_spend_p2sh", + "embed_data", + "get_metadata", + "put_metadata", + "delete_metadata", + "from_base_unit", + "satoshis_to_btc", + "wei_to_ether", + "is_valid_hash", + "is_valid_address", + "is_valid_eth_address", +] diff --git a/blockcypher/api.py b/blockcypher/api.py index accd019..7ba3330 100644 --- a/blockcypher/api.py +++ b/blockcypher/api.py @@ -1,24 +1,25 @@ -import os - -from bitcoin import ecdsa_raw_sign -from bitcoin import ecdsa_raw_verify -from bitcoin import der_decode_sig -from bitcoin import compress -from bitcoin import privkey_to_pubkey -from bitcoin import pubkey_to_address -from bitcoin import der_encode_sig - -from .utils import is_valid_hash -from .utils import is_valid_block_representation -from .utils import is_valid_coin_symbol -from .utils import is_valid_wallet_name -from .utils import is_valid_address_for_coinsymbol -from .utils import coin_symbol_from_mkey -from .utils import double_sha256 -from .utils import compress_txn_outputs -from .utils import get_txn_outputs_dict -from .utils import uses_only_hash_chars -from .utils import delegate_task +from cryptos import ( + ecdsa_raw_sign, + ecdsa_raw_verify, + der_decode_sig, + compress, + privkey_to_pubkey, + pubkey_to_address, + der_encode_sig, +) + +from .utils import ( + is_valid_hash, + is_valid_block_representation, + is_valid_coin_symbol, + is_valid_wallet_name, + is_valid_address_for_coinsymbol, + coin_symbol_from_mkey, + double_sha256, + compress_txn_outputs, + get_txn_outputs_dict, + uses_only_hash_chars, +) from .constants import COIN_SYMBOL_MAPPINGS diff --git a/blockcypher/crypto.py b/blockcypher/crypto.py index 1226931..c320f90 100644 --- a/blockcypher/crypto.py +++ b/blockcypher/crypto.py @@ -1,4 +1,6 @@ -from bitcoin import encode, changebase, binascii, bin_to_b58check +import binascii + +from cryptos import bin_to_b58check import re diff --git a/blockcypher/utils.py b/blockcypher/utils.py index 87a2c0c..73669f8 100644 --- a/blockcypher/utils.py +++ b/blockcypher/utils.py @@ -1,12 +1,11 @@ import re from concurrent.futures.thread import ThreadPoolExecutor -from functools import partial -from typing import Callable, Sequence, Tuple, List +from typing import Callable, Tuple, List from .constants import SHA_COINS, SCRYPT_COINS, ETHASH_COINS, COIN_SYMBOL_SET, COIN_SYMBOL_MAPPINGS, FIRST4_MKEY_CS_MAPPINGS_UPPER, UNIT_CHOICES, UNIT_MAPPINGS from .crypto import script_to_address -from bitcoin import safe_from_hex, deserialize +from cryptos import safe_from_hex, deserialize from collections import OrderedDict from hashlib import sha256 diff --git a/setup.py b/setup.py index 52534ec..ccb3dd2 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ setup(name='blockcypher', long_description=long_description, long_description_content_type='text/markdown', - version='1.0.93', + version='1.0.94', description='BlockCypher Python Library', author='Michael Flaxman', author_email='mflaxman+blockcypher@gmail.com', @@ -22,7 +22,7 @@ install_requires=[ 'requests<3.0.0', 'python-dateutil<3.0.0', - 'bitcoin==1.1.39', + 'cryptos<3.0.0' ], packages=['blockcypher'], include_package_data=True,