I'm parsing the blockchain to extract certain information I need for a script.

One thing I do is parsing transactions. What I do is:

getrawtransaction <tx>
decoderawtransaction <rawtx>

This works on most of the transactions (>99%) but some are very huge and the bitcoin client cant handle them. I wonder what else can handle them if not bitcoind itself. The error I get in bitcoind:

TX decode failed (code -22)

Thats because it cant accept very long arguments. My ruby script dies with

Arguement list too long - (Errno::E2BIG)

How to decode such transactions? Here are some examples:



Update: I just tried to paste the rawtransaction to this online parser and this one decodes that transaction without any problems. How is that possible programmatically?

4 Answers 4


try this:

bitcoind getrawtransaction 2f50fdf7adbf58e91d738869948f4b191eb3cafa016c6df7e9182c06e4513852 1

note the 1 at the end, which instructs bitcoind to operate in verbose mode.


It sounds like you are passing the whole transaction on the command line, but your operating system has a limit on the maximum (combined) length of command line arguments, which has been exceeded. The message "Argument list too long" is an OS error, not from bitcoind itself.

You should be able to use the -stdin argument from bitcoin-cli to pass it via standard input instead of on the command line, in which case there are no length limits. On a Unix-like operating system, you'll likely want to pass the data via a pipe, using popen(3) or its equivalent in your language of choice, but you could also write to a temporary file.


Bitcoind can accept very long inputs, but if you are using bitcoin-cli there is a limit on how long a command-line argument can be. You can use the -stdin option to send the arguments to bitcoin-cli vis stdin and bypass the size limit on arguments.


There are libraries for deserializing transactions out there.

pybitcointools - python

bitwasp/bitcoin-php - php

libbitcoin - C++/C

OUTDATED: bitcoin-lib-php - php

There's bound to be many others.

  • 1
    Do you know of any in JavaScript? For example, can Bitcore deserialise transactions?
    – Randomblue
    Commented Dec 15, 2015 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.