<p><a href="https://github.com/richardkiss/pycoin" rel="nofollow">pycoin</a> is probably your best bet. You need the utxo first, which you'll need to look up somewhere (blockchain.info is fine). Once you have the utxos, they'd need to be TxIns like this:</p>

<pre><code>tx_in = TxIn("&lt;utxo hash in binary here&gt;", &lt;utxo position, usually between 0 and 5&gt;)
script = standard_tx_out_script(address)
tx_out = TxOut(&lt;btc amount to send - fee&gt;, script)
tx = Tx(1, [tx_in], [tx_out])
lookup = &lt;this part you have to figure out&gt;
tx.sign(lookup)
print tx.as_hex()
</code></pre>

<p>You can take the results and paste to something like <a href="https://blockchain.info/pushtx" rel="nofollow">blockchain.info's send transaction page</a>.</p>

<p>NOTE: It's very easy to screw this up and have a too-high tx fee or lose your coins altogether. I would NOT recommend it. Install Armory and import the key or do the same using Mycelium. It's a lot safer to do it that way.</p>

CC BY-SA 3.0
2016-03-20T01:36:19.163Z
2016-03-20T01:36:19.163Z
Jimmy Song
<p>I have a private key (raw + WIF) and I want to send all funds from that address - fee to another address. </p>

<p>Is there a raw python function that can do that for me ? I will broadcast the tx manually.</p>

<p>I tried to look into electrum source code but I find it to complicated for this task please help.</p>

<client><electrum><python>
Create raw transaction in python
sektor
# Create raw transaction in python

(Asked by: username_0 on 2016-03-19)

I have a private key (raw + WIF) and I want to send all funds from that address - fee to another address.

Is there a raw python function that can do that for me ? I will broadcast the tx manually.

I tried to look into electrum source code but I find it to complicated for this task please help.

**Tags:** client, electrum, python


---

## 1 answers

### Answer by username_1 on 2016-03-20. Score: 3

[pycoin](https://github.com/richardkiss/pycoin) is probably your best bet. You need the utxo first, which you'll need to look up somewhere (blockchain.info is fine). Once you have the utxos, they'd need to be TxIns like this:

```
tx_in = TxIn("<utxo hash in binary here>", <utxo position, usually between 0 and 5>)
script = standard_tx_out_script(address)
tx_out = TxOut(<btc amount to send - fee>, script)
tx = Tx(1, [tx_in], [tx_out])
lookup = <this part you have to figure out>
tx.sign(lookup)
print tx.as_hex()

```

You can take the results and paste to something like [blockchain.info's send transaction page](https://blockchain.info/pushtx).

NOTE: It's very easy to screw this up and have a too-high tx fee or lose your coins altogether. I would NOT recommend it. Install Armory and import the key or do the same using Mycelium. It's a lot safer to do it that way.


---

