'In txout, set script_type, address_version, binaddr, and for multisig, required_signatures.'

def _export_scriptPubKey(store, txout, chain, scriptPubKey):

    if (scriptPubKey is None):
        txout['script_type'] = None
        txout['binaddr'] = None
        return
    (script_type, data) = chain.parse_txout_script(scriptPubKey)
    txout['script_type'] = script_type
    txout['address_version'] = chain.address_version
    if (script_type == Chain.SCRIPT_TYPE_PUBKEY):
        txout['binaddr'] = chain.pubkey_hash(data)
    elif (script_type == Chain.SCRIPT_TYPE_ADDRESS):
        txout['binaddr'] = data
    elif (script_type == Chain.SCRIPT_TYPE_P2SH):
        txout['address_version'] = chain.script_addr_vers
        txout['binaddr'] = data
    elif (script_type == Chain.SCRIPT_TYPE_MULTISIG):
        txout['required_signatures'] = data['m']
        txout['binaddr'] = chain.pubkey_hash(scriptPubKey)
        txout['subbinaddr'] = [chain.pubkey_hash(pubkey) for pubkey in data['pubkeys']]
    elif (script_type == Chain.SCRIPT_TYPE_BURN):
        txout['binaddr'] = NULL_PUBKEY_HASH
    else:
        txout['binaddr'] = None
