def zchain_address_validate(chainId,addr): chainId = chainId.lower() logger.info("Zchain.Address.validate") if type(chainId) != unicode: return error_utils.mismatched_parameter_type('chainId', 'STRING') if type(addr) != unicode: return error_utils.mismatched_parameter_type('addr', 'STRING') result = None if sim_btc_plugin.has_key(chainId): result = sim_btc_plugin[chainId].sim_btc_validate_address(addr) elif chainId == "hc": result = hc_plugin.hc_validate_address(addr) elif chainId == "usdt": result = usdt_plugin.omni_validate_address(addr) elif chainId == "btm": result = btm_plugin.btm_validate_address(addr) return { "chainId": chainId, "valid": result } elif chainId == "eth" or 'erc'in chainId: result = eth_utils.eth_validate_address(addr) return { "chainId": chainId, "valid": result } else: return error_utils.invalid_chainid_type(chainId) return { "chainId":chainId, "valid" : result.get("isvalid") }
def zchain_multisig_add(chainId, addrs, amount, addrType): logger.info('Zchain.Multisig.Add') chainId = chainId.lower() if type(chainId) != unicode: return error_utils.mismatched_parameter_type('chainId', 'STRING') if type(addrs) != list: return error_utils.mismatched_parameter_type('addrs', 'ARRAY') if type(amount) != int: return error_utils.mismatched_parameter_type('amount', 'INTEGER') if type(addrType) != int: return error_utils.mismatched_parameter_type('addrType', 'INTEGER') address = "" if sim_btc_plugin.has_key(chainId): multisig_addr = sim_btc_plugin[chainId].sim_btc_add_multisig( addrs, amount) if multisig_addr is not None: addr_info = sim_btc_plugin[chainId].sim_btc_validate_address( multisig_addr) if addr_info == "": multisig_record = db.get_collection( "b_" + chainId + "_multisig_address").find_one( {"address": multisig_addr}) if multisig_record is not None: db.get_collection("b_" + chainId + "_multisig_address").remove( {"address": multisig_addr}) data = { "address": addr_info["address"], "redeemScript": addr_info["hex"], "addr_type": addrType } db.get_collection("b_" + chainId + "_multisig_address").insert_one(data) address = addr_info["address"] elif chainId == "hc": multisig_addr = hc_plugin.hc_add_multisig(addrs, amount) if multisig_addr is not None: addr_info = hc_plugin.hc_validate_address(multisig_addr) if addr_info is not None: multisig_record = db.get_collection( "b_hc_multisig_address").find_one( {"address": multisig_addr}) if multisig_record is not None: db.get_collection("b_hc_multisig_address").remove( {"address": multisig_addr}) data = { "address": addr_info["address"], "redeemScript": addr_info["hex"], "addr_type": addrType } db.get_collection("b_hc_multisig_address").insert_one(data) else: return error_utils.invalid_chainid_type() return {'chainId': chainId, 'data': address}