Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bcwallet/bc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


def guess_network_from_mkey(mkey):
cs = coin_symbol_from_mkey(mkey)
cs = next(iter(coin_symbol_from_mkey(mkey)))
return COIN_SYMBOL_TO_BMERCHANT_NETWORK.get(cs)


Expand Down
29 changes: 9 additions & 20 deletions bcwallet/bcwallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def display_balance_info(wallet_obj, verbose=False):
verbose_print('Wallet Name: %s' % wallet_name)
verbose_print('API Key: %s' % BLOCKCYPHER_API_KEY)

coin_symbol = coin_symbol_from_mkey(mpub)
coin_symbol = next(iter(coin_symbol_from_mkey(mpub)))

wallet_details = get_wallet_balance(
wallet_name=wallet_name,
Expand Down Expand Up @@ -175,7 +175,7 @@ def get_addresses_on_both_chains(wallet_obj, used=None, zero_balance=None):
is_hd_wallet=True,
used=used,
zero_balance=zero_balance,
coin_symbol=coin_symbol_from_mkey(mpub),
coin_symbol=next(iter(coin_symbol_from_mkey(mpub))),
)
verbose_print('wallet_addresses:')
verbose_print(wallet_addresses)
Expand Down Expand Up @@ -223,7 +223,7 @@ def register_unused_addresses(wallet_obj, subchain_index, num_addrs=1):
assert num_addrs > 0

mpub = wallet_obj.serialize_b58(private=False)
coin_symbol = coin_symbol_from_mkey(mpub)
coin_symbol = next(iter(coin_symbol_from_mkey(mpub)))
wallet_name = get_blockcypher_walletname_from_mpub(
mpub=mpub,
subchain_indices=[0, 1],
Expand Down Expand Up @@ -341,7 +341,7 @@ def display_recent_txs(wallet_obj):
wallet_details = get_wallet_transactions(
wallet_name=wallet_name,
api_key=BLOCKCYPHER_API_KEY,
coin_symbol=coin_symbol_from_mkey(mpub),
coin_symbol=next(iter(coin_symbol_from_mkey(mpub))),
)
verbose_print(wallet_details)

Expand Down Expand Up @@ -374,7 +374,7 @@ def display_recent_txs(wallet_obj):
input_quantity=net_satoshis_tx,
input_type='satoshi',
output_type=UNIT_CHOICE,
coin_symbol=coin_symbol_from_mkey(mpub),
coin_symbol=next(iter(coin_symbol_from_mkey(mpub))),
print_cs=True,
),
'received' if net_satoshis_tx > 0 else 'sent',
Expand Down Expand Up @@ -926,7 +926,7 @@ def dump_all_keys_or_addrs(wallet_obj):
address=child_wallet.to_address(),
path=path,
wif=wif_to_use,
coin_symbol=coin_symbol_from_mkey(mpub),
coin_symbol=next(iter(coin_symbol_from_mkey(mpub))),
)

puts(colored.blue('\nYou can compare this output to bip32.org'))
Expand All @@ -943,7 +943,6 @@ def dump_selected_keys_or_addrs(wallet_obj, used=None, zero_balance=None):

if not USER_ONLINE:
puts(colored.red('\nInternet connection required, would you like to dump *all* %s instead?' % (
content_str,
content_str,
)))
if confirm(user_prompt=DEFAULT_PROMPT, default=True):
Expand Down Expand Up @@ -982,7 +981,7 @@ def dump_selected_keys_or_addrs(wallet_obj, used=None, zero_balance=None):
address=address_obj['pub_address'],
wif=address_obj.get('wif'),
path=address_obj['path'],
coin_symbol=coin_symbol_from_mkey(mpub),
coin_symbol=next(iter(coin_symbol_from_mkey(mpub))),
)

addr_cnt += 1
Expand Down Expand Up @@ -1099,7 +1098,7 @@ def wallet_home(wallet_obj):
else:
print_bcwallet_basic_pub_opening(mpub=mpub)

