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_valid_xpub_testnet(self, xpub, expected, description):
helpers.configurationhelpers.get_use_testnet = mock.MagicMock(return_value=True)
print(description)
assert validators.valid_xpub(xpub) == expected, description
def get_lal(address, xpub, block_height=0):
if not valid_address(address):
return {'error': 'Invalid address: %s' % address}
if not valid_xpub(xpub):
return {'error': 'Invalid xpub: %s' % xpub}
sil_data = get_sil(address, block_height)
if 'SIL' in sil_data:
sil = sil_data['SIL']
linked_addresses = get_addresses_from_xpub(xpub, len(sil))
lal = []
for i in range(0, len(sil)):
lal.append([sil[i][0], linked_addresses[i]])
return {'LAL': lal}
else:
return {'error': 'Received invalid SIL data: %s' % sil_data}
raise Exception('Unable to get distribution: invalid registration_xpub: %s' % self.registration_xpub)
if not valid_block_height(self.registration_block_height):
LOG.error('Unable to get distribution: invalid registration_block_height: %s' % self.registration_block_height)
raise Exception('Unable to get distribution: invalid registration_block_height: %s' % self.registration_block_height)
data = get_lbl(address=self.registration_address, xpub=self.registration_xpub, block_height=self.registration_block_height)
if 'LBL' not in data:
LOG.error('Unable to get distribution: invalid LBL data: %s' % data)
raise Exception('Unable to get distribution: invalid LBL: %s' % data)
distribution = {recipient[0]: recipient[1] for recipient in data['LBL']}
elif transaction_type == 'Send2LRL':
if not valid_address(self.registration_address):
LOG.error('Unable to get distribution: invalid registration_address: %s' % self.registration_address)
raise Exception('Unable to get distribution: invalid registration_address: %s' % self.registration_address)
if not valid_xpub(self.registration_xpub):
LOG.error('Unable to get distribution: invalid registration_xpub: %s' % self.registration_xpub)
raise Exception('Unable to get distribution: invalid registration_xpub: %s' % self.registration_xpub)
if not valid_block_height(self.registration_block_height):
LOG.error('Unable to get distribution: invalid registration_block_height: %s' % self.registration_block_height)
raise Exception('Unable to get distribution: invalid registration_block_height: %s' % self.registration_block_height)
data = get_lrl(address=self.registration_address, xpub=self.registration_xpub, block_height=self.registration_block_height)
if 'LRL' not in data:
LOG.error('Unable to get distribution: invalid LRL data: %s' % data)
raise Exception('Unable to get distribution: invalid LRL: %s' % data)
distribution = {recipient[0]: recipient[1] for recipient in data['LRL']}
elif transaction_type == 'Send2LSL':
if not valid_address(self.registration_address):
LOG.error('Unable to get distribution: invalid registration_address: %s' % self.registration_address)
raise Exception('Unable to get distribution: invalid registration_address: %s' % self.registration_address)
def random_address_from_lrl(address, xpub, sil_block_height=0, rng_block_height=0):
if not valid_address(address):
return {'error': 'Invalid address: %s' % address}
if not valid_xpub(xpub):
return {'error': 'Invalid xpub: %s' % xpub}
return RandomAddress(address=address,
xpub=xpub,
sil_block_height=sil_block_height).get(source='LRL',
rng_block_height=rng_block_height)
if 'wallet_type' in config and config['wallet_type'] in ['Single', 'BIP44']:
self.wallet_type = config['wallet_type']
if 'sending_address' in config and valid_address(config['sending_address']):
self.sending_address = config['sending_address']
if 'bip44_account' in config:
self.bip44_account = config['bip44_account']
if 'bip44_index' in config:
self.bip44_index = config['bip44_index']
if 'receiving_address' in config and valid_address(config['receiving_address']):
self.receiving_address = config['receiving_address']
if 'receiving_xpub' in config and valid_xpub(config['receiving_xpub']):
self.receiving_xpub = config['receiving_xpub']
if 'amount' in config and valid_amount(config['amount']):
self.amount = config['amount']
if 'minimum_amount' in config and valid_amount(config['minimum_amount']):
self.minimum_amount = config['minimum_amount']
if 'op_return_data' in config and valid_op_return(config['op_return_data']):
self.op_return_data = config['op_return_data']
if 'change_address' in config and valid_address(config['change_address']):
self.receiving_address = config['change_address']
if 'transaction_type' in config and valid_transaction_type(config['transaction_type']):
self.transaction_type = config['transaction_type']
raise Exception('Unable to get distribution: invalid registration_xpub: %s' % self.registration_xpub)
if not valid_block_height(self.registration_block_height):
LOG.error('Unable to get distribution: invalid registration_block_height: %s' % self.registration_block_height)
raise Exception('Unable to get distribution: invalid registration_block_height: %s' % self.registration_block_height)
data = get_lrl(address=self.registration_address, xpub=self.registration_xpub, block_height=self.registration_block_height)
if 'LRL' not in data:
LOG.error('Unable to get distribution: invalid LRL data: %s' % data)
raise Exception('Unable to get distribution: invalid LRL: %s' % data)
distribution = {recipient[0]: recipient[1] for recipient in data['LRL']}
elif transaction_type == 'Send2LSL':
if not valid_address(self.registration_address):
LOG.error('Unable to get distribution: invalid registration_address: %s' % self.registration_address)
raise Exception('Unable to get distribution: invalid registration_address: %s' % self.registration_address)
if not valid_xpub(self.registration_xpub):
LOG.error('Unable to get distribution: invalid registration_xpub: %s' % self.registration_xpub)
raise Exception('Unable to get distribution: invalid registration_xpub: %s' % self.registration_xpub)
if not valid_block_height(self.registration_block_height):
LOG.error('Unable to get distribution: invalid registration_block_height: %s' % self.registration_block_height)
raise Exception('Unable to get distribution: invalid registration_block_height: %s' % self.registration_block_height)
data = get_lsl(address=self.registration_address, xpub=self.registration_xpub, block_height=self.registration_block_height)
if 'LSL' not in data:
LOG.error('Unable to get distribution: invalid LSL data: %s' % data)
raise Exception('Unable to get distribution: invalid LSL: %s' % data)
distribution = {recipient[0]: recipient[1] for recipient in data['LSL']}
elif transaction_type == 'Send2LAL':
if not valid_address(self.sending_address):
LOG.error('Unable to get distribution: invalid sending_address: %s' % self.sending_address)
raise Exception('Unable to get distribution: invalid sending_address: %s' % self.sending_address)