<p>Yes, <a href="https://github.com/vbuterin/pybitcointools" rel="nofollow">Pybitcointools</a> (or <a href="https://github.com/simcity4242/pybitcointools" rel="nofollow">this fork</a> which has BIP39, file embedding and <code>mk_opreturn</code>) can do this.</p>

<p>Install either version of pybitcointools using <code>setup.py install</code>, as usual.</p>

<p>Then, with a raw hex transaction, <code>rawtx</code>, simply use <code>txo = deserialize(rawtx)</code>. <code>rawtx</code> can be either a signed or unsigned hex transaction. The returned <code>txo</code> is deserialized as a <code>dict</code> object. Use <code>serialize(txo)</code> to get back to <code>rawtx</code>.</p>

<p>You can fetch TxIDs using <code>fetchtx(hex_txid, source="blockr")</code> and send signed Txs with <code>pushtx(signed_hex_tx, source="bci")</code>.</p>

CC BY-SA 3.0
2015-07-13T00:48:56.133Z
Does Pybitcointools send an RPC call to bitcoind to deserialize raw transactions or does it do the conversion within the module?
SLee
CC BY-SA 3.0
2015-07-13T02:47:41.533Z
@SLee From the module: no RPC required
Wizard Of Ozzie
CC BY-SA 3.0
2015-07-10T07:49:55.097Z
2015-07-10T07:49:55.097Z
Wizard Of Ozzie
<p>I'm currently doing RPC calls to bitcoin-cli within python to get raw block data:</p>

<pre><code>bitcoin-cli getblock BLOCKHASH False
</code></pre>

<p>I've already written a function that cuts off the block header and splits the transaction block into individual transactions, resulting in the same result as: </p>

<pre><code>bitcoin-cli getrawblock TXID
</code></pre>

<p>I'm now trying to convert this data into the same result as</p>

<pre><code>bitcoin-cli getrawblock TXID 1
</code></pre>

<p>without doing another RPC call to bitcoind. Would prefer to use pre-existing modules if possible.</p>

<p>Python packages would be appreciated.</p>

<bitcoind><raw-transaction><raw-data><python>
Are there any Python modules that decode raw transaction data?
SLee
# Are there any Python modules that decode raw transaction data?

(Asked by: username_0 on 2015-07-09)

I'm currently doing RPC calls to bitcoin-cli within python to get raw block data:

```
bitcoin-cli getblock BLOCKHASH False

```

I've already written a function that cuts off the block header and splits the transaction block into individual transactions, resulting in the same result as:

```
bitcoin-cli getrawblock TXID

```

I'm now trying to convert this data into the same result as

```
bitcoin-cli getrawblock TXID 1

```

without doing another RPC call to bitcoind. Would prefer to use pre-existing modules if possible.

Python packages would be appreciated.

**Tags:** bitcoind, raw-transaction, raw-data, python


---

## 1 answers

### Answer by username_1 on 2015-07-10. Score: 4 | Accepted answer

Yes, [Pybitcointools](https://github.com/vbuterin/pybitcointools) (or [this fork](https://github.com/simcity4242/pybitcointools) which has BIP39, file embedding and `mk_opreturn`) can do this.

Install either version of pybitcointools using `setup.py install`, as usual.

Then, with a raw hex transaction, `rawtx`, simply use `txo = deserialize(rawtx)`. `rawtx` can be either a signed or unsigned hex transaction. The returned `txo` is deserialized as a `dict` object. Use `serialize(txo)` to get back to `rawtx`.

You can fetch TxIDs using `fetchtx(hex_txid, source="blockr")` and send signed Txs with `pushtx(signed_hex_tx, source="bci")`.

> **Comments:**
> **username_0**: Does Pybitcointools send an RPC call to bitcoind to deserialize raw transactions or does it do the conversion within the module?  
> **username_1**: @username_0 From the module: no RPC required  

---

