Pages:
Author

Topic: [ANNOUNCE] Electrum - Lightweight Bitcoin Client - page 53. (Read 274534 times)

legendary
Activity: 1896
Merit: 1353
Here's a patch for .60 with all the getpass calls "fixed".

I was able to test (with success) all patch conditions with the exception of mktx and payto.

why don't you define a unique getpass function, instead of repeating things six times?
hero member
Activity: 784
Merit: 1010
Bitcoin Mayor of Las Vegas
Here's a patch for .60 with all the getpass calls "fixed".

I was able to test (with success) all patch conditions with the exception of mktx and payto.

Code:
$ diff -u /tmp/electrum-60 /usr/bin/electrum
--- /tmp/electrum-60 2012-06-23 04:17:48.760346152 -0700
+++ /usr/bin/electrum 2012-06-23 05:21:51.516348218 -0700
@@ -170,15 +170,29 @@
     
     if cmd in ['create', 'restore']:
         if wallet.file_exists:
-            print "remove the existing wallet first!"
-            sys.exit(0)
-        password = getpass.getpass("Password (hit return if you do not wish to encrypt your wallet):")
-        if password:
-            password2 = getpass.getpass("Confirm password:")
-            if password != password2:
-                print "error"
-                sys.exit(1)
+            print "Error: Wallet file exists. Remove the existing wallet first."
+            sys.exit(1)
+
+        # Get password once if stdin, confirmed if by atty
+        passStr = "Password (hit return if you do not wish to encrypt your wallet):"
+        if sys.stdin.isatty():
+            password = getpass.getpass(passStr)
+
+            if password:
+                passStr = "Confirm password:"
+                if sys.stdin.isatty():
+                    password2 = getpass.getpass(passStr)
+                else:
+                    password2 = raw_input(passStr)
+
+                if password != password2:
+                    print "Error: Passwords do not match."
+                    sys.exit(1)
+
         else:
+            password = raw_input(passStr)
+
+        if not password:
             password = None
 
         w_host, w_port, w_protocol = wallet.server.split(':')
@@ -263,12 +277,21 @@
                 
     # commands needing password
     if cmd in protected_commands or ( cmd=='addresses' and options.show_keys):
-        password = getpass.getpass('Password:') if wallet.use_encryption and not is_temporary else None
+        if wallet.use_encryption and not is_temporary:
+            passStr = "Password:"
+            if sys.stdin.isatty():
+                password = getpass.getpass(passStr)
+            else:
+                password = raw_input(passStr)
+        else:
+            password = None
+        #if wallet.use_encryption and not is_temporary else None
+
         # check password
         try:
             wallet.pw_decode( wallet.seed, password)
         except:
-            print "invalid password"
+            print "Error: Invalid password"
             exit(1)
 
     if cmd == 'import':
@@ -429,7 +452,13 @@
     elif cmd in ['payto', 'mktx']:
         if from_addr and is_temporary:
             if from_addr.find(":") == -1:
-                keypair = from_addr + ":" + getpass.getpass('Private key:')
+                passStr = "Private key:"
+                if sys.stdin.isatty():
+                    tmpKey = getpass.getpass(passStr)
+                else:
+                    tmpKey = raw_input(passStr)
+                keypair = from_addr + ":" + tmpKey
+                del tmpKey
             else:
                 keypair = from_addr
                 from_addr = keypair.split(':')[0]
@@ -478,13 +507,20 @@
         try:
             seed = wallet.pw_decode( wallet.seed, password)
         except:
-            print "sorry"
+            print "Error: Password failed to decode wallet."
             sys.exit(1)
-        new_password = getpass.getpass('New password:')
-        if new_password == getpass.getpass('Confirm new password:'):
-            wallet.update_password(seed, password, new_password)
+
+        passStr = "New password:"
+        if sys.stdin.isatty():
+            new_password = getpass.getpass(passStr)
+            new_password2 = getpass.getpass("Confirm new password:")
+            if not new_password == new_password2:
+                print "Error: Passwords do not match."
+                sys.exit(1)
         else:
