Constructing, signing, and pushing a Bitcoin transaction by using pybitcointools with Python I'm utilizing the pybitcointools module in python 3.4

I've went through time and time again in the examples listed on the github page, but it isn't documented very well nor is the code.

My situation is this: I have a list of private keys in a CSV and I want to generate a raw transaction for each address and spend their unspent_outputs to a single address by pushing the signed transaction to blockchain.info

I'm having a problem when it comes to the these functions: mktx, mksend, sign

If someone could create an example of the process while also documenting each step and explaining what each argument for each function is for and how it's used. This would be an amazing help if someone could give a hand here! I've searched far and low, but I just can't find a good documentation of this process. I'm sure this would help many others as well!
OK, so first off:


Use Python 2.7; there's numerous pieces of code which doesn't work with Python 3.4, namely make_request
Check out this pybitcointools fork, as there's a lot of added functionality (see the README.txt file)


The functions you've named work as so:


mktx(ins, outs) where ins is an array of "hexTxIdString:index" and outs is an array of {"value": 12345, "address": 1base58addressString}
mksend(ins, outs, txfee, 1changeAddress) where txfee is again in Satoshis


sign(unsignedtx, index to sign, privkey for utxo) where index is the input index to sign



We'll start by making the ins:

utxos = [(utxo_txid, utxo_index), (txid2, i2)....]
ins = ["%s:%d" % utxo for utxo in utxos]
change_addr = "1thisIsAChangeAddressYouOwn123"
txfee = int(0.45 * len(ins) * 10000) # you may want to check this 10000 value, it could be 100000
rawtx = mksend(ins, txfee, change_addr)


Right, so let's assume, you have the UTXOs' TxID and corresponding vout for each private key. Make an dict of privkeys ={ 'TxID:vout' : privkey, 'TxID2:vout2': privkey2 } Then finally, signall(rawtx, privkeys) to get your signed Tx. Then to broadcast it, use pushtx(signedTx, source="bci") or pushtx(signedTx, "testnet", source="blockr") for Testnet. Done!