def executeScript(self, binaryScript, stack=[]): self.stack = stack self.stackAlt = [] scriptData = BinaryUnpacker(binaryScript) self.lastOpCodeSepPos = None while scriptData.getRemainingSize() > 0: opcode = scriptData.get(UINT8) exitCode = self.executeOpCode(opcode, scriptData, self.stack, self.stackAlt) if not exitCode == SCRIPT_NO_ERROR: if exitCode == OP_NOT_IMPLEMENTED: LOGERROR( '***ERROR: OpCodes OP_IF, OP_NOTIF, OP_ELSE, OP_ENDIF,' ) LOGERROR( ' have not been implemented, yet. This script' ) LOGERROR(' could not be evaluated.') if exitCode == OP_DISABLED: LOGERROR( '***ERROR: This script included an op code that has been' ) LOGERROR( ' disabled for security reasons. Script eval' ) LOGERROR(' failed.') return exitCode return SCRIPT_NO_ERROR
def unserialize(self, toUnpack): bu = BinaryUnpacker(toUnpack) self.messageType = bu.get(VAR_STR) self.rejectCode = bu.get(INT8) self.message = bu.get(VAR_STR) self.data = bu.get(BINARY_CHUNK, bu.getRemainingSize()) self.serializedData = toUnpack return self
def executeScript(self, binaryScript, stack=[]): self.stack = stack self.stackAlt = [] scriptData = BinaryUnpacker(binaryScript) self.lastOpCodeSepPos = None while scriptData.getRemainingSize() > 0: opcode = scriptData.get(UINT8) exitCode = self.executeOpCode(opcode, scriptData, self.stack, self.stackAlt) if not exitCode == SCRIPT_NO_ERROR: if exitCode==OP_NOT_IMPLEMENTED: LOGERROR('***ERROR: OpCodes OP_IF, OP_NOTIF, OP_ELSE, OP_ENDIF,') LOGERROR(' have not been implemented, yet. This script') LOGERROR(' could not be evaluated.') if exitCode==OP_DISABLED: LOGERROR('***ERROR: This script included an op code that has been') LOGERROR(' disabled for security reasons. Script eval') LOGERROR(' failed.') return exitCode return SCRIPT_NO_ERROR