Skip to content

Commit

Permalink
Fix get transactions CLI for Clawback (Chia-Network#15541)
Browse files Browse the repository at this point in the history
Handle coin record missing
  • Loading branch information
ytx1991 authored Jun 16, 2023
1 parent 11d6c43 commit bde6f39
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions chia/cmds/wallet_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,21 +199,25 @@ async def get_transactions(args: dict, wallet_client: WalletRpcClient, fingerpri
except LookupError as e:
print(e.args[0])
return

skipped = 0
num_per_screen = 5 if paginate else len(txs)
for i in range(0, len(txs), num_per_screen):
for j in range(0, num_per_screen):
if i + j >= len(txs):
if i + j + skipped >= len(txs):
break
coin_record: Optional[Dict[str, Any]] = None
if txs[i + j].type in CLAWBACK_TRANSACTION_TYPES:
coin_record = (
await wallet_client.get_coin_records(
GetCoinRecords(coin_id_filter=HashFilter.include([txs[i + j].additions[0].name()]))
)
)["coin_records"][0]
if txs[i + j + skipped].type in CLAWBACK_TRANSACTION_TYPES:
coin_records = await wallet_client.get_coin_records(
GetCoinRecords(coin_id_filter=HashFilter.include([txs[i + j + skipped].additions[0].name()]))
)
if len(coin_records["coin_records"]) > 0:
coin_record = coin_records["coin_records"][0]
else:
j -= 1
skipped += 1
continue
print_transaction(
txs[i + j],
txs[i + j + skipped],
verbose=(args["verbose"] > 0),
name=name,
address_prefix=address_prefix,
Expand Down

0 comments on commit bde6f39

Please sign in to comment.