restore from master public key (qt and command line)
This commit is contained in:
19
electrum
19
electrum
@@ -90,6 +90,7 @@ def arg_parser():
|
|||||||
parser.add_option("-W", "--password", dest="password", default=None, help="set password for usage with commands (currently only implemented for create command, do not use it for longrunning gui session since the password is visible in /proc)")
|
parser.add_option("-W", "--password", dest="password", default=None, help="set password for usage with commands (currently only implemented for create command, do not use it for longrunning gui session since the password is visible in /proc)")
|
||||||
parser.add_option("-1", "--oneserver", action="store_true", dest="oneserver", default=False, help="connect to one server only")
|
parser.add_option("-1", "--oneserver", action="store_true", dest="oneserver", default=False, help="connect to one server only")
|
||||||
parser.add_option("--bip32", action="store_true", dest="bip32", default=False, help="bip32")
|
parser.add_option("--bip32", action="store_true", dest="bip32", default=False, help="bip32")
|
||||||
|
parser.add_option("--mpk", dest="mpk", default=False, help="master public key")
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
@@ -265,6 +266,8 @@ if __name__ == '__main__':
|
|||||||
sys.exit("Error: Remove the existing wallet first!")
|
sys.exit("Error: Remove the existing wallet first!")
|
||||||
if options.password is not None:
|
if options.password is not None:
|
||||||
password = options.password
|
password = options.password
|
||||||
|
elif cmd.name == 'restore' and options.mpk:
|
||||||
|
password = None
|
||||||
else:
|
else:
|
||||||
password = prompt_password("Password (hit return if you do not wish to encrypt your wallet):")
|
password = prompt_password("Password (hit return if you do not wish to encrypt your wallet):")
|
||||||
|
|
||||||
@@ -282,12 +285,16 @@ if __name__ == '__main__':
|
|||||||
# wallet.change_gap_limit(int(gap))
|
# wallet.change_gap_limit(int(gap))
|
||||||
|
|
||||||
if cmd.name == 'restore':
|
if cmd.name == 'restore':
|
||||||
import getpass
|
if options.mpk:
|
||||||
seed = getpass.getpass(prompt="seed:", stream=None) if options.concealed else raw_input("seed:")
|
wallet = Wallet.from_mpk(options.mpk, storage)
|
||||||
wallet = Wallet.from_seed(str(seed),storage)
|
else:
|
||||||
if not wallet:
|
import getpass
|
||||||
sys.exit("Error: Invalid seed")
|
seed = getpass.getpass(prompt="seed:", stream=None) if options.concealed else raw_input("seed:")
|
||||||
wallet.save_seed(password)
|
wallet = Wallet.from_seed(str(seed),storage)
|
||||||
|
if not wallet:
|
||||||
|
sys.exit("Error: Invalid seed")
|
||||||
|
wallet.save_seed(password)
|
||||||
|
|
||||||
if not options.offline:
|
if not options.offline:
|
||||||
network = Network(config)
|
network = Network(config)
|
||||||
network.start()
|
network.start()
|
||||||
|
|||||||
@@ -167,12 +167,6 @@ class InstallWizard(QDialog):
|
|||||||
mpk_e.setMaximumHeight(100)
|
mpk_e.setMaximumHeight(100)
|
||||||
grid.addWidget(mpk_e, 0, 1)
|
grid.addWidget(mpk_e, 0, 1)
|
||||||
|
|
||||||
label = QLabel(_("Chain"))
|
|
||||||
#grid.addWidget(label, 1, 0)
|
|
||||||
chain_e = QTextEdit()
|
|
||||||
chain_e.setMaximumHeight(100)
|
|
||||||
#grid.addWidget(chain_e, 1, 1)
|
|
||||||
|
|
||||||
vbox.addLayout(grid)
|
vbox.addLayout(grid)
|
||||||
|
|
||||||
vbox.addStretch(1)
|
vbox.addStretch(1)
|
||||||
@@ -183,8 +177,7 @@ class InstallWizard(QDialog):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
mpk = str(mpk_e.toPlainText()).strip()
|
mpk = str(mpk_e.toPlainText()).strip()
|
||||||
chain = str(chain_e.toPlainText()).strip()
|
return mpk
|
||||||
return mpk, chain
|
|
||||||
|
|
||||||
|
|
||||||
def network_dialog(self):
|
def network_dialog(self):
|
||||||
@@ -289,8 +282,7 @@ class InstallWizard(QDialog):
|
|||||||
mpk = self.mpk_dialog()
|
mpk = self.mpk_dialog()
|
||||||
if not mpk:
|
if not mpk:
|
||||||
return
|
return
|
||||||
wallet.seed = ''
|
wallet = Wallet.from_mpk(mpk, self.storage)
|
||||||
wallet.create_watching_only_wallet(mpk)
|
|
||||||
|
|
||||||
else: raise
|
else: raise
|
||||||
|
|
||||||
|
|||||||
@@ -1809,7 +1809,6 @@ class Wallet(object):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_seed(self, seed, storage):
|
def from_seed(self, seed, storage):
|
||||||
import mnemonic
|
import mnemonic
|
||||||
@@ -1835,8 +1834,26 @@ class Wallet(object):
|
|||||||
w.init_seed(seed) #hex
|
w.init_seed(seed) #hex
|
||||||
else:
|
else:
|
||||||
#assert is_seed(seed)
|
#assert is_seed(seed)
|
||||||
w = Wallet(storage)
|
w = NewWallet(storage)
|
||||||
w.init_seed(seed)
|
w.init_seed(seed)
|
||||||
|
|
||||||
|
return w
|
||||||
|
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_mpk(self, s, storage):
|
||||||
|
try:
|
||||||
|
mpk, chain = s.split(':')
|
||||||
|
except:
|
||||||
|
mpk = s
|
||||||
|
chain = False
|
||||||
|
|
||||||
|
if chain:
|
||||||
|
w = NewWallet(storage)
|
||||||
|
w.create_watching_only_wallet(mpk, chain)
|
||||||
|
else:
|
||||||
|
w = OldWallet(storage)
|
||||||
|
w.seed = ''
|
||||||
|
w.create_watching_only_wallet(mpk)
|
||||||
|
|
||||||
return w
|
return w
|
||||||
|
|||||||
Reference in New Issue
Block a user