def get_multichain_op_drop_data(script): """ Get OP DROP data. :param script: script byte data :return: """ try: decoded = [x for x in deserialize.script_GetOp(script)] except Exception: return None data = None if deserialize.match_decoded(decoded, Chain.SCRIPT_MULTICHAIN_TEMPLATE): data = decoded[5][1] elif deserialize.match_decoded(decoded, Chain.SCRIPT_MULTICHAIN_P2SH_TEMPLATE): data = decoded[3][1] # 4th element contains the OP_DROP data. elif deserialize.match_decoded(decoded, Chain.SCRIPT_MULTICHAIN_STREAM_ITEM_TEMPLATE): data = decoded[0][1] # 1st element contains the creation txid OP_DROP data elif deserialize.match_decoded(decoded, Chain.SCRIPT_MULTICHAIN_STREAM_FORMATTED_ITEM_TEMPLATE): data = decoded[0][1] # 1st element contains the creation txid OP_DROP data elif deserialize.match_decoded(decoded, Chain.SCRIPT_MULTICHAIN_STREAM_TEMPLATE): data = decoded[0][1] # 1st element contains the OP_DROP data. elif deserialize.match_decoded(decoded, Chain.SCRIPT_MULTICHAIN_SPKN_TEMPLATE): data = decoded[0][1] # 1st element contains the OP_DROP data. elif deserialize.match_decoded(decoded, Chain.SCRIPT_MULTICHAIN_FOLLOW_ON_ISSUANCE_METADATA_TEMPLATE): data = decoded[0][1] # 1st element contains the OP_DROP data. elif len(decoded) >= 3 and decoded[-2][1] and decoded[-2][1].startswith("spkq"): data = decoded[-2][1] # element before last contains the OP_DROP data. return data
def get_gamechain_op_drop_data(script): """ Get OP DROP data. :param script: script byte data :return: """ try: decoded = [x for x in deserialize.script_GetOp(script)] except Exception: return None data = None if deserialize.match_decoded(decoded, Chain.SCRIPT_GAMECHAIN_TEMPLATE): data = decoded[5][1] elif deserialize.match_decoded(decoded, Chain.SCRIPT_GAMECHAIN_P2SH_TEMPLATE): data = decoded[3][1] # 4th element contains the OP_DROP data. elif deserialize.match_decoded( decoded, Chain.SCRIPT_GAMECHAIN_STREAM_ITEM_TEMPLATE): data = decoded[0][ 1] # 1st element contains the creation txid OP_DROP data elif deserialize.match_decoded(decoded, Chain.SCRIPT_GAMECHAIN_STREAM_TEMPLATE): data = decoded[0][1] # 1st element contains the OP_DROP data. elif deserialize.match_decoded(decoded, Chain.SCRIPT_GAMECHAIN_SPKN_TEMPLATE): data = decoded[0][1] # 1st element contains the OP_DROP data. elif deserialize.match_decoded( decoded, Chain.SCRIPT_GAMECHAIN_FOLLOW_ON_ISSUANCE_METADATA_TEMPLATE): data = decoded[0][1] # 1st element contains the OP_DROP data. return data
def get_multichain_op_return_data(script): """ Get OP_RETURN data. :param script: script byte data :return: """ try: decoded = [x for x in deserialize.script_GetOp(script)] except Exception: return None data = None if deserialize.match_decoded(decoded, Chain.SCRIPT_MULTICHAIN_STREAM_TEMPLATE): data = decoded[3][1] # 4th element contains the OP_RETURN data. return data
def get_multichain_op_drop_data(script): ''' Get OP DROP data. :param script: script byte data :return: ''' try: decoded = [x for x in deserialize.script_GetOp(script)] except Exception: return None data = None if deserialize.match_decoded(decoded, Chain.SCRIPT_MULTICHAIN_TEMPLATE): data = decoded[5][1] return data
def parse_txout_script(chain, script): """ Return TYPE, DATA where the format of DATA depends on TYPE. * SCRIPT_TYPE_INVALID - DATA is the raw script * SCRIPT_TYPE_UNKNOWN - DATA is the decoded script * SCRIPT_TYPE_PUBKEY - DATA is the binary public key * SCRIPT_TYPE_ADDRESS - DATA is the binary public key hash * SCRIPT_TYPE_BURN - DATA is None * SCRIPT_TYPE_MULTISIG - DATA is {"m":M, "pubkeys":list_of_pubkeys} * SCRIPT_TYPE_P2SH - DATA is the binary script hash """ if script is None: raise ValueError() try: decoded = [ x for x in deserialize.script_GetOp(script) ] except Exception: return SCRIPT_TYPE_INVALID, script return chain.parse_decoded_txout_script(decoded)
def parse_txout_script(chain, script): """ Return TYPE, DATA where the format of DATA depends on TYPE. * SCRIPT_TYPE_INVALID - DATA is the raw script * SCRIPT_TYPE_UNKNOWN - DATA is the decoded script * SCRIPT_TYPE_PUBKEY - DATA is the binary public key * SCRIPT_TYPE_ADDRESS - DATA is the binary public key hash * SCRIPT_TYPE_BURN - DATA is None * SCRIPT_TYPE_MULTISIG - DATA is {"m":M, "pubkeys":list_of_pubkeys} * SCRIPT_TYPE_P2SH - DATA is the binary script hash """ if script is None: raise ValueError() try: decoded = [x for x in deserialize.script_GetOp(script)] except Exception: return SCRIPT_TYPE_INVALID, script return chain.parse_decoded_txout_script(decoded)
def get_multichain_op_drop_data(script): """ Get OP DROP data. :param script: script byte data :return: """ try: decoded = [x for x in deserialize.script_GetOp(script)] except Exception: return None data = None if deserialize.match_decoded(decoded, Chain.SCRIPT_MULTICHAIN_TEMPLATE): data = decoded[5][1] elif deserialize.match_decoded(decoded, Chain.SCRIPT_MULTICHAIN_P2SH_TEMPLATE): data = decoded[3][1] # 4th element contains the OP_DROP data. elif deserialize.match_decoded(decoded, Chain.SCRIPT_MULTICHAIN_STREAM_ITEM_TEMPLATE): data = decoded[0][1] # 1st element contains the creation txid OP_DROP data elif deserialize.match_decoded(decoded, Chain.SCRIPT_MULTICHAIN_STREAM_TEMPLATE): data = decoded[0][1] # 1st element contains the OP_DROP data. elif deserialize.match_decoded(decoded, Chain.SCRIPT_MULTICHAIN_SPKN_TEMPLATE): data = decoded[0][1] # 1st element contains the OP_DROP data. elif deserialize.match_decoded(decoded, Chain.SCRIPT_MULTICHAIN_FOLLOW_ON_ISSUANCE_METADATA_TEMPLATE): data = decoded[0][1] # 1st element contains the OP_DROP data. return data
store = Abe.DataStore.new(args) script = "530c333438343139353934393239027b7d6d7576a90fee462a84eac99150b023fb941a266b88ac".decode( "hex") # i = 0 # opcode = 0 # while i < len(script): # vch = None # prevCode = opcode # opcode = ord(script[i]) # i += 1 # if opcode == 0x14 and prevCode == 0xa9: # break # h160 = script[i:i+20] # version='\x34' # vh160 = version+h160 # h3=SHA256.new(SHA256.new(vh160).digest()).digest() # addr=vh160+h3[0:4] # print b58encode(addr) # print binascii.hexlify(bytearray(h160)) decoded = [x for x in deserialize.script_GetOp(script)] namechain = store.chains_by.id[3] print namechain.parse_decoded_txout_script(decoded) # print decoded
else: store = Abe.DataStore.new(args) script = "530c333438343139353934393239027b7d6d7576a90fee462a84eac99150b023fb941a266b88ac".decode("hex") # i = 0 # opcode = 0 # while i < len(script): # vch = None # prevCode = opcode # opcode = ord(script[i]) # i += 1 # if opcode == 0x14 and prevCode == 0xa9: # break # h160 = script[i:i+20] # version='\x34' # vh160 = version+h160 # h3=SHA256.new(SHA256.new(vh160).digest()).digest() # addr=vh160+h3[0:4] # print b58encode(addr) # print binascii.hexlify(bytearray(h160)) decoded = [ x for x in deserialize.script_GetOp(script) ] namechain = store.chains_by.id[3] print namechain.parse_decoded_txout_script(decoded) # print decoded