coin_symbol = coin_symbol_from_mkey(mpub)
coin_symbol = next(iter(coin_symbol_from_mkey(mpub)))
if USER_ONLINE:
wallet_name = get_blockcypher_walletname_from_mpub(
mpub=mpub,
Expand All @@ -1121,7 +1120,6 @@ def wallet_home(wallet_obj):
# Go to home screen
while True:
puts('-' * 70 + '\n')

if coin_symbol in ('bcy', 'btc-testnet'):
display_shortname = COIN_SYMBOL_MAPPINGS[coin_symbol]['display_shortname']
if coin_symbol == 'bcy':
Expand Down Expand Up @@ -1313,16 +1311,6 @@ def cli():


def invoke_cli():
if sys.version_info[0] != 2 or sys.version_info[1] != 7:
puts(colored.red('Sorry, this app must be run with python 2.7'))
puts(colored.red('Your version: %s' % sys.version))
if sys.version_info[0] == 3:
puts(colored.red('Please uninstall bcwallet and reinstall like this:\n'))
with indent(4):
puts(colored.magenta('$ pip2 install bcwallet\n'))

sys.exit()

# Check if blockcypher is up (basically if the user's machine is online)
global USER_ONLINE
if is_connected_to_blockcypher():
Expand Down Expand Up @@ -1377,6 +1365,7 @@ def invoke_cli():
print_keys_not_saved()
sys.exit()


if __name__ == '__main__':
'''
For invocation like this (not tested):
Expand Down
23 changes: 12 additions & 11 deletions bcwallet/cl_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from bitmerchant.wallet.keys import PrivateKey

from builtins import input
from datetime import datetime

import json
Expand Down Expand Up @@ -62,7 +63,7 @@ def choice_prompt(user_prompt=DEFAULT_PROMPT, acceptable_responses=[],
else:
prompt_to_use = '%s: ' % user_prompt

user_input = raw_input(prompt_to_use).strip().strip('"')
user_input = input(prompt_to_use).strip().strip('"')

if not user_input and default_input in acceptable_responses:
return default_input
Expand Down Expand Up @@ -96,7 +97,7 @@ def get_crypto_qty(max_num, input_type, user_prompt=DEFAULT_PROMPT,
else:
prompt_to_use = '%s: ' % user_prompt

user_input = raw_input(prompt_to_use).strip().strip('"')
user_input = input(prompt_to_use).strip().strip('"')

if default_input and not user_input:
return int(default_input)
Expand Down Expand Up @@ -159,7 +160,7 @@ def get_int(max_int, min_int=1, user_prompt=DEFAULT_PROMPT, default_input=None,
else:
prompt_to_use = '%s: ' % user_prompt

user_input = raw_input(prompt_to_use).strip().strip('"')
user_input = input(prompt_to_use).strip().strip('"')

if default_input and not user_input:
return int(default_input)
Expand Down Expand Up @@ -205,7 +206,7 @@ def get_int(max_int, min_int=1, user_prompt=DEFAULT_PROMPT, default_input=None,
def get_crypto_address(coin_symbol, user_prompt=DEFAULT_PROMPT, quit_ok=False):

display_shortname = COIN_SYMBOL_MAPPINGS[coin_symbol]['display_shortname']
destination_address = raw_input('%s: ' % user_prompt).strip().strip('"')
destination_address = input('%s: ' % user_prompt).strip().strip('"')

if not destination_address:
err_str = 'No entry, please enter something'
Expand Down Expand Up @@ -235,7 +236,7 @@ def get_crypto_address(coin_symbol, user_prompt=DEFAULT_PROMPT, quit_ok=False):

def get_wif_obj(network, user_prompt=DEFAULT_PROMPT, quit_ok=False):

user_input = raw_input('%s: ' % user_prompt).strip().strip('"')
user_input = input('%s: ' % user_prompt).strip().strip('"')

if quit_ok and user_input in ['q', 'Q', 'b', 'B']:
return False
Expand Down Expand Up @@ -306,7 +307,7 @@ def confirm(user_prompt=DEFAULT_PROMPT, default=None):
prompt_to_use = user_prompt + ': '
else:
raise Exception('Bad Default Value: %s' % default)
user_input = raw_input(prompt_to_use).strip()
user_input = input(prompt_to_use).strip()
if not user_input:
return default
elif user_input.lower() == 'y':
Expand All @@ -321,14 +322,14 @@ def confirm(user_prompt=DEFAULT_PROMPT, default=None):
def get_public_wallet_url(mpub):
# subchain indices set at 0 * 1
return 'https://live.blockcypher.com/%s/xpub/%s/?subchain-indices=0-1' % (
coin_symbol_from_mkey(mpub),
next(iter(coin_symbol_from_mkey(mpub))),
mpub,
)


# TODO: move to blockcypher python library
def first4mprv_from_mpub(mpub):
coin_symbol = coin_symbol_from_mkey(mkey=mpub)
coin_symbol = next(iter(coin_symbol_from_mkey(mpub)))
return COIN_SYMBOL_MAPPINGS[coin_symbol]['first4_mprv']


Expand Down Expand Up @@ -362,9 +363,9 @@ def print_bcwallet_piped_priv_cat_opening():


def print_childprivkey_warning():
puts("\nNOTE:")
puts("Do not reveal your private keys to anyone!")
puts("One quirk of HD wallets is that if an attacker learns any of your non-hardened child private keys as well as your master public key then the attacker can derive all of your private keys and steal all of your funds.""")
puts("\nNOTE:")
puts("Do not reveal your private keys to anyone!")
puts("One quirk of HD wallets is that if an attacker learns any of your non-hardened child private keys as well as your master public key then the attacker can derive all of your private keys and steal all of your funds.""")


def print_traversal_warning():
Expand Down
2 changes: 1 addition & 1 deletion bcwallet/version_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
def get_latest_bcwallet_version():
r = requests.get(VERSION_URL)
assert r.status_code == 200, 'Could Not Connect to GitHub (status code %s)' % r.status_code
matches = re.findall("version='(.*?)\'", r.content)
matches = re.findall("version='(.*?)\'", r.content.decode('utf-8'))
assert matches, 'bcwallet version not found on github'
return matches[0]
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
author_email='[email protected]',
url='https://github.com/blockcypher/bcwallet/',
py_modules=['bcwallet'],
use_2to3=True,
install_requires=[
'python>=2.7,<3',
'clint==0.4.1',
'blockcypher==1.0.69',
'future==0.18.2',
'blockcypher==1.0.81',
'bitmerchant==0.1.8',
'tzlocal==1.2',
],
Expand Down