X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=lib%2Fpaymentrequest.py;h=6e97e21c23b38a55315f3e91402c9a4e9c79849c;hb=020702968230606c60564a4ec03fd2c53d65675f;hp=9d4138a5ea104e2b0dcb48539cbbcc1e17431ec5;hpb=f9985ae233d035d6b41aa18e882688af4b670ae0;p=electrum-nvc.git diff --git a/lib/paymentrequest.py b/lib/paymentrequest.py index 9d4138a..6e97e21 100644 --- a/lib/paymentrequest.py +++ b/lib/paymentrequest.py @@ -189,13 +189,19 @@ class PaymentRequest: prev_x = x509_chain[i-1] algo, sig, data = prev_x.extract_sig() - if algo.getComponentByName('algorithm') != x509.ALGO_RSA_SHA1: - self.error = "Algorithm not suported" - return - sig = bytearray(sig[5:]) pubkey = x.publicKey - verify = pubkey.hashAndVerify(sig, data) + if algo.getComponentByName('algorithm') == x509.ALGO_RSA_SHA1: + verify = pubkey.hashAndVerify(sig, data) + elif algo.getComponentByName('algorithm') == x509.ALGO_RSA_SHA256: + hashBytes = bytearray(hashlib.sha256(data).digest()) + prefixBytes = bytearray([0x30,0x31,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,0x04,0x20]) + verify = pubkey.verify(sig, prefixBytes + hashBytes) + else: + self.error = "Algorithm not supported" + util.print_error(self.error, algo.getComponentByName('algorithm')) + return + if not verify: self.error = "Certificate not Signed by Provided CA Certificate Chain" return @@ -243,7 +249,7 @@ class PaymentRequest: for o in pay_det.outputs: addr = transaction.get_address_from_output_script(o.script)[1] - self.outputs.append( (addr, o.amount) ) + self.outputs.append( ('address', addr, o.amount) ) self.memo = self.details.memo @@ -263,7 +269,7 @@ class PaymentRequest: return self.details.expires def get_amount(self): - return sum(map(lambda x:x[1], self.outputs)) + return sum(map(lambda x:x[2], self.outputs)) def get_domain(self): return self.domain @@ -288,7 +294,7 @@ class PaymentRequest: paymnt.transactions.append(raw_tx) ref_out = paymnt.refund_to.add() - ref_out.script = transaction.Transaction.pay_script(refund_addr) + ref_out.script = transaction.Transaction.pay_script('address', refund_addr) paymnt.memo = "Paid using Electrum" pm = paymnt.SerializeToString()