Skip to content

Commit

Permalink
fix: clarify how to break out of build_tx loops
Browse files Browse the repository at this point in the history
  • Loading branch information
ibz committed Sep 18, 2024
1 parent 02533aa commit 6d69e25
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions python/tools/build_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
continue

txhash = prev_hash.hex()
tx_url = blockbook_url + txhash
Expand Down Expand Up @@ -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:
continue
script_type = prompt(
"Output type",
type=ChoiceType(OUTPUT_SCRIPTS),
Expand Down
2 changes: 1 addition & 1 deletion tools/snippets/sign_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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/
Expand Down

0 comments on commit 6d69e25

Please sign in to comment.