What is the simplest python program that would query the bitcoin core client for a raw tx?

0

I put this one together that claims "no JSON object could be decoded".

from bitcoinrpc.authproxy import AuthServiceProxy

access = AuthServiceProxy("http://user:password@127.0.0.1:8332")

printme=access.getrawtransaction("6359f0868171b1d194cbee1af2f16ea598ae8fad666d9b012c8ed2b79a236ec4")

print printme

My bitcoin core wallet is set to "server=1" and "listen=1", but it is currently downloading the blockchain (idk if that would have an impact).

Mine

Posted 2018-03-02T03:17:51.240

Reputation: 1 142

Answers

1

If you are still downloading the blockchain and you haven't downloaded and verified that transaction yet, then of course you will get an error when you try to look it up, Bitcoin Core doesn't know about it yet!

Furthermore, if that transaction is not part of your wallet or in the UTXO set (i.e. one of the outputs is unspent), then getrawtransaction won't work. Bitcoin Core can only retrieve arbitrary transactions if you have enabled the transaction index with txindex=1.

Andrew Chow

Posted 2018-03-02T03:17:51.240

Reputation: 40 910

0

need to download blocks from the server Maybe you can try on this (python 3) You need to install bitcoinrpc

#!/usr/bin/python
import json
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException



rpc_connection = AuthServiceProxy("http://%s:%s@127.0.0.1:8332"%("rpc_username", "rpc_password"))
result = rpc_connection.getrawtransaction  ("52309405287e737cf412fc42883d65a392ab950869fae80b2a5f1e33326aca46")
print(result)

Austin Dominic

Posted 2018-03-02T03:17:51.240

Reputation: 1