-            print "error: mismatch"
+            new_password = raw_input(passStr)
+
+        wallet.update_password(seed, password, new_password)
 
     elif cmd == 'signmessage':
         address = args[1]
hero member
Activity: 784
Merit: 1010
Bitcoin Mayor of Las Vegas
thanks. there are 6 instances of getpass in the file.
is there a reason why you want to patch only 2 of them?

#1 I barely knew what the hell I was doing.

#2 That was the only place I could find that "bothered me" at the moment.

#3 I will search for the other 5 and patch those too.

#4 Father, I am sorry I dissapoint. lol

edit: #5 I can't count. 4 other patches coming.
legendary
Activity: 1896
Merit: 1353
new release: 0.60

changes:
 - updated list of default servers
 - the client will not display servers that have not upgraded to version 0.1.
 - two new languages: chinese and dutch
 - improved help messages (tachik0ma)
legendary
Activity: 1896
Merit: 1353
Submitting a patch to allow batch create and restore functions. The getpass function breaks input from stdin so I inserted a check for tty.

thanks. there are 6 instances of getpass in the file.
is there a reason why you want to patch only 2 of them?
legendary
Activity: 1896
Merit: 1353
ThomasV,
    I've just updated Electrum/Translation wiki, add cn , mind merge that ?
          finway

that's very nice, thanks!
note that I still have to update that page; some new messages are missing.
legendary
Activity: 3920
Merit: 2349
Eadem mutata resurgo
I did not (but might).. I've just been using the install commandline from the linux download option at ecdsa.org.

Yeah, it's a little generous to call it a "linux" download .... Debian-Ubuntu is known to work, I don't know what else it has been tested on ...


Edit: all right I tested the
Code:
sudo pip-python install http://ecdsa.org/electrum/Electrum-0.59b.tar.gz#md5=4254bad432f44d61904b93917860069b

on FC15 and it works. Note however though I already had the "slowaes" and "ecdsa" packages installed from previous deps on electrum work. I also tested downloading the .tar.gz manually, unpacking and running
Code:
sudo python setup.py install
inside the unpacked dir and that works also, but again with previous caveat about existing deps.

So known to work on FC will be something like this:

Code:
#
# use yum-ex and get packages PyQt4 PyQt4-devel
# or on command line

$ sudo yum install PyQt4 PyQt4-devel

# separately do same for packages python-setuptools python-pip

$ sudo yum install python-setuptools python-pip

# Install python modules ecdsa slowaes (crypto stuff)

$ sudo easy_install ecdsa
$ sudo easy_install slowaes

$ sudo pip-python install http://ecdsa.org/electrum/Electrum-0.59b.tar.gz#md5=4254bad432f44d61904b93917860069b

Note how the dep. packages need to be installed first, rather relying on electrum to install them. Anyway it is not good practice to "sudo" a whole lot of unknown packages onto your OS !!
hero member
Activity: 784
Merit: 1010
Bitcoin Mayor of Las Vegas
I did not (but might).. I've just been using the install commandline from the linux download option at ecdsa.org.
legendary
Activity: 3920
Merit: 2349
Eadem mutata resurgo
Can I get some love? FC16

Code:
2012-06-18:1919 PDT
[tux@powerball ~]$ sudo pip-python install http://ecdsa.org/electrum/Electrum-0.59b.tar.gz#md5=4254bad432f44d61904b93917860069b
Downloading/unpacking http://ecdsa.org/electrum/Electrum-0.59b.tar.gz#md5=4254bad432f44d61904b93917860069b
  Downloading Electrum-0.59b.tar.gz (214Kb): 214Kb downloaded
  Running setup.py egg_info for package from http://ecdsa.org/electrum/Electrum-0.59b.tar.gz#md5=4254bad432f44d61904b93917860069b
    
