Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clarify how to break out of build_tx loops #4092

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 Exception:
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 Exception:
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
Loading