kivy: finish multisig in instalwizard
This commit is contained in:
parent
b6393cbdf2
commit
7c42957a7c
|
@ -346,6 +346,21 @@ class ElectrumWindow(App):
|
|||
activity.bind(on_activity_result=on_qr_result)
|
||||
integrator.initiateScan()
|
||||
|
||||
def do_share(self, data):
|
||||
if platform != 'android':
|
||||
return
|
||||
from jnius import autoclass, cast
|
||||
JS = autoclass('java.lang.String')
|
||||
Intent = autoclass('android.content.Intent')
|
||||
sendIntent = Intent()
|
||||
sendIntent.setAction(Intent.ACTION_SEND)
|
||||
sendIntent.setType("text/plain")
|
||||
sendIntent.putExtra(Intent.EXTRA_TEXT, JS(data))
|
||||
PythonActivity = autoclass('org.renpy.android.PythonActivity')
|
||||
currentActivity = cast('android.app.Activity', PythonActivity.mActivity)
|
||||
it = Intent.createChooser(sendIntent, cast('java.lang.CharSequence', JS("Share Bitcoin Request")))
|
||||
currentActivity.startActivity(it)
|
||||
|
||||
def build(self):
|
||||
return Builder.load_file('gui/kivy/main.kv')
|
||||
|
||||
|
|
|
@ -40,6 +40,12 @@ Builder.load_string('''
|
|||
on_press: if self.root: self.root.dispatch('on_press', self)
|
||||
on_release: if self.root: self.root.dispatch('on_release', self)
|
||||
|
||||
<BigLabel@Label>
|
||||
color: .854, .925, .984, 1
|
||||
size_hint: 1, None
|
||||
text_size: self.width, None
|
||||
height: self.texture_size[1]
|
||||
bold: True
|
||||
|
||||
<-WizardDialog>
|
||||
text_color: .854, .925, .984, 1
|
||||
|
@ -196,12 +202,8 @@ Builder.load_string('''
|
|||
|
||||
<RestoreSeedDialog>
|
||||
word: ''
|
||||
Label:
|
||||
color: root.text_color
|
||||
size_hint: 1, None
|
||||
text_size: self.width, None
|
||||
height: self.texture_size[1]
|
||||
text: "[b]ENTER YOUR SEED PHRASE[/b]"
|
||||
BigLabel:
|
||||
text: "ENTER YOUR SEED PHRASE"
|
||||
GridLayout
|
||||
cols: 1
|
||||
padding: 0, '12dp'
|
||||
|
@ -301,12 +303,10 @@ Builder.load_string('''
|
|||
text: '<'
|
||||
|
||||
<AddXpubDialog>
|
||||
Label:
|
||||
color: root.text_color
|
||||
size_hint: 1, None
|
||||
text_size: self.width, None
|
||||
height: self.texture_size[1]
|
||||
text: "[b]MASTER PUBLIC KEY[/b]"
|
||||
title: ''
|
||||
message: ''
|
||||
BigLabel:
|
||||
text: root.title
|
||||
GridLayout
|
||||
cols: 1
|
||||
padding: 0, '12dp'
|
||||
|
@ -315,12 +315,11 @@ Builder.load_string('''
|
|||
size_hint: 1, None
|
||||
height: self.minimum_height
|
||||
SeedButton:
|
||||
id: text_input_seed
|
||||
id: text_input
|
||||
text: ''
|
||||
on_text: Clock.schedule_once(root.on_text)
|
||||
on_text: Clock.schedule_once(root.check_text)
|
||||
SeedLabel:
|
||||
text: root.message
|
||||
|
||||
GridLayout
|
||||
rows: 1
|
||||
spacing: '12dp'
|
||||
|
@ -340,15 +339,44 @@ Builder.load_string('''
|
|||
on_release: root.do_clear()
|
||||
|
||||
|
||||
<ShowXpubDialog>
|
||||
xpub: ''
|
||||
message: _('Here is your master public key. Share it with your cosigners.')
|
||||
BigLabel:
|
||||
text: "MASTER PUBLIC KEY"
|
||||
GridLayout
|
||||
cols: 1
|
||||
padding: 0, '12dp'
|
||||
orientation: 'vertical'
|
||||
spacing: '12dp'
|
||||
size_hint: 1, None
|
||||
height: self.minimum_height
|
||||
SeedButton:
|
||||
id: text_input
|
||||
text: root.xpub
|
||||
SeedLabel:
|
||||
text: root.message
|
||||
GridLayout
|
||||
rows: 1
|
||||
spacing: '12dp'
|
||||
size_hint: 1, None
|
||||
height: self.minimum_height
|
||||
WizardButton:
|
||||
text: _('QR code')
|
||||
on_release: root.do_qr()
|
||||
WizardButton:
|
||||
text: _('Copy')
|
||||
on_release: root.do_copy()
|
||||
WizardButton:
|
||||
text: _('Share')
|
||||
on_release: root.do_share()
|
||||
|
||||
|
||||
<ShowSeedDialog>
|
||||
spacing: '12dp'
|
||||
value: 'next'
|
||||
Label:
|
||||
color: root.text_color
|
||||
size_hint: 1, None
|
||||
text_size: self.width, None
|
||||
height: self.texture_size[1]
|
||||
text: "[b]PLEASE WRITE DOWN YOUR SEED PHRASE[/b]"
|
||||
BigLabel:
|
||||
text: "PLEASE WRITE DOWN YOUR SEED PHRASE"
|
||||
GridLayout:
|
||||
id: grid
|
||||
cols: 1
|
||||
|
@ -546,30 +574,50 @@ class RestoreSeedDialog(WizardDialog):
|
|||
tis._keyboard.unbind(on_key_down=self.on_key_down)
|
||||
tis.focus = False
|
||||
|
||||
class AddXpubDialog(WizardDialog):
|
||||
|
||||
message = StringProperty('')
|
||||
class ShowXpubDialog(WizardDialog):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super(AddXpubDialog, self).__init__(**kwargs)
|
||||
self._test = kwargs['test']
|
||||
WizardDialog.__init__(self, **kwargs)
|
||||
self.app = App.get_running_app()
|
||||
self.xpub = kwargs['xpub']
|
||||
self.ids.next.disabled = False
|
||||
|
||||
def do_copy(self):
|
||||
self.app._clipboard.copy(self.xpub)
|
||||
|
||||
def do_share(self):
|
||||
self.app.do_share(self.xpub)
|
||||
|
||||
def do_qr(self):
|
||||
from qr_dialog import QRDialog
|
||||
popup = QRDialog(_("Master Public Key"), self.xpub, True)
|
||||
popup.open()
|
||||
|
||||
|
||||
class AddXpubDialog(WizardDialog):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
WizardDialog.__init__(self, **kwargs)
|
||||
self.app = App.get_running_app()
|
||||
self._test = kwargs['test']
|
||||
self.title = kwargs['title']
|
||||
self.message = kwargs['message']
|
||||
|
||||
def check_text(self, dt):
|
||||
self.ids.next.disabled = not bool(self._test(self.get_text()))
|
||||
|
||||
def get_text(self):
|
||||
ti = self.ids.text_input_seed
|
||||
ti = self.ids.text_input
|
||||
return unicode(ti.text).strip()
|
||||
|
||||
def on_text(self, dt):
|
||||
self.ids.next.disabled = not bool(self._test(self.get_text()))
|
||||
|
||||
def scan_xpub(self):
|
||||
def on_complete(text):
|
||||
self.ids.text_input_seed.text = text
|
||||
self.ids.text_input.text = text
|
||||
self.app.scan_qr(on_complete)
|
||||
|
||||
def do_paste(self):
|
||||
self.ids.text_input_seed.text = test_xpub if is_test else unicode(self.app._clipboard.paste())
|
||||
self.ids.text_input.text = test_xpub if is_test else unicode(self.app._clipboard.paste())
|
||||
|
||||
def do_clear(self):
|
||||
self.ids.text_input_seed.text = ''
|
||||
|
||||
self.ids.text_input.text = ''
|
||||
|
|
|
@ -13,7 +13,7 @@ import threading
|
|||
from functools import partial
|
||||
import weakref
|
||||
|
||||
from create_restore import WizardChoiceDialog, ShowSeedDialog, RestoreSeedDialog, AddXpubDialog, WizardMultisigDialog
|
||||
from create_restore import WizardChoiceDialog, ShowSeedDialog, RestoreSeedDialog, AddXpubDialog, ShowXpubDialog, WizardMultisigDialog
|
||||
from password_dialog import PasswordDialog
|
||||
|
||||
|
||||
|
@ -135,8 +135,9 @@ class InstallWizard(Widget):
|
|||
return
|
||||
text = _dlg.get_text()
|
||||
self.run('create_wallet', (text, None))
|
||||
msg = _('To create a watching-only wallet, paste your master public key, or scan it using the camera button.')
|
||||
AddXpubDialog(test=Wallet.is_mpk, message=msg, on_release=on_xpub).open()
|
||||
title = "MASTER PUBLIC KEY"
|
||||
message = _('To create a watching-only wallet, paste your master public key, or scan it using the camera button.')
|
||||
AddXpubDialog(title=title, message=message, test=Wallet.is_mpk, on_release=on_xpub).open()
|
||||
|
||||
def create_standard(self):
|
||||
self.wallet_type = 'standard'
|
||||
|
@ -158,15 +159,30 @@ class InstallWizard(Widget):
|
|||
action = self.wallet.get_action()
|
||||
self.run(action)
|
||||
|
||||
|
||||
def add_cosigners(self):
|
||||
def on_release(_dlg, btn):
|
||||
_dlg.close()
|
||||
self.run('add_cosigner')
|
||||
xpub = self.wallet.master_public_keys.get('x1/')
|
||||
ShowXpubDialog(xpub=xpub, test=Wallet.is_xpub, on_release=on_release).open()
|
||||
|
||||
def add_cosigner(self):
|
||||
def on_xpub(_dlg, btn):
|
||||
xpub = _dlg.get_text()
|
||||
_dlg.close()
|
||||
self.wallet.add_master_public_key("x%d/" % 2, xpub)
|
||||
if btn is _dlg.ids.back:
|
||||
self.run('add_cosigners')
|
||||
return
|
||||
if xpub:
|
||||
self.wallet.add_master_public_key("x%d/" % 2, xpub)
|
||||
action = self.wallet.get_action()
|
||||
if action == 'add_cosigners': action = 'add_cosigner'
|
||||
self.run(action)
|
||||
msg = _('Paste your cosigner xpub, or scan it using the camera button.')
|
||||
AddXpubDialog(test=Wallet.is_xpub, message=msg, on_release=on_xpub).open()
|
||||
|
||||
title = "ADD COSIGNERS"
|
||||
message = _('Please paste your cosigners master public key, or scan it using the camera button.')
|
||||
AddXpubDialog(title=title, message=message, test=Wallet.is_xpub, on_release=on_xpub).open()
|
||||
|
||||
def create_main_account(self):
|
||||
self.wallet.create_main_account()
|
||||
|
|
|
@ -357,20 +357,8 @@ class ReceiveScreen(CScreen):
|
|||
qr.set_data(uri)
|
||||
|
||||
def do_share(self):
|
||||
if platform != 'android':
|
||||
return
|
||||
uri = self.get_URI()
|
||||
from jnius import autoclass, cast
|
||||
JS = autoclass('java.lang.String')
|
||||
Intent = autoclass('android.content.Intent')
|
||||
sendIntent = Intent()
|
||||
sendIntent.setAction(Intent.ACTION_SEND)
|
||||
sendIntent.setType("text/plain")
|
||||
sendIntent.putExtra(Intent.EXTRA_TEXT, JS(uri))
|
||||
PythonActivity = autoclass('org.renpy.android.PythonActivity')
|
||||
currentActivity = cast('android.app.Activity', PythonActivity.mActivity)
|
||||
it = Intent.createChooser(sendIntent, cast('java.lang.CharSequence', JS("Share Bitcoin Request")))
|
||||
currentActivity.startActivity(it)
|
||||
self.app.do_share(uri)
|
||||
|
||||
def do_copy(self):
|
||||
uri = self.get_URI()
|
||||
|
|
Loading…
Reference in New Issue