URI: 
       tmove create_csr to gui - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit e4038dcdba038b46f242362c840cac5f8c66190f
   DIR parent 6527eae32b6a5961554dca9946b0eb353c3eb28f
  HTML Author: ThomasV <thomasv@gitorious>
       Date:   Sat,  2 May 2015 16:26:27 +0200
       
       move create_csr to gui
       
       Diffstat:
         M gui/qt/main_window.py               |      13 +++++++++++++
         M lib/x509.py                         |      12 ++----------
       
       2 files changed, 15 insertions(+), 10 deletions(-)
       ---
   DIR diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
       t@@ -2742,3 +2742,16 @@ class ElectrumWindow(QMainWindow):
                text.setText(mpk_text)
                vbox.addLayout(Buttons(CloseButton(d)))
                d.exec_()
       +
       +    @protected
       +    def create_csr(self, alias, challenge, password):
       +        from electrum import x509
       +        import tlslite
       +        xprv = self.wallet.get_master_private_key(self.wallet.root_name, password)
       +        _, _, _, c, k = bitcoin.deserialize_xkey(xprv)
       +        csr = x509.create_csr(alias, challenge, k)
       +        csr = tlslite.utils.pem.pem(bytearray(csr), "CERTIFICATE REQUEST")
       +        with open('test.csr', 'w') as f:
       +            f.write(csr)
       +        #os.system('openssl asn1parse -i -in test.csr')
       +        return 'test.csr'
   DIR diff --git a/lib/x509.py b/lib/x509.py
       t@@ -237,11 +237,10 @@ def int_to_bytestr(i):
                s = chr(i % 256) + s
            return s
        
       -def create_csr(commonName, challenge, secexp):
       -
       +def create_csr(commonName, challenge, k):
            import ecdsa, hashlib
            from bitcoin import point_to_ser
       -    private_key = ecdsa.SigningKey.from_secret_exponent(secexp, curve = ecdsa.SECP256k1)
       +    private_key = ecdsa.SigningKey.from_string(k, curve = ecdsa.SECP256k1)
            public_key = private_key.get_verifying_key()
            pubkey = point_to_ser(public_key.pubkey.point, False)
            asn1_type_table = {
       t@@ -295,10 +294,3 @@ def create_csr(commonName, challenge, secexp):
        
        
        
       -if __name__ == "__main__":
       -    import os
       -    csr = create_csr('test@electrum.org', 'blah', 123456)
       -    with open('test.csr', 'w') as f:
       -        o = tlslite.utils.pem.pem(bytearray(csr), "CERTIFICATE REQUEST")
       -        f.write(o)
       -    os.system('openssl asn1parse -i -in test.csr')