Browse Source

import lib directory as electrum if the library is not installed

283
thomasv 13 years ago
parent
commit
735f9b9c20
  1. 7
      electrum
  2. 5
      lib/gui.py
  3. 6
      lib/gui_qt.py

7
electrum

@ -30,11 +30,14 @@ except:
print "AES does not seem to be installed. Try 'sudo pip install slowaes'" print "AES does not seem to be installed. Try 'sudo pip install slowaes'"
sys.exit(1) sys.exit(1)
try:
import electrum
except:
print "Electrum library not found. Importing lib as electrum"
import lib as electrum
import electrum
from optparse import OptionParser from optparse import OptionParser
from decimal import Decimal from decimal import Decimal
from electrum import Wallet, WalletSynchronizer, format_satoshis from electrum import Wallet, WalletSynchronizer, format_satoshis
known_commands = ['help', 'validateaddress', 'balance', 'contacts', 'create', 'restore', 'payto', 'sendtx', 'password', 'addresses', 'history', 'label', 'mktx','seed','import','signmessage','verifymessage','eval','deseed','reseed'] known_commands = ['help', 'validateaddress', 'balance', 'contacts', 'create', 'restore', 'payto', 'sendtx', 'password', 'addresses', 'history', 'label', 'mktx','seed','import','signmessage','verifymessage','eval','deseed','reseed']

5
lib/gui.py

@ -22,9 +22,10 @@ import socket, traceback
import pygtk import pygtk
pygtk.require('2.0') pygtk.require('2.0')
import gtk, gobject import gtk, gobject
from electrum import pyqrnative
from decimal import Decimal from decimal import Decimal
import pyqrnative, mnemonic
gtk.gdk.threads_init() gtk.gdk.threads_init()
APP_NAME = "Electrum" APP_NAME = "Electrum"
import platform import platform
@ -59,7 +60,6 @@ def numbify(entry, is_int = False):
def show_seed_dialog(wallet, password, parent): def show_seed_dialog(wallet, password, parent):
from electrum import mnemonic
if not wallet.seed: if not wallet.seed:
show_message("No seed") show_message("No seed")
return return
@ -206,7 +206,6 @@ def run_recovery_dialog(wallet):
try: try:
seed.decode('hex') seed.decode('hex')
except: except:
from electrum import mnemonic
print "not hex, trying decode" print "not hex, trying decode"
seed = mnemonic.mn_decode( seed.split(' ') ) seed = mnemonic.mn_decode( seed.split(' ') )
if not seed: if not seed:

6
lib/gui_qt.py

@ -40,6 +40,8 @@ except:
sys.exit(1) sys.exit(1)
from wallet import format_satoshis from wallet import format_satoshis
import bmp, mnemonic, pyqrnative
from decimal import Decimal from decimal import Decimal
import platform import platform
@ -107,7 +109,6 @@ class QRCodeWidget(QWidget):
self.set_addr(addr) self.set_addr(addr)
def set_addr(self, addr): def set_addr(self, addr):
from electrum import pyqrnative
self.addr = addr self.addr = addr
self.qr = pyqrnative.QRCode(4, pyqrnative.QRErrorCorrectLevel.L) self.qr = pyqrnative.QRCode(4, pyqrnative.QRErrorCorrectLevel.L)
self.qr.addData(addr) self.qr.addData(addr)
@ -720,7 +721,6 @@ class ElectrumWindow(QMainWindow):
@staticmethod @staticmethod
def show_seed_dialog(wallet, parent=None): def show_seed_dialog(wallet, parent=None):
from electrum import mnemonic
if not wallet.seed: if not wallet.seed:
QMessageBox.information(parent, _('Message'), _('No seed'), _('OK')) QMessageBox.information(parent, _('Message'), _('No seed'), _('OK'))
@ -833,7 +833,6 @@ class ElectrumWindow(QMainWindow):
qrw.repaint() qrw.repaint()
def do_save(): def do_save():
from electrum import bmp
bmp.save_qrcode(qrw.qr, "qrcode.bmp") bmp.save_qrcode(qrw.qr, "qrcode.bmp")
self.show_message(_("QR code saved to file") + " 'qrcode.bmp'") self.show_message(_("QR code saved to file") + " 'qrcode.bmp'")
@ -978,7 +977,6 @@ class ElectrumWindow(QMainWindow):
seed = unicode(seed_e.text()) seed = unicode(seed_e.text())
seed.decode('hex') seed.decode('hex')
except: except:
from electrum import mnemonic
print "not hex, trying decode" print "not hex, trying decode"
try: try:
seed = mnemonic.mn_decode( seed.split(' ') ) seed = mnemonic.mn_decode( seed.split(' ') )

Loading…
Cancel
Save