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.

1 Answer 1


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>
print tx.as_hex()

You can take the results and paste to something like blockchain.info's send transaction page.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.