mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-12 13:39:52 +00:00
wizard: option to create multisig wallet manually
This commit is contained in:
parent
ac4a522289
commit
5d68ce4f22
3 changed files with 55 additions and 24 deletions
|
@ -3,7 +3,7 @@ from PyQt4.QtCore import *
|
||||||
import PyQt4.QtCore as QtCore
|
import PyQt4.QtCore as QtCore
|
||||||
|
|
||||||
from electrum.i18n import _
|
from electrum.i18n import _
|
||||||
from electrum import Wallet, Wallet_2of3
|
from electrum import Wallet, Wallet_2of2, Wallet_2of3
|
||||||
|
|
||||||
import seed_dialog
|
import seed_dialog
|
||||||
from network_dialog import NetworkDialog
|
from network_dialog import NetworkDialog
|
||||||
|
@ -250,14 +250,18 @@ class InstallWizard(QDialog):
|
||||||
gb = QGroupBox()
|
gb = QGroupBox()
|
||||||
|
|
||||||
b1 = QRadioButton(gb)
|
b1 = QRadioButton(gb)
|
||||||
b1.setText(_("Standard wallet (protected by password)"))
|
b1.setText(_("Standard wallet"))
|
||||||
b1.setChecked(True)
|
b1.setChecked(True)
|
||||||
|
|
||||||
b2 = QRadioButton(gb)
|
b2 = QRadioButton(gb)
|
||||||
b2.setText(_("Multi-signature wallet (two-factor authentication)"))
|
b2.setText(_("Wallet with two-factor authentication (plugin)"))
|
||||||
|
|
||||||
|
b3 = QRadioButton(gb)
|
||||||
|
b3.setText(_("Multisig wallet (paired manually)"))
|
||||||
|
|
||||||
grid.addWidget(b1,1,0)
|
grid.addWidget(b1,1,0)
|
||||||
grid.addWidget(b2,2,0)
|
grid.addWidget(b2,2,0)
|
||||||
|
grid.addWidget(b3,3,0)
|
||||||
|
|
||||||
vbox = QVBoxLayout()
|
vbox = QVBoxLayout()
|
||||||
|
|
||||||
|
@ -272,7 +276,9 @@ class InstallWizard(QDialog):
|
||||||
if b1.isChecked():
|
if b1.isChecked():
|
||||||
return 'standard'
|
return 'standard'
|
||||||
elif b2.isChecked():
|
elif b2.isChecked():
|
||||||
return '2of3'
|
return 'multisig_plugin'
|
||||||
|
elif b3.isChecked():
|
||||||
|
return 'multisig_manual'
|
||||||
|
|
||||||
|
|
||||||
def run(self, action):
|
def run(self, action):
|
||||||
|
@ -288,12 +294,16 @@ class InstallWizard(QDialog):
|
||||||
if not t:
|
if not t:
|
||||||
return
|
return
|
||||||
|
|
||||||
if t == '2of3':
|
if t == 'multisig_plugin':
|
||||||
action = 'create_cold'
|
action = 'create_2of3_1'
|
||||||
|
if t == 'multisig_manual':
|
||||||
|
action = 'create_2of2_1'
|
||||||
|
|
||||||
|
if action in ['create']:
|
||||||
if action in ['create', 'create_cold', 'create_hot', 'create_remote']:
|
|
||||||
wallet = Wallet(self.storage)
|
wallet = Wallet(self.storage)
|
||||||
|
elif action in ['create_2of2_1','create_2of2_2']:
|
||||||
|
wallet = Wallet_2of2(self.storage)
|
||||||
|
|
||||||
|
|
||||||
if action == 'create':
|
if action == 'create':
|
||||||
seed = wallet.make_seed()
|
seed = wallet.make_seed()
|
||||||
|
@ -304,16 +314,15 @@ class InstallWizard(QDialog):
|
||||||
password = self.password_dialog()
|
password = self.password_dialog()
|
||||||
wallet.add_seed(seed, password)
|
wallet.add_seed(seed, password)
|
||||||
wallet.create_accounts(password)
|
wallet.create_accounts(password)
|
||||||
# generate first addresses offline
|
|
||||||
self.waiting_dialog(wallet.synchronize)
|
self.waiting_dialog(wallet.synchronize)
|
||||||
|
|
||||||
|
|
||||||
if action == 'create_cold':
|
if action == 'create_2of3_1':
|
||||||
run_hook('create_cold_seed', self.storage, self)
|
run_hook('create_cold_seed', self.storage, self)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
if action == 'create_hot':
|
if action in ['create_2of2_1', 'create_2of3_2']:
|
||||||
msg = _('You are about to create the hot seed of a multisig wallet')
|
msg = _('You are about to create the hot seed of a multisig wallet')
|
||||||
if not self.question(msg):
|
if not self.question(msg):
|
||||||
return
|
return
|
||||||
|
@ -324,10 +333,22 @@ class InstallWizard(QDialog):
|
||||||
return
|
return
|
||||||
password = self.password_dialog()
|
password = self.password_dialog()
|
||||||
wallet.add_seed(seed, password)
|
wallet.add_seed(seed, password)
|
||||||
action = 'create_remote'
|
if action == 'create_2of2_1':
|
||||||
|
# display mpk
|
||||||
|
action = 'create_2of2_2'
|
||||||
|
else:
|
||||||
|
action = 'create_2of3_3'
|
||||||
|
|
||||||
|
if action == 'create_2of2_2':
|
||||||
|
xpub = self.enter_seed_dialog(True, 'cold')
|
||||||
|
if not Wallet.is_mpk(xpub):
|
||||||
|
return
|
||||||
|
wallet.add_master_public_key("cold/", xpub)
|
||||||
|
wallet.create_account()
|
||||||
|
self.waiting_dialog(wallet.synchronize)
|
||||||
|
|
||||||
|
|
||||||
if action == 'create_remote':
|
if action == 'create_2of3_3':
|
||||||
run_hook('create_remote_key', wallet, self)
|
run_hook('create_remote_key', wallet, self)
|
||||||
if not wallet.master_public_keys.get("remote/"):
|
if not wallet.master_public_keys.get("remote/"):
|
||||||
return
|
return
|
||||||
|
@ -352,12 +373,15 @@ class InstallWizard(QDialog):
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
elif t in ['2of2', '2of3']:
|
elif t in ['multisig_plugin', 'multisig_manual']:
|
||||||
r = self.double_seed_dialog()
|
r = self.double_seed_dialog()
|
||||||
if not r:
|
if not r:
|
||||||
return
|
return
|
||||||
text1, text2 = r
|
text1, text2 = r
|
||||||
password = self.password_dialog()
|
password = self.password_dialog()
|
||||||
|
if t == 'multisig_manual':
|
||||||
|
wallet = Wallet_2of2(self.storage)
|
||||||
|
else:
|
||||||
wallet = Wallet_2of3(self.storage)
|
wallet = Wallet_2of3(self.storage)
|
||||||
|
|
||||||
if Wallet.is_seed(text1):
|
if Wallet.is_seed(text1):
|
||||||
|
@ -375,9 +399,10 @@ class InstallWizard(QDialog):
|
||||||
wallet.add_master_public_key("m/", text1)
|
wallet.add_master_public_key("m/", text1)
|
||||||
wallet.add_master_public_key("cold/", text2)
|
wallet.add_master_public_key("cold/", text2)
|
||||||
|
|
||||||
|
if t == '2of3':
|
||||||
run_hook('restore_third_key', wallet, self)
|
run_hook('restore_third_key', wallet, self)
|
||||||
|
|
||||||
wallet.create_accounts(None)
|
wallet.create_account()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from version import ELECTRUM_VERSION
|
from version import ELECTRUM_VERSION
|
||||||
from util import format_satoshis, print_msg, print_json, print_error, set_verbosity
|
from util import format_satoshis, print_msg, print_json, print_error, set_verbosity
|
||||||
from wallet import WalletSynchronizer, WalletStorage
|
from wallet import WalletSynchronizer, WalletStorage
|
||||||
from wallet import Wallet, Wallet_2of3
|
from wallet import Wallet, Wallet_2of2, Wallet_2of3
|
||||||
from verifier import TxVerifier
|
from verifier import TxVerifier
|
||||||
from network import Network, DEFAULT_SERVERS, DEFAULT_PORTS, pick_random_server
|
from network import Network, DEFAULT_SERVERS, DEFAULT_PORTS, pick_random_server
|
||||||
from interface import Interface
|
from interface import Interface
|
||||||
|
|
|
@ -1486,8 +1486,7 @@ class Wallet_2of2(NewWallet):
|
||||||
def can_create_accounts(self):
|
def can_create_accounts(self):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def create_account(self, account_id):
|
def create_account(self):
|
||||||
"""Creates and saves the master keys, but does not save the account"""
|
|
||||||
xpub1 = self.master_public_keys.get("m/")
|
xpub1 = self.master_public_keys.get("m/")
|
||||||
xpub2 = self.master_public_keys.get("cold/")
|
xpub2 = self.master_public_keys.get("cold/")
|
||||||
account = BIP32_Account_2of2({'xpub':xpub1, 'xpub2':xpub2})
|
account = BIP32_Account_2of2({'xpub':xpub1, 'xpub2':xpub2})
|
||||||
|
@ -1498,6 +1497,13 @@ class Wallet_2of2(NewWallet):
|
||||||
xpub2 = self.master_public_keys.get("cold/")
|
xpub2 = self.master_public_keys.get("cold/")
|
||||||
return {'hot':xpub1, 'cold':xpub2}
|
return {'hot':xpub1, 'cold':xpub2}
|
||||||
|
|
||||||
|
def get_action(self):
|
||||||
|
xpub1 = self.master_public_keys.get("m/")
|
||||||
|
xpub2 = self.master_public_keys.get("cold/")
|
||||||
|
if xpub1 is None:
|
||||||
|
return 'create_2of2_1'
|
||||||
|
if xpub2 is None:
|
||||||
|
return 'create_2of2_2'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1525,11 +1531,11 @@ class Wallet_2of3(Wallet_2of2):
|
||||||
xpub2 = self.master_public_keys.get("cold/")
|
xpub2 = self.master_public_keys.get("cold/")
|
||||||
xpub3 = self.master_public_keys.get("remote/")
|
xpub3 = self.master_public_keys.get("remote/")
|
||||||
if xpub2 is None:
|
if xpub2 is None:
|
||||||
return 'create_cold'
|
return 'create_2of3_1'
|
||||||
if xpub1 is None:
|
if xpub1 is None:
|
||||||
return 'create_hot'
|
return 'create_2of3_2'
|
||||||
if xpub3 is None:
|
if xpub3 is None:
|
||||||
return 'create_remote'
|
return 'create_2of3_3'
|
||||||
|
|
||||||
|
|
||||||
class WalletSynchronizer(threading.Thread):
|
class WalletSynchronizer(threading.Thread):
|
||||||
|
|
Loading…
Add table
Reference in a new issue