def GetDelegatedStaker(rawtx, out_n, isTestnet): tx = ParseTx(rawtx) script = tx['vout'][out_n]["scriptPubKey"]["hex"] if not utils.IsPayToColdStaking(bytes.fromhex(script)): return "" pkh = utils.GetDelegatedStaker(bytes.fromhex(script)) return pubkeyhash_to_address(pkh, isTestnet, isCold=True)
def ParseTxOutput(p, isTestnet=False): vout = {} vout["value"] = p.readInt(8, "little") script_len = p.readInt(1, "little") vout["scriptPubKey"] = {} vout["scriptPubKey"]["hex"] = p.readString(script_len, "big") vout["scriptPubKey"]["addresses"] = [] try: add_bytes = extract_pkh_from_locking_script( bytes.fromhex(vout["scriptPubKey"]["hex"])) address = pubkeyhash_to_address(add_bytes, isTestnet) vout["scriptPubKey"]["addresses"].append(address) except Exception as e: print(e) return vout
def ParseTxOutput(p, isTestnet=False): vout = {} vout["value"] = p.readInt(8, "little") script_len = p.readInt(1, "little") vout["scriptPubKey"] = {} vout["scriptPubKey"]["hex"] = p.readString(script_len, "big") vout["scriptPubKey"]["addresses"] = [] try: locking_script = bytes.fromhex(vout["scriptPubKey"]["hex"]) if len(locking_script) > 0: add_bytes = utils.extract_pkh_from_locking_script(locking_script) address = pubkeyhash_to_address(add_bytes, isTestnet) vout["scriptPubKey"]["addresses"].append(address) except Exception as e: printException(getCallerName(True), getFunctionName(True), "error parsing output", str(e)) return vout