def Verification(self, currentheight, aipdic): ##1 the protocol name should be the same if self.aipname.value != "aip1.aip1_0.Input": return False, "aip1.aip1_0.Input, item 1, False" if not aiptool.IsAipLegalForCurrentHeight(self.aipname.value, currentheight, aipdic): return False, "aip1.aip1_0.Input, item 1.1, False" return True, "aip1.aip1_0.Input, True"
def Verification(self, currentheight, aipdic): if self.aipname.value != "aip1.aip1_0.Output": return False, "aip1.aip1_0.Output, item 1, False" if not aiptool.IsAipLegalForCurrentHeight(self.aipname.value, currentheight, aipdic): return False, "aip1.aip1_0.Output, item 1.1, False" ##verify aoc address if not aiptool.GetObj("aip0.aip0_0.Wallet").VerifyAddress( self.aocaddress.value): return False, "aip1.aip1_0.Output, item 2, False" return True, "aip1.aip1_0.Output, True"
def Verification(self, currentheight, aipdic): if self.aipname.value != "aip2.aip2_0.Transaction_Gate": return False, "aip2.aip2_0.Transaction_Gate, item 1, False" if not aiptool.IsAipLegalForCurrentHeight(self.aipname.value, currentheight, aipdic): return False, "aip2.aip2_0.Transaction_Gate, item 1.1, False" for inputi in self.withdraw: if inputi.aipname.value != "aip1.aip1_0.Input": return False, "aip2.aip2_0.Transaction_Gate, item 2, False" if inputi.pubkey.value != self.ownerpubkey.value: return False, "aip2.aip2_0.Transaction_Gate, item 2.1, False" re, msg = inputi.Verification(currentheight, aipdic) if not re: return False, "aip1.aip1_0.Transaction_Pay, item 2.2, False" for outputi in self.deposit: if outputi.aipname.value != "aip1.aip1_0.Output": return False, "aip2.aip2_0.Transaction_Gate, item 3, False" re, msg = outputi.Verification(currentheight, aipdic) if not re: return False, "aip2.aip2_0.Transaction_Gate, item 3.1, False" if self.token.value.lower() == "aoc": return False, "aip2.aip2_0.Transaction_Gate, item 4, False" if self.agreement.value != "this service is offered by aocpay, the ownerpubkey is responsible for any real law issue caused by this record": return False, "aip2.aip2_0.Transaction_Gate, item 5, False" msg1, msg2 = self.GetMsgSig() wallet = aiptool.GetObj("aip0.aip0_0.Wallet") try: re = wallet.VerifyMsg(self.ownerpubkey.value, msg1, self.sig.value) except: re = False if not re: return False, "aip2.aip2_0.Transaction_Gate, item 6, False" for os in self.ownerships: if os.aipname.value != "aip0.aip0_0.Ownership": return False, "aip2.aip2_0.Transaction_Gate, item 7.1, False" if msg2 != os.msg.value: return False, "aip2.aip2_0.Transaction_Gate, item 7.2, False" re, msg = os.Verification(currentheight, aipdic) if not re: return False, "aip2.aip2_0.Transaction_Gate, item 7.3, False " + msg return True, "aip2.aip2_0.Transaction_Gate, True"
def Verification(self, currentheight, aipdic): ##1 the protocol name should be the same if self.aipname.value != "aip0.aip0_0.Block": return False, "aip0.aip0_0.Block, item 1, False" ##1.1 the protocol valid range if not aiptool.IsAipLegalForCurrentHeight(self.aipname.value, currentheight, aipdic): return False, "aip0.aip0_0.Block, item 1.1, False" ##2 protocol type if self.blocktype.value not in (0, 1, 2): return False, "aip0.aip0_0.Block, item 2, False" ##3 check payloads for payload in self.payloads: if self.blocktype.value in (0, 1): if payload.aipname.value != "aip0.aip0_0.Law": return False, "aip0.aip0_0.Block, item 3.1.1, False" if self.blocktype.value == 1 and payload.LawType.value == 0: return False, "aip0.aip0_0.Block, item 3.1.2, False" if payload.expiretime.value <= self.timestamp.value: return False, "aip0.aip0_0.Block, item 3.2, False" re, msg = payload.Verification(currentheight, aipdic) if not re: return False, "aip0.aip0_0.Block, item 3.3, False " + msg ##4 check ownership osmsg = self._osmsg if hasattr(self, '_osmsg') else VariBytes().parse( self.MerkleRoot(ObjList2BytesList( self.payloads.value))).serialize() if len(self.ownerships) == 0: return False, "aip0.aip0_0.Block, item 4.0, False" for os in self.ownerships: if os.aipname.value != "aip0.aip0_0.Ownership": return False, "aip0.aip0_0.Block, item 4.1, False" if osmsg != os.msg.value: return False, "aip0.aip0_0.Block, item 4.2, False" re, msg = os.Verification(currentheight, aipdic) if not re: return False, "aip0.aip0_0.Block, item 4.3, False " + msg return True, "aip0.aip0_0.Block, True"
def Verification(self, currentheight, aipdic): ##1 the protocol name should be the same if self.aipname.value != "aip0.aip0_0.Ownership": return False, "aip0.aip0_0.Ownership, item 1, False" if not aiptool.IsAipLegalForCurrentHeight(self.aipname.value, currentheight, aipdic): return False, "aip0.aip0_0.Ownership, item 1.1, False" #2 the msg should be verified wallet = aiptool.GetObj("aip0.aip0_0.Wallet") try: re = wallet.VerifyMsg(self.pubkey.value, self.msg.value, self.sig.value) except: re = False if not re: return False, "aip0.aip0_0.Ownership, item 2, False" return True, "aip0.aip0_0.Ownership, True"
def Verification(self, currentheight, aipdic): ##1. the protocol name should be the same if self.aipname.value != "aip0.aip0_0.Law": return False, "aip0.aip0_0.Law, item 1, False" if not aiptool.IsAipLegalForCurrentHeight(self.aipname.value, currentheight, aipdic): return False, "aip0.aip0_0.Law, item 1.1, False" if self.LawName.value.rstrip() == "" or self.LawContent.value.rstrip( ) == "": return False, "aip0.aip0_0.Law, item 2, False" print(self.LawName.value) ##2. The law name should obey the rule if not aiptool.VerifyAipPathRule(self.LawName.value): return False, "aip0.aip0_0.Law, item 3, False" ##3. law type if self.LawType.value not in (0, 1): return False, "aip0.aip0_0.Law, item 4, False" return True, "aip0.aip0_0.Law, True"
def Verification(self, currentheight, aipdic): if self.aipname.value != "aip1.aip1_0.Transaction_Pay": return False, "aip1.aip1_0.Transaction_Pay, item 1, False" if not aiptool.IsAipLegalForCurrentHeight(self.aipname.value, currentheight, aipdic): return False, "aip1.aip1_0.Transaction_Pay, item 1.1, False" ##3 Length of inputs and sigs should equal, integration or normal transaction txid = self.GetTxType() if txid == 0: return False, "aip1.aip1_0.Transaction_Pay, item 2, False" ##4 for outputi in self.outputs: if outputi.aipname.value != "aip1.aip1_0.Output": return False, "aip1.aip1_0.Transaction_Pay, item 3, False" re, msg = outputi.Verification(currentheight, aipdic) if not re: return False, "aip1.aip1_0.Transaction_Pay, item 3.1, False" ##5 msgsig = self.GetMsgSig() wallet = aiptool.GetObj("aip0.aip0_0.Wallet") #"""if is normal transaction or integration transaction""" for idd, inputi in enumerate(self.inputs): if inputi.aipname.value != "aip1.aip1_0.Input": return False, "aip1.aip1_0.Transaction_Pay, item 4, False" re, msg = inputi.Verification(currentheight, aipdic) if not re: return False, "aip1.aip1_0.Transaction_Pay, item 4.1, False" if txid == 1: sig = self.sigs.value[idd].value elif txid == 2: sig = self.sigs.value[0].value try: rew = wallet.VerifyMsg(inputi.pubkey.value, msgsig, sig) except: rew = False if not rew: return False, "aip1.aip1_0.Transaction_Pay, item 4.2, False" return True, "aip1.aip1_0.Transaction_Pay, True"