2

I am running a bitcoin node on my machine, fully synced with RPC commands enabled, rpc server live and txindex=1.

In the command-line I can run the following RPC call and obtain the information about the transaction I require. I am using the cli as I need to process 2.5 million transactions.

./bitcoin-cli decoderawtransaction $(./bitcoin-cli getrawtransaction b601fc820d66b6516f89557fba9b40943df962de96b914547dec72b0f047c2f3)

Which returns a JSON output of the transaction.

However, when run with the python-bitcoinlib library it seems to give the following error message

import bitcoin, bitcoin.rpc bitcoin.SelectParams("mainnet") rpc = bitcoin.rpc.Proxy() rpc.getrawtransaction("b601fc820d66b6516f89557fba9b40943df962de96b914547dec72b0f047c2f3")

InvalidParameterError: {u'message': u'parameter 1 must be of length 64 (not 128)', u'code': -8}

What am I doing wrong, isn't b601.. the transaction id?

Edit: As per comment I fixed it by replacing rpc=bitcoin.rpc.Proxy() with rpc=bitcoin.rpc.RawProxy(). But I would still like to know why the previous fails.

  • 1
    I fixed it by replacing rpc=bitcoin.rpc.Proxy() with rpc=bitcoin.rpc.RawProxy(). But I would still like to know why the previous fails – Oonah Sep 4 '17 at 13:07
  • I suppose there's a difference parsing the hexstring when you use Proxy vs. RawProxy. – renlord Oct 17 '17 at 11:30
-2

getrawtransaction requires little endian format of the trxid, like:

import bitcoin.rpc
from bitcoin.core import lx
p = bitcoin.rpc.Proxy(service_url='http://usr:pa@ip:port')
trxid = lx('7e195aa3de827814f172c362fcf838d92ba10e3f9fdd9c3ecaf79522b311b22d')
rawtrx = p.getrawtransaction(trxid)
print(rawtrx)

Comments from Mr Peter Todd on that:

https://github.com/petertodd/python-bitcoinlib/blob/master/examples/spend-p2pkh-txout.py#L41

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.