def create_transaction(node, coinbase, to_address, amount, expiry_height): from_txid = node.getblock(coinbase)['tx'][0] inputs = [{"txid": from_txid, "vout": 0}] outputs = {to_address: amount} rawtx = node.createrawtransaction(inputs, outputs) tx = CTransaction() # Set the expiry height f = cStringIO.StringIO(unhexlify(rawtx)) tx.deserialize(f) tx.nExpiryHeight = expiry_height rawtx = hexlify(tx.serialize()) signresult = node.signrawtransaction(rawtx) f = cStringIO.StringIO(unhexlify(signresult['hex'])) tx.deserialize(f) tx.rehash() return tx