'Create a transaction from json inputs.
Inputs must have a redeemPubkey.
Outputs must be a list of {\'address\':address, \'value\':satoshi_amount}.'

@command('')
def serialize(self, jsontx):

    keypairs = {}
    inputs = jsontx.get('inputs')
    outputs = jsontx.get('outputs')
    locktime = jsontx.get('locktime', 0)
    for txin in inputs:
        if txin.get('output'):
            (prevout_hash, prevout_n) = txin['output'].split(':')
            txin['prevout_n'] = int(prevout_n)
            txin['prevout_hash'] = prevout_hash
        if txin.get('redeemPubkey'):
            pubkey = txin['redeemPubkey']
            txin['type'] = 'p2pkh'
            txin['x_pubkeys'] = [pubkey]
            txin['signatures'] = [None]
            txin['num_sig'] = 1
            if txin.get('privkey'):
                keypairs[pubkey] = txin['privkey']
        elif txin.get('redeemScript'):
            raise BaseException('Not    implemented')
    outputs = map((lambda x: (TYPE_ADDRESS, x['address'], int(x['value']))), outputs)
    tx = Transaction.from_io(inputs, outputs, locktime=locktime)
    tx.sign(keypairs)
    return tx.as_dict()