Downloading/unpacking slowaes (from Electrum==0.59b)
  Downloading slowaes-0.1a1.tar.gz
  Running setup.py egg_info for package slowaes
    
Downloading/unpacking ecdsa (from Electrum==0.59b)
  Downloading ecdsa-0.7.tar.gz
  Running setup.py egg_info for package ecdsa
    
Installing collected packages: slowaes, ecdsa, Electrum
  Running setup.py install for slowaes
    
  Running setup.py install for ecdsa
    
  Running setup.py install for Electrum
    changing mode of build/scripts-2.7/electrum from 640 to 755
    
    changing mode of /usr/bin/electrum to 755
Successfully installed slowaes ecdsa Electrum
Cleaning up...

2012-06-18:1920 PDT
[tux@powerball ~]$ electrum
python-ecdsa does not seem to be installed. Try 'sudo pip install ecdsa'

2012-06-18:1920 PDT
[tux@powerball ~]$

Additionally....

Code:
$ pip-python search ecdsa
ecdsa                     - ECDSA cryptographic signature library (pure python)
  INSTALLED: 0.7 (latest)

Tuxuvant : did you follow my Install instructions for Fedora posted earlier in the thread https://bitcointalksearch.org/topic/m.948023

Would somebody mind posting them on the wiki or with the source or something for Fedora and other RH derivative users?
hero member
Activity: 784
Merit: 1010
Bitcoin Mayor of Las Vegas
Submitting a patch to allow batch create and restore functions. The getpass function breaks input from stdin so I inserted a check for tty.


Code:
diff -u  /tmp/electrum /usr/bin/electrum
--- /tmp/electrum 2012-06-19 10:06:29.842304577 -0700
+++ /usr/bin/electrum 2012-06-19 10:16:58.050869673 -0700
@@ -173,9 +173,19 @@
         if wallet.file_exists:
             print "remove the existing wallet first!"
             sys.exit(0)
-        password = getpass.getpass("Password (hit return if you do not wish to encrypt your wallet):")
+
+        passStr = "Password (hit return if you do not wish to encrypt your wallet):"
+        if sys.stdin.isatty():
+          password = getpass.getpass(passStr)
+        else:
+          password = raw_input(passStr)
+        
         if password:
-            password2 = getpass.getpass("Confirm password:")
+            passStr = "Confirm password:"
+            if sys.stdin.isatty():
+              password2 = getpass.getpass(passStr)
+            else:
+              password2 = raw_input(passStr)
             if password != password2:
                 print "error"
                 sys.exit(1)
hero member
Activity: 714
Merit: 500
ThomasV,
    I've just updated Electrum/Translation wiki, add cn , mind merge that ?
          finway
legendary
Activity: 1092
Merit: 1016
760930
404 not found on that gui_qt.py link.

Sorry, you can try again now. Let me know if it works for you.
full member
Activity: 237
Merit: 100
Thanks, finally got it to work.

Is there a program that converts between different formats?  Or at least a set of algorithms?

I like brainwallet.org -- you can run it off the site to see what it can do, or run it offline by downloading the zip.

bitaddress.org can also do some tricks with its Wallet Details tab. Like brainwallet.org, you can download the HTML and run it offline to be secure.
sr. member
Activity: 354
Merit: 250
Thanks, finally got it to work.

Is there a program that converts between different formats?  Or at least a set of algorithms?
full member
Activity: 237
Merit: 100
What key format does electrum use?  I just tried to import my wallet from blockchain.info using every format they provided, and none of them worked.  I keep getting an "unsupported key format message".  Furthermore, why do I have to provide both the address and private key?  Shouldn't the client be able to compute the address from the private key?

Uncompressed, WIF (starts with 5), the command is:

electrum import address:privkey

Where address and privkey are your actual pair.
sr. member
Activity: 354
Merit: 250
What key format does electrum use?  I just tried to import my wallet from blockchain.info using every format they provided, and none of them worked.  I keep getting an "unsupported key format message".  Furthermore, why do I have to provide both the address and private key?  Shouldn't the client be able to compute the address from the private key?
hero member
Activity: 784
Merit: 1010
Bitcoin Mayor of Las Vegas
Can I get some love? FC16

