From c82fad68e7373117e24abd2e8763f0054132be36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ioan=20Biz=C4=83u?= Date: Wed, 7 Aug 2024 12:13:18 +0200 Subject: [PATCH] fix: clarify how to break out of build_tx loops [no changelog] --- python/tools/build_tx.py | 15 +++++++++++---- tools/snippets/sign_tx.py | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/python/tools/build_tx.py b/python/tools/build_tx.py index 12aabc768..6241a277d 100755 --- a/python/tools/build_tx.py +++ b/python/tools/build_tx.py @@ -75,11 +75,14 @@ def _get_inputs_interactive( while True: echo() prev = prompt( - "Previous output to spend (txid:vout)", type=parse_vin, default="" + "Previous output to spend (txid:vout / empty string to skip)", default="" ) if not prev: break - prev_hash, prev_index = prev + try: + prev_hash, prev_index = parse_vin(prev) + except Exception: + continue txhash = prev_hash.hex() tx_url = blockbook_url + txhash @@ -140,17 +143,21 @@ def _get_outputs_interactive() -> List[messages.TxOutputType]: outputs: List[messages.TxOutputType] = [] while True: echo() - address = prompt("Output address (for non-change output)", default="") + address = prompt("Output address for non-change output", default="") if address: address_n = None script_type = messages.OutputScriptType.PAYTOADDRESS else: address = None address_n = prompt( - "BIP-32 path (for change output)", type=tools.parse_path, default="" + "BIP-32 path for change output (empty string to skip)", default="" ) if not address_n: break + try: + address_n = tools.parse_path(address_n) + except Exception: + continue script_type = prompt( "Output type", type=ChoiceType(OUTPUT_SCRIPTS), diff --git a/tools/snippets/sign_tx.py b/tools/snippets/sign_tx.py index 5c36d2bb4..2dfa5746b 100644 --- a/tools/snippets/sign_tx.py +++ b/tools/snippets/sign_tx.py @@ -4,7 +4,7 @@ specific inputs and outputs inspired by BTC device tests. INPUTS and OUTPUTS lists are the only things needed to be modified. -Similar to tools/build_tx.py, but more suitable for bigger/autogenerated transactions. +Similar to python/tools/build_tx.py, but more suitable for bigger/autogenerated transactions. The serialized transaction can then be announced to network at https://tbtc1.trezor.io/sendtx It could be useful to inspect the transaction details at https://live.blockcypher.com/btc/decodetx/