Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_create_ps2h_unsigned(self):
# This address I previously sent funds to but threw out the private key
create_unsigned_tx(
inputs=[
{
'pubkeys': [
'036f5ca449944655b5c580ff6686bdd19123d1003b41f49f4b603f53e33f70a2d1',
'03e93a754aa03dedbe032e5be051bce031db4337c48fbbcf970d1b27bb25a07964',
'02582061ab1dba9d6b5b4e6e29f9da2bd590862f1b1e8566f405eb1d92898eafee',
],
'script_type': 'multisig-2-of-3'
},
],
outputs=[
{
'value': -1,
'address': 'CFr99841LyMkyX5ZTGepY58rjXJhyNGXHf',
},
],
def test_create_basic_unsigned(self):
# This address I previously sent funds to but threw out the private key
create_unsigned_tx(
inputs=[
{'address': 'BwvSPyMWVL1gkp5FZdrGXLpHj2ZJyJYLVB'},
],
outputs=[
{
'value': -1,
# p2sh address for extra measure
'address': 'Dbc9fnf1Kqct7zvfNTiwr6HjvDfPYaFSNg',
},
],
change_address=None,
include_tosigntx=True,
# will test signature returned locally:
verify_tosigntx=True,
coin_symbol='bcy',
api_key=BC_API_KEY,
def test_create_nulldata_unsigned(self):
# This address I previously sent funds to but threw out the private key
create_unsigned_tx(
inputs=[
{'address': 'BwvSPyMWVL1gkp5FZdrGXLpHj2ZJyJYLVB'},
],
outputs=[
# embed some null-data
{
'value': 0,
'script_type': 'null-data',
'script': '6a06010203040506',
},
],
change_address='CFr99841LyMkyX5ZTGepY58rjXJhyNGXHf',
include_tosigntx=True,
# will test signature returned locally:
verify_tosigntx=True,
coin_symbol='bcy',
def send_multi_payment(payment_privkey, list_of_addresses, payment_per_address):
payment_address = get_address_from_privkey(payment_privkey)
if dontuseAddress(payment_address):
log.debug("Payment address %s not ready" % payment_address)
return None
inputs = [{'address': payment_address}]
payment_in_satoshis = btc_to_satoshis(float(payment_per_address))
outputs = []
for address in list_of_addresses:
outputs.append({'address': address, 'value': int(payment_in_satoshis)})
unsigned_tx = create_unsigned_tx(inputs=inputs, outputs=outputs,
api_key=BLOCKCYPHER_TOKEN)
# iterate through unsigned_tx['tx']['inputs'] to find each address in order
# need to include duplicates as many times as they may appear
privkey_list = []
pubkey_list = []
for input in unsigned_tx['tx']['inputs']:
privkey_list.append(payment_privkey)
pubkey_list.append(get_pubkey_from_privkey(payment_privkey))
tx_signatures = make_tx_signatures(txs_to_sign=unsigned_tx['tosign'],
privkey_list=privkey_list,
pubkey_list=pubkey_list)
resp = broadcast_signed_transaction(unsigned_tx=unsigned_tx,
def send_multi_payment(payment_privkey, list_of_addresses, payment_per_address):
payment_address = get_address_from_privkey(payment_privkey)
if dontuseAddress(payment_address):
log.debug("Payment address %s not ready" % payment_address)
return None
inputs = [{'address': payment_address}]
payment_in_satoshis = btc_to_satoshis(float(payment_per_address))
outputs = []
for address in list_of_addresses:
outputs.append({'address': address, 'value': int(payment_in_satoshis)})
unsigned_tx = create_unsigned_tx(inputs=inputs, outputs=outputs,
api_key=BLOCKCYPHER_TOKEN)
# iterate through unsigned_tx['tx']['inputs'] to find each address in order
# need to include duplicates as many times as they may appear
privkey_list = []
pubkey_list = []
for input in unsigned_tx['tx']['inputs']:
privkey_list.append(payment_privkey)
pubkey_list.append(get_pubkey_from_privkey(payment_privkey))
tx_signatures = make_tx_signatures(txs_to_sign=unsigned_tx['tosign'],
privkey_list=privkey_list,
pubkey_list=pubkey_list)
resp = broadcast_signed_transaction(unsigned_tx=unsigned_tx,