Code:
2012-06-18:1919 PDT
[tux@powerball ~]$ sudo pip-python install http://ecdsa.org/electrum/Electrum-0.59b.tar.gz#md5=4254bad432f44d61904b93917860069b
Downloading/unpacking http://ecdsa.org/electrum/Electrum-0.59b.tar.gz#md5=4254bad432f44d61904b93917860069b
  Downloading Electrum-0.59b.tar.gz (214Kb): 214Kb downloaded
  Running setup.py egg_info for package from http://ecdsa.org/electrum/Electrum-0.59b.tar.gz#md5=4254bad432f44d61904b93917860069b
    
Downloading/unpacking slowaes (from Electrum==0.59b)
  Downloading slowaes-0.1a1.tar.gz
  Running setup.py egg_info for package slowaes
    
Downloading/unpacking ecdsa (from Electrum==0.59b)
  Downloading ecdsa-0.7.tar.gz
  Running setup.py egg_info for package ecdsa
    
Installing collected packages: slowaes, ecdsa, Electrum
  Running setup.py install for slowaes
    
  Running setup.py install for ecdsa
    
  Running setup.py install for Electrum
    changing mode of build/scripts-2.7/electrum from 640 to 755
    
    changing mode of /usr/bin/electrum to 755
Successfully installed slowaes ecdsa Electrum
Cleaning up...

2012-06-18:1920 PDT
[tux@powerball ~]$ electrum
python-ecdsa does not seem to be installed. Try 'sudo pip install ecdsa'

2012-06-18:1920 PDT
[tux@powerball ~]$

Additionally....

Code:
$ pip-python search ecdsa
ecdsa                     - ECDSA cryptographic signature library (pure python)
  INSTALLED: 0.7 (latest)
full member
Activity: 237
Merit: 100
404 not found on that gui_qt.py link.
legendary
Activity: 1092
Merit: 1016
760930
Could you add an at-a-glance way to see the current block number -- perhaps in the lower right corner?

You mean, something like this? Smiley


I have made a little patch for it and am currently fine-tuning it.
The patch is ready. If some find it useful and want to test it out, just let me know and I will post it.
(It's NOT included in my releases at this time.)

EDIT: Added a little hyperlink to the BlockExplorer count, for a quick comparison.

PS: bear with me, I'm still a beginner with Python and Qt Smiley

Could you give me a patch or a diff, want to try to patch my OS X version Smiley


Sure! To try it out, just back up your copy of gui_qt.py and replace it with this one:
 http://dre.tx0.org/gui_qt.py  (file size should be 53791 bytes)

Hopefully it should be OK on a Mac too, let us know Smiley

Thanks, seems to work fine, I hope this gets added to master.



It's not as pretty as on Windows but it will have to do Smiley

Thanks for the feedback!
If ThomasV decides to merge it, it's just 4 lines of code.
hero member
Activity: 938
Merit: 1000
Could you add an at-a-glance way to see the current block number -- perhaps in the lower right corner?

You mean, something like this? Smiley


I have made a little patch for it and am currently fine-tuning it.
The patch is ready. If some find it useful and want to test it out, just let me know and I will post it.
(It's NOT included in my releases at this time.)

EDIT: Added a little hyperlink to the BlockExplorer count, for a quick comparison.

PS: bear with me, I'm still a beginner with Python and Qt Smiley

Could you give me a patch or a diff, want to try to patch my OS X version Smiley


Sure! To try it out, just back up your copy of gui_qt.py and replace it with this one:
 http://dre.tx0.org/gui_qt.py  (file size should be 53791 bytes)

Hopefully it should be OK on a Mac too, let us know Smiley

Thanks, seems to work fine, I hope this gets added to master.



It's not as pretty as on Windows but it will have to do Smiley
Pages:
Jump to: