3

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:

2f50fdf7adbf58e91d738869948f4b191eb3cafa016c6df7e9182c06e4513852
e7229316b5a5b1f53382ec5a526b842dda2ca96bc891cd02d397a52c4a84dba0
540359af779a510828f0afd3c88562b62c37d0e4eeccb08104a167a3600f7956

Thanks.


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?

6

try this:

bitcoind getrawtransaction 2f50fdf7adbf58e91d738869948f4b191eb3cafa016c6df7e9182c06e4513852 1

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

2

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.

1

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.

-1

There are libraries for deserializing transactions out there.

pybitcointools - python

bitcoin-lib-php - php

libbitcoin - C++/C

There's bound to be many others.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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