fix restore from mpk
This commit is contained in:
@@ -140,6 +140,46 @@ class InstallWizard(QDialog):
|
|||||||
return seed, gap
|
return seed, gap
|
||||||
|
|
||||||
|
|
||||||
|
def mpk_dialog(self):
|
||||||
|
d = QDialog()
|
||||||
|
d.setModal(1)
|
||||||
|
|
||||||
|
vbox = QVBoxLayout()
|
||||||
|
msg = _("Please enter your master public key.")
|
||||||
|
|
||||||
|
label=QLabel(msg)
|
||||||
|
label.setWordWrap(True)
|
||||||
|
vbox.addWidget(label)
|
||||||
|
|
||||||
|
mpk_e = QTextEdit()
|
||||||
|
mpk_e.setMaximumHeight(100)
|
||||||
|
vbox.addWidget(mpk_e)
|
||||||
|
|
||||||
|
grid = QGridLayout()
|
||||||
|
grid.setSpacing(8)
|
||||||
|
gap_e = AmountEdit(None, True)
|
||||||
|
gap_e.setText("5")
|
||||||
|
grid.addWidget(QLabel(_('Gap limit')), 2, 0)
|
||||||
|
grid.addWidget(gap_e, 2, 1)
|
||||||
|
grid.addWidget(HelpButton(_('Keep the default value unless you modified this parameter in your wallet.')), 2, 3)
|
||||||
|
vbox.addLayout(grid)
|
||||||
|
|
||||||
|
vbox.addLayout(ok_cancel_buttons(d, _('Next')))
|
||||||
|
d.setLayout(vbox)
|
||||||
|
|
||||||
|
if not d.exec_(): return
|
||||||
|
|
||||||
|
mpk = str(mpk_e.toPlainText())
|
||||||
|
|
||||||
|
try:
|
||||||
|
gap = int(unicode(gap_e.text()))
|
||||||
|
except:
|
||||||
|
QMessageBox.warning(None, _('Error'), 'error', 'OK')
|
||||||
|
return
|
||||||
|
|
||||||
|
return mpk, gap
|
||||||
|
|
||||||
|
|
||||||
def network_dialog(self):
|
def network_dialog(self):
|
||||||
|
|
||||||
d = QDialog()
|
d = QDialog()
|
||||||
@@ -266,15 +306,23 @@ class InstallWizard(QDialog):
|
|||||||
|
|
||||||
elif action == 'watching':
|
elif action == 'watching':
|
||||||
# ask for seed and gap.
|
# ask for seed and gap.
|
||||||
sg = self.seed_dialog()
|
sg = self.mpk_dialog()
|
||||||
if not sg:
|
if not sg:
|
||||||
return
|
return
|
||||||
seed, gap = sg
|
mpk, gap = sg
|
||||||
if not seed:
|
if not mpk:
|
||||||
return
|
return
|
||||||
wallet.gap_limit = gap
|
wallet.gap_limit = gap
|
||||||
wallet.seed = ''
|
wallet.seed = ''
|
||||||
wallet.init_sequence(str(seed))
|
|
||||||
|
print eval(mpk)
|
||||||
|
try:
|
||||||
|
c0, K0 = eval(mpk)
|
||||||
|
except:
|
||||||
|
QMessageBox.warning(None, _('Error'), _('error'), _('OK'))
|
||||||
|
return
|
||||||
|
wallet.create_watching_only_wallet(c0,K0)
|
||||||
|
|
||||||
|
|
||||||
else: raise
|
else: raise
|
||||||
|
|
||||||
|
|||||||
@@ -238,6 +238,13 @@ class Wallet:
|
|||||||
self.storage.put('seed', self.seed, True)
|
self.storage.put('seed', self.seed, True)
|
||||||
self.storage.put('seed_version', self.seed_version, True)
|
self.storage.put('seed_version', self.seed_version, True)
|
||||||
|
|
||||||
|
def create_watching_only_wallet(self, c0, K0):
|
||||||
|
cK0 = ""
|
||||||
|
self.master_public_keys = {
|
||||||
|
"m/0'/": (c0, K0, cK0),
|
||||||
|
}
|
||||||
|
self.storage.put('master_public_keys', self.master_public_keys, True)
|
||||||
|
self.create_account('1','Main account')
|
||||||
|
|
||||||
def create_accounts(self):
|
def create_accounts(self):
|
||||||
|
|
||||||
@@ -254,7 +261,6 @@ class Wallet:
|
|||||||
k5, c5, K5, cK5 = bip32_private_derivation(master_k, master_c, "m/", "m/5'/")
|
k5, c5, K5, cK5 = bip32_private_derivation(master_k, master_c, "m/", "m/5'/")
|
||||||
|
|
||||||
self.master_public_keys = {
|
self.master_public_keys = {
|
||||||
"m/": (master_c, master_K, master_cK),
|
|
||||||
"m/0'/": (c0, K0, cK0),
|
"m/0'/": (c0, K0, cK0),
|
||||||
"m/1'/": (c1, K1, cK1),
|
"m/1'/": (c1, K1, cK1),
|
||||||
"m/2'/": (c2, K2, cK2),
|
"m/2'/": (c2, K2, cK2),
|
||||||
@@ -423,7 +429,8 @@ class Wallet:
|
|||||||
if self.seed_version == 4:
|
if self.seed_version == 4:
|
||||||
return self.storage.get("master_public_key")
|
return self.storage.get("master_public_key")
|
||||||
else:
|
else:
|
||||||
return self.storage.get("master_public_keys")["m/"]
|
c, K, cK = self.storage.get("master_public_keys")["m/0'/"]
|
||||||
|
return repr((c, K))
|
||||||
|
|
||||||
def get_master_private_key(self, account, password):
|
def get_master_private_key(self, account, password):
|
||||||
master_k = pw_decode( self.master_private_keys[account], password)
|
master_k = pw_decode( self.master_private_keys[account], password)
|
||||||
@@ -697,7 +704,7 @@ class Wallet:
|
|||||||
for account_type in ['1','2of2','2of3']:
|
for account_type in ['1','2of2','2of3']:
|
||||||
a = self.new_account_address(account_type)
|
a = self.new_account_address(account_type)
|
||||||
if self.address_is_old(a):
|
if self.address_is_old(a):
|
||||||
print "creating account", a
|
print_error( "creating account", a )
|
||||||
self.create_account(account_type)
|
self.create_account(account_type)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user