Skip to content

Commit

Permalink
SFT-1708: restored try-except
Browse files Browse the repository at this point in the history
  • Loading branch information
mjg-foundation committed Oct 14, 2023
1 parent f9c1798 commit 7d44e28
Showing 1 changed file with 34 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,45 +24,42 @@ async def search_for_address_task(
import stash
from errors import Error
from uasyncio import sleep_ms
from ubinascii import hexlify as b2a_hex

# try:
with stash.SensitiveValues() as sv:
if multisig_wallet:
# NOTE: Can't easily reverse order here, so this is slightly less efficient
for (curr_idx, paths, curr_address, script) in multisig_wallet.yield_addresses(
start_address_idx,
max_to_check,
change_idx=1 if is_change else 0):
# print('Multisig: curr_idx={}: paths={} curr_address = {}'.format(curr_idx, paths, curr_address))
try:
with stash.SensitiveValues() as sv:
if multisig_wallet:
# NOTE: Can't easily reverse order here, so this is slightly less efficient
for (curr_idx, paths, curr_address, script) in multisig_wallet.yield_addresses(
start_address_idx,
max_to_check,
change_idx=1 if is_change else 0):
# print('Multisig: curr_idx={}: paths={} curr_address = {}'.format(curr_idx, paths, curr_address))

if curr_address == address:
# NOTE: Paths are the full paths of the addresses of each signer
await on_done(curr_idx, paths, None)
return
await sleep_ms(1)
if curr_address == address:
# NOTE: Paths are the full paths of the addresses of each signer
await on_done(curr_idx, paths, None)
return
await sleep_ms(1)

else:
r = range(start_address_idx, start_address_idx + max_to_check)
if reverse:
r = reversed(r)
else:
r = range(start_address_idx, start_address_idx + max_to_check)
if reverse:
r = reversed(r)

for curr_idx in r:
addr_path = '{}/{}/{}'.format(path, is_change, curr_idx) # Zero for non-change address
# print('Singlesig: addr_path={}'.format(addr_path))
node = sv.derive_path(addr_path)
print(b2a_hex(node.public_key()))
curr_address = sv.chain.address(node, addr_type)
# print(' curr_idx={}: path={} addr_type={} curr_address = {}'.format(curr_idx, addr_path,
# addr_type, curr_address))
print("path: {}, address: {}".format(addr_path, curr_address))
if curr_address == address:
await on_done(curr_idx, addr_path, None)
return
await sleep_ms(1)
for curr_idx in r:
addr_path = '{}/{}/{}'.format(path, is_change, curr_idx) # Zero for non-change address
# print('Singlesig: addr_path={}'.format(addr_path))
node = sv.derive_path(addr_path)
curr_address = sv.chain.address(node, addr_type)
# print(' curr_idx={}: path={} addr_type={} curr_address = {}'.format(curr_idx, addr_path,
# addr_type, curr_address))
if curr_address == address:
await on_done(curr_idx, addr_path, None)
return
await sleep_ms(1)

await on_done(-1, None, Error.ADDRESS_NOT_FOUND)
# except Exception as e:
# # print('EXCEPTION: e={}'.format(e))
# # Any address handling exceptions result in no address found
# await on_done(-1, None, Error.ADDRESS_NOT_FOUND)
await on_done(-1, None, Error.ADDRESS_NOT_FOUND)
except Exception as e:
# print('EXCEPTION: e={}'.format(e))
# Any address handling exceptions result in no address found
await on_done(-1, None, Error.ADDRESS_NOT_FOUND)

0 comments on commit 7d44e28

Please sign in to comment.