<p>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!</p>

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

CC BY-SA 3.0
2018-03-02T04:09:42.463Z
2018-03-02T04:09:42.463Z
Ava Chow
<p>need to download blocks from the server
Maybe you can try on this (python 3)
You need to install bitcoinrpc</p>

<pre><code>#!/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)
</code></pre>

CC BY-SA 3.0
2018-03-02T04:20:55.887Z
2018-03-02T04:20:55.887Z
Austin Dominic
<p>I put this one together that claims "no JSON object could be decoded".</p>

<blockquote>
  <p>from bitcoinrpc.authproxy import AuthServiceProxy </p>
  
  <p>access =
  AuthServiceProxy("<a href="http://user:password@127.0.0.1:8332" rel="nofollow noreferrer">http://user:password@127.0.0.1:8332</a>") </p>
  
  <p>printme=access.getrawtransaction("6359f0868171b1d194cbee1af2f16ea598ae8fad666d9b012c8ed2b79a236ec4")</p>
  
  <p>print printme</p>
</blockquote>

<p>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).</p>

<bitcoin-core><json-rpc><raw-transaction>
What is the simplest python program that would query the bitcoin core client for a raw tx?
Mine
# What is the simplest python program that would query the bitcoin core client for a raw tx?

(Asked by: username_0 on 2018-03-02)

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).

**Tags:** bitcoin-core, json-rpc, raw-transaction


---

## 2 answers

### Answer by username_1 on 2018-03-02. Score: 1 | Accepted answer

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`.


---

### Answer by username_2 on 2018-03-02. Score: 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)

```


---

