Пример #1
0
def example_verify(bank_client, receipt_bytes, signature_bytes, dst, amount,
                   memo):
    if not bank_client.verify(receipt_bytes, signature_bytes):
        raise Exception("Bad receipt. Not correctly signed by bank")
    ledger_line = LedgerLineStorage.deserialize(receipt_bytes)
    if ledger_line.getTransactionAmount(dst) != amount:
        raise Exception("Invalid amount. Expected {} got {}".format(
            amount, ledger_line.getTransactionAmount(dst)))
    elif ledger_line.memo(dst) != memo:
        raise Exception("Invalid memo. Expected {} got {}".format(
            memo, ledger_line.memo()))
    return True
Пример #2
0
 def _verifyReceipt(self, receipt, expected_token):
     ledger_line = LedgerLineStorage.deserialize(receipt)
     memo = ledger_line.memo(self._account)
     if str(memo) != str(expected_token):
         return "Mismatching token in memo (expected {} got {})".format(
             expected_token,
             memo)
     amount = ledger_line.getTransactionAmount(self._account)
     if amount != self._price:
         return "Mismatching amount (expected {} got {})".format(
             self._price,
             amount)
     return "Verified"
Пример #3
0
    def receipt_verify(self,receipt_bytes, signature_bytes, dst, amount, memo):
        self.bank_client = BankClientProtocol(self.bank_cert,self.bank_username,"testpass")
        # self.setBankClient()
        if not self.bank_client.verify(receipt_bytes, signature_bytes):
            # TODO: this func is not working as execpted
            printError("Bad receipt. Not correctly signed by bank")
            return False

        ledger_line = LedgerLineStorage.deserialize(receipt_bytes)
        if ledger_line.getTransactionAmount(dst) != amount:
            printError("Invalid amount. Expected {} got {}".format(amount, ledger_line.getTransactionAmount(dst)))
            return False
        elif ledger_line.memo(dst) != memo:
            printError("Invalid memo. Expected {} got {}".format(memo, ledger_line.memo()))
            return False
        printx('confirmed a receipt')
        return True