electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

bip70.py (1041B)


      1 #!/usr/bin/env python3
      2 # create a BIP70 payment request signed with a certificate
      3 # FIXME: the code here is outdated, and no longer working
      4 
      5 import tlslite
      6 
      7 from electrum.transaction import Transaction
      8 from electrum import paymentrequest
      9 from electrum import paymentrequest_pb2 as pb2
     10 from electrum.bitcoin import address_to_script
     11 
     12 chain_file = 'mychain.pem'
     13 cert_file = 'mycert.pem'
     14 amount = 1000000
     15 address = "18U5kpCAU4s8weFF8Ps5n8HAfpdUjDVF64"
     16 memo = "blah"
     17 out_file = "payreq"
     18 
     19 
     20 with open(chain_file, 'r') as f:
     21     chain = tlslite.X509CertChain()
     22     chain.parsePemList(f.read())
     23 
     24 certificates = pb2.X509Certificates()
     25 certificates.certificate.extend(map(lambda x: str(x.bytes), chain.x509List))
     26 
     27 with open(cert_file, 'r') as f:
     28     rsakey = tlslite.utils.python_rsakey.Python_RSAKey.parsePEM(f.read())
     29 
     30 script = address_to_script(address)
     31 
     32 pr_string = paymentrequest.make_payment_request(amount, script, memo, rsakey)
     33 
     34 with open(out_file,'wb') as f:
     35     f.write(pr_string)
     36 
     37 print("Payment request was written to file '%s'"%out_file)