Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
verbose_print('num_addrs:\n%s' % num_addrs)
unused_receiving_addresses = get_unused_receiving_addresses(
wallet_obj=wallet_obj,
num_addrs=num_addrs,
)
puts('-' * 70 + '\n')
if num_addrs > 1:
addr_str = 'Addresses'
else:
addr_str = 'Address'
puts('Unused %s Receiving %s - (for others to send you funds):' % (
COIN_SYMBOL_MAPPINGS[coin_symbol_from_mkey(mpub)]['currency_abbrev'],
addr_str,
))
for unused_receiving_address in unused_receiving_addresses:
with indent(2):
puts(colored.green('%s (path is %s)' % (
unused_receiving_address['pub_address'],
unused_receiving_address['path'],
)))
def coin_overview(request, coin_symbol):
initial = {
'coin_symbol': coin_symbol,
'search_string': COIN_SYMBOL_MAPPINGS[coin_symbol]['example_address']
}
form = SearchForm(initial=initial)
latest_bh = get_latest_block_height(coin_symbol=coin_symbol, api_key=BLOCKCYPHER_API_KEY)
recent_blocks = get_blocks_overview(
block_representation_list=list(reversed(range(latest_bh-4, latest_bh+1))),
coin_symbol=coin_symbol,
api_key=BLOCKCYPHER_API_KEY)
recent_blocks = sorted(recent_blocks, key=lambda k: k['height'], reverse=True)
fees = get_blockchain_fee_estimates(coin_symbol=coin_symbol, api_key=BLOCKCYPHER_API_KEY)
fees['high_fee_per_kb__smalltx'] = fees['high_fee_per_kb']/4
fees['medium_fee_per_kb__smalltx'] = fees['medium_fee_per_kb']/4
fees['low_fee_per_kb__smalltx'] = fees['low_fee_per_kb']/4
verbose_print('num_addrs:\n%s' % num_addrs)
unused_receiving_addresses = get_unused_receiving_addresses(
wallet_obj=wallet_obj,
num_addrs=num_addrs,
)
puts('-' * 70 + '\n')
if num_addrs > 1:
addr_str = 'Addresses'
else:
addr_str = 'Address'
puts('Unused %s Receiving %s - (for others to send you funds):' % (
COIN_SYMBOL_MAPPINGS[coin_symbol_from_mkey(mpub)]['currency_abbrev'],
addr_str,
))
for unused_receiving_address in unused_receiving_addresses:
with indent(2):
puts(colored.green('%s (path is %s)' % (
unused_receiving_address['pub_address'],
unused_receiving_address['path'],
)))
def get_curr_symbol(coin_symbol, output_type):
if output_type == 'btc':
return COIN_SYMBOL_MAPPINGS[coin_symbol]['currency_abbrev']
elif output_type == 'mbtc':
return 'm%s' % COIN_SYMBOL_MAPPINGS[coin_symbol]['currency_abbrev']
elif output_type == 'bit':
return 'bits'
elif output_type == 'satoshi':
return 'satoshis'
else:
raise Exception('Invalid Unit Choice: %s' % output_type)
def make_url(coin_symbol, simple_string=False, meta=False, **kwargs):
url_bits = [
BLOCKCYPHER_DOMAIN,
ENDPOINT_VERSION,
COIN_SYMBOL_MAPPINGS[coin_symbol]['blockcypher_code'],
COIN_SYMBOL_MAPPINGS[coin_symbol]['blockcypher_network'],
]
if simple_string:
url_bits.append(simple_string)
# kwargs must be ONE of {addrs: address, txs: hhash, blocks: blockhash}
if kwargs:
url_bits += list(kwargs.popitem())
if meta:
url_bits.append('meta')
url = os.path.join(*url_bits)
logger.info(url)
time_to_use = confirmed_at
else:
time_to_use = received_at
if 'prev_hash' in inputs[0]:
is_coinbase_tx = False
total_satoshis_coinbase, fee_in_satoshis_coinbase = None, None
coinbase_msg = None
else:
is_coinbase_tx = True
total_satoshis_coinbase, fee_in_satoshis_coinbase = 0, 0
coinbase_msg = str(unhexlify(inputs[0]['script']))
api_url = 'https://api.blockcypher.com/v1/%s/%s/txs/%s?limit=%s&includeHex=true' % (
COIN_SYMBOL_MAPPINGS[coin_symbol]['blockcypher_code'],
COIN_SYMBOL_MAPPINGS[coin_symbol]['blockcypher_network'],
tx_hash,
TX_LIMIT,
)
return {
'coin_symbol': coin_symbol,
'tx_hash': tx_hash,
'api_url': api_url,
'is_coinbase_tx': is_coinbase_tx,
'coinbase_msg': coinbase_msg,
'received_at': received_at,
'confirmed_at': confirmed_at,
'time_to_use': time_to_use,
'total_satoshis': total_satoshis,
'total_satoshis_coinbase': total_satoshis_coinbase,
'fee_in_satoshis': fee_in_satoshis,
def coin_symbol_to_display_shortname(coin_symbol):
return COIN_SYMBOL_MAPPINGS[coin_symbol]['display_shortname']
block_overview = get_block_overview(
block_representation=block_hash,
coin_symbol=coin_symbol,
txn_limit=500,
api_key=BLOCKCYPHER_API_KEY,
)
random_tx_hash = choice(block_overview['txids'])
redir_url = reverse(
'add_metadata_to_tx',
kwargs={'coin_symbol': coin_symbol, 'tx_hash': random_tx_hash},
)
msg = _('%(cs_display)s transaction %(tx_hash)s from latest block (%(latest_block_num)s) randomly selected' % {
'cs_display': COIN_SYMBOL_MAPPINGS[coin_symbol]['currency_abbrev'],
'tx_hash': random_tx_hash,
'latest_block_num': intcomma(block_overview['height']),
})
messages.success(request, msg, extra_tags='safe')
return HttpResponseRedirect(redir_url)
def coin_symbol_chooser(user_prompt=DEFAULT_PROMPT, quit_ok=True):
ACTIVE_COIN_SYMBOL_LIST = [x for x in COIN_SYMBOL_LIST if x != 'uro']
for cnt, coin_symbol_choice in enumerate(ACTIVE_COIN_SYMBOL_LIST):
with indent(2):
puts(colored.cyan('%s: %s' % (
cnt+1,
COIN_SYMBOL_MAPPINGS[coin_symbol_choice]['display_name'],
)))
if ACTIVE_COIN_SYMBOL_LIST[4] == 'bcy':
default_input = 5
show_default = True
else:
default_input = None
show_default = False
coin_symbol_int = get_int(
min_int=1,
user_prompt=user_prompt,
max_int=len(ACTIVE_COIN_SYMBOL_LIST),
default_input=default_input,
show_default=show_default,
quit_ok=quit_ok,
)
msg = _('Invalid Block Representation')
messages.warning(request, msg)
redir_url = reverse('coin_overview', kwargs={'coin_symbol': coin_symbol})
return HttpResponseRedirect(redir_url)
# import pprint; pprint.pprint(block_details, width=1)
if 'error' in block_details:
msg = _('Sorry, that block was not found')
messages.warning(request, msg)
messages.warning(request, block_details['error'])
return HttpResponseRedirect(reverse('home'))
# Technically this is not the only API call used on this page
api_url = 'https://api.blockcypher.com/v1/%s/%s/blocks/%s' % (
COIN_SYMBOL_MAPPINGS[coin_symbol]['blockcypher_code'],
COIN_SYMBOL_MAPPINGS[coin_symbol]['blockcypher_network'],
block_representation,
)
return {
'coin_symbol': coin_symbol,
'api_url': api_url,
'block_details': block_details,
'current_page': current_page,
'max_pages': get_max_pages(num_items=block_details['n_tx'], items_per_page=TXNS_PER_PAGE),
}