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

build_tx.py: Use bitcoinlib to parse raw transactions when the Blockbook server could not find them. #4144

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

oren-z0
Copy link

@oren-z0 oren-z0 commented Aug 31, 2024

I really like the build_tx.py tool, and I patched it to be able to sign a transaction that spends a utxo of a transaction that hasn't been sent to the blockchain yet.

In case the user wants to create two transactions, where the second spends the output of the first, he can do that without broadcasting them. This is useful in scenarios of relative timelocks (using nSequence).

The user can also specify "." as the blockbook host (instead of btc1.trezor.io) and then the script will never send http requests and instead will ask the user to provide the previous raw-transaction for every vin (could be useful in cases with privacy issues).

I couldn't find any existing code in this project that parses raw transactions, so I used: https://pypi.org/project/bitcoinlib (if bitcoinlib is not installed, the behavior remains the same).

@oren-z0 oren-z0 requested a review from matejcik as a code owner August 31, 2024 21:05
@oren-z0 oren-z0 changed the title Use bitcoinlib to parse raw transaction when Blockbook server could not find it. build_tx.py: Use bitcoinlib to parse raw transactions when the Blockbook server could not find them. Aug 31, 2024
@matejcik
Copy link
Contributor

matejcik commented Sep 4, 2024

we already use python-bitcoinlib in the firmware repository so it would be nice if you could use that too?
(yeah bitcoinlib and python-bitcoinlib are two different libs)

If the txid was not found using the api, allow the
user to enter the raw transaction manually.

Users can also enter the previous output in the
format of raw_tx:vout instead of txid:vout
(raw_tx is expected to be in hex format).
@oren-z0
Copy link
Author

oren-z0 commented Sep 11, 2024

@matejcik Fixed. The code now uses python-bitcoinlib.
I hope I got the script_type evaluation correctly:

https://github.com/trezor/trezor-firmware/pull/4144/files#diff-105c3d18beed9785fe90377478d62e08517eb5e6ef585348f6a43bd31d1c3447R153-R160

@matejcik matejcik requested review from ibz and removed request for matejcik September 30, 2024 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants