Bitcoin Forum
November 18, 2018, 05:04:03 AM *
News: Latest Bitcoin Core release: 0.17.0 [Torrent].
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: analyze TRX via CLI/Unix Shell (trx2txt) - now with SegWit  (Read 1717 times)
pebwindkraft
Full Member
***
Offline Offline

Activity: 256
Merit: 239


View Profile
June 10, 2016, 12:45:54 PM
 #1

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  Grin

enjoy!
1542517443
Hero Member
*
Offline Offline

Posts: 1542517443

View Profile Personal Message (Offline)

Ignore
1542517443
Reply with quote  #2

1542517443
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
ca333
Hero Member
*****
Offline Offline

Activity: 502
Merit: 500


Developer - EthicHacker - BTC enthusiast


View Profile
June 11, 2016, 06:41:26 PM
 #2

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  Grin

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!

this space is available (free) for humanitarian nonprofit organizations - please contact me
pebwindkraft
Full Member
***
Offline Offline

Activity: 256
Merit: 239


View Profile
June 12, 2016, 08:22:23 PM
 #3

sure, didn't get the security implications of a zipped file...
Here we go:

https://github.com/pebwindkraft/trx2txt

pebwindkraft
Full Member
***
Offline Offline

Activity: 256
Merit: 239


View Profile
June 15, 2016, 06:32:49 PM
 #4

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


ca333
Hero Member
*****
Offline Offline

Activity: 502
Merit: 500


Developer - EthicHacker - BTC enthusiast


View Profile
June 15, 2016, 08:21:07 PM
 #5

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.

this space is available (free) for humanitarian nonprofit organizations - please contact me
pebwindkraft
Full Member
***
Offline Offline

Activity: 256
Merit: 239


View Profile
July 23, 2016, 05:58:52 PM
 #6

Hi team(s)  Wink

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
LeChuckDE
Sr. Member
****
Offline Offline

Activity: 420
Merit: 252



View Profile
July 23, 2016, 09:27:43 PM
 #7

+1 good job Volker !
pebwindkraft
Full Member
***
Offline Offline

Activity: 256
Merit: 239


View Profile
December 19, 2016, 09:16:40 AM
 #8

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.
pebwindkraft
Full Member
***
Offline Offline

Activity: 256
Merit: 239


View Profile
October 04, 2017, 09:22:44 AM
 #9

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). 
btc_enigma
Hero Member
*****
Offline Offline

Activity: 631
Merit: 501


View Profile
October 06, 2017, 09:55:33 AM
 #10

Good Job ! You may also want to have a look at this https://github.com/shivaenigma/bitcointools

pebwindkraft
Full Member
***
Offline Offline

Activity: 256
Merit: 239


View Profile
October 29, 2017, 10:38:05 PM
 #11

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
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!