Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: pebwindkraft on June 10, 2016, 12:45:54 PM



Title: analyze TRX via CLI/Unix Shell (trx2txt) - now with SegWit
Post by: pebwindkraft on June 10, 2016, 12:45:54 PM
Hi,

thought I share my command line tool with the audience.
I wrote the script to better understand the transaction details.
I wanted to start with the python tools and perl tools, but had several issues on versions, links, required subtools, dependencies - after a day I got tired. I wanted to be able to analyze my trx on OpenBSD, MAC OS X and SuSE Linux. No tool could provide this, so I thought I'd give it a try. Need some POSIX compliance here...

- the script (trx2txt.sh) produces a transaction output similiar to the JSON outputs that can be found on blockchain.info.
- it shows the OpCodes of the TRX_IN sig scripts and TRX_OUT public key scripts (hex values)
- shows type of transaction script (P2PKH, P2SH, MULTISIG, ...)
- it shows the corresponding bitcoin address (hash).
- there is a detailed README with the file, supporting doc and state machine picture (and each script is heavily commented)
- there are test cases included

The link is here:

nowarra.ch/Volker/160610_TRX2TXT.zip (removed 15June2016)

The code is not (yet?) beautified, nor made for performance reasons...
And yes, there is room for improvement  ;D

enjoy!


Title: Re: analyze TRX via CLI/Unix Shell (trx2txt)
Post by: ca333 on June 11, 2016, 06:41:26 PM
Hi,

thought I share my command line tool with the audience.
I wrote the script to better understand the transaction details.
I wanted to start with the python tools and perl tools, but had several issues on versions, links, required subtools, dependencies - after a day I got tired. I wanted to be able to analyze my trx on OpenBSD, MAC OS X and SuSE Linux. No tool could provide this, so I thought I'd give it a try. Need some POSIX compliance here...

- the script (trx2txt.sh) produces a transaction output similiar to the JSON outputs that can be found on blockchain.info.
- it shows the OpCodes of the TRX_IN sig scripts and TRX_OUT public key scripts (hex values)
- shows type of transaction script (P2PKH, P2SH, MULTISIG, ...)
- it shows the corresponding bitcoin address (hash).
- there is a detailed README with the file, supporting doc and state machine picture (and each script is heavily commented)
- there are test cases included

The link is here:

link removed from OP

The code is not (yet?) beautified, nor made for performance reasons...
And yes, there is room for improvement  ;D

enjoy!

you could provide the script on a gist or on github. Why on earth you zip a simple shell script?

@all readers - as always: BE CAUTIOS when downloading any files from untrusted sources. They can contain VIRUS and WALLETSTEALING software. Never trust nobody!


Title: Re: analyze TRX via CLI/Unix Shell (trx2txt)
Post by: pebwindkraft on June 12, 2016, 08:22:23 PM
sure, didn't get the security implications of a zipped file...
Here we go:

https://github.com/pebwindkraft/trx2txt



Title: Re: analyze TRX via CLI/Unix Shell (trx2txt)
Post by: pebwindkraft on June 15, 2016, 06:32:49 PM
removed old link to zipped file, everything on github now.
Added a cool feature to directly load trx from network (blockchain.info):

./trx2txt.sh -vv -t 7264f8ba4a85a4780c549bf04a98e8de4c9cb1120cb1dfe8ab85ff6832eff864

have fun :-)

Volker




Title: Re: analyze TRX via CLI/Unix Shell (trx2txt)
Post by: ca333 on June 15, 2016, 08:21:07 PM
removed old link to zipped file, everything on github now.
Added a cool feature to directly load trx from network (blockchain.info):

./trx2txt.sh -vv -t 7264f8ba4a85a4780c549bf04a98e8de4c9cb1120cb1dfe8ab85ff6832eff864

have fun :-)

Volker




+1 - very good Volker. github and basically any versioning capable hosting for sources is the best you can do.. i will look at this the coming weekend. now saw its couple of files. will be great when you add little info in the readme about each script so we can have fast look/review.


Title: Re: analyze TRX via CLI/Unix Shell (trx2txt) + Cold Storage
Post by: pebwindkraft on July 23, 2016, 05:58:52 PM
Hi team(s)  ;)

I further improved the scripts, to include possibility for creating/signing transactions (cold storage!).
With some help (from here: https://bitcointalk.org/index.php?topic=1535855.0) I did several fixes and updates, to also have improved portability.

Here is my last transaction with the tools, which I created on Mac OSX, put it on USB to my Cold Storage OpenBSD system, signed it, and brought it back to MAC OSX. Via blockchain.info's "pushtx" I sent it into the network.

https://blockchain.info/de/rawtx/4fc62561c97c15599831e13dbdbc2afc65d9526d116ed664036c147e55162d05

I am currently limited to one previous trx, and one output, for a P2PKH trx.

Code as usual here:
https://github.com/pebwindkraft/trx2txt

enjoy :-)
Volker


Title: Re: analyze TRX via CLI/Unix Shell (trx2txt)
Post by: LeChuckDE on July 23, 2016, 09:27:43 PM
+1 good job Volker !


Title: Re: analyze TRX via CLI/Unix Shell
Post by: pebwindkraft on December 19, 2016, 09:16:40 AM
just modified title, as old tool (trx2txt) is discontinued.

Shell scripts for Linux, MacOS and OpenBSD are here:
https://github.com/pebwindkraft/trx_cl_suite

last added functionality was DER sig check, creation of transaction with multiple inputs, and calculation of fees. Here is a transaction with 53 TX Inputs:
https://blockchain.info/de/tx/a9895d9891c21e515a449245e60a97054716f68bd023622a69db80ed44c1e5e4?show_adv=true

Those who forked, may want to update.

Final help came from stackexchange (a very valuable ressource!), thx to the team running this environment:
http://bitcoin.stackexchange.com/questions/49661/signing-tx-with-openssl-but-fails-when-sending-with-bitcoin-qt-how-to-debug/49953#49953

thx.


Title: analyze TRX via CLI/Unix Shell (tx_cl_suite): now with SegWit
Post by: pebwindkraft on October 04, 2017, 09:22:44 AM
just another short update: as it is time to play with segwit, I have extended the tx analyzer (tcls_tx2txt.sh) with capabilities for SegWit. The decomposition would show now the details of any SegWit tx.
(as usual testcases are also included). 


Title: Re: analyze TRX via CLI/Unix Shell (trx2txt) - now with SegWit
Post by: btc_enigma on October 06, 2017, 09:55:33 AM
Good Job ! You may also want to have a look at this https://github.com/shivaenigma/bitcointools


Title: Re: analyze TRX via CLI/Unix Shell (trx2txt) - now with SegWit
Post by: pebwindkraft on October 29, 2017, 10:38:05 PM
and some more update: the idea of smart contracts become more and more important... people seem to believe, smart contracts are a unique element of Ethereum or other altcoins, this is simply not true. Bitcoin and it's scripting language has these capabilities for a long time, and I thought I update my tx analyzer (tcls_tx2txt.sh) in a way, that the sig scripts display more than a block of some op_codes. The corresponding testcase file (tcls_testcases_tx2txt.sh) has testcase14 for latest SegWit tx, testcase16 and 17 for CLTV and CSV smart contracts, with examples from the forum here (and the links). Have fun, as usual the shell scripts are here:
https://github.com/pebwindkraft/trx_cl_suite