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)
|
activity.bind(on_activity_result=on_qr_result)
|
||||||
integrator.initiateScan()
|
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):
|
def build(self):
|
||||||
return Builder.load_file('gui/kivy/main.kv')
|
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_press: if self.root: self.root.dispatch('on_press', self)
|
||||||
on_release: if self.root: self.root.dispatch('on_release', 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>
|
<-WizardDialog>
|
||||||
text_color: .854, .925, .984, 1
|
text_color: .854, .925, .984, 1
|
||||||
@ -196,12 +202,8 @@ Builder.load_string('''
|
|||||||
|
|
||||||
<RestoreSeedDialog>
|
<RestoreSeedDialog>
|
||||||
word: ''
|
word: ''
|
||||||
Label:
|
BigLabel:
|
||||||
color: root.text_color
|
text: "ENTER YOUR SEED PHRASE"
|
||||||
size_hint: 1, None
|
|
||||||
text_size: self.width, None
|
|
||||||
height: self.texture_size[1]
|
|
||||||
text: "[b]ENTER YOUR SEED PHRASE[/b]"
|
|
||||||
GridLayout
|
GridLayout
|
||||||
cols: 1
|
cols: 1
|
||||||
padding: 0, '12dp'
|
padding: 0, '12dp'
|
||||||
@ -301,12 +303,10 @@ Builder.load_string('''
|
|||||||
text: '<'
|
text: '<'
|
||||||
|
|
||||||
<AddXpubDialog>
|
<AddXpubDialog>
|
||||||
Label:
|
title: ''
|
||||||
color: root.text_color
|
message: ''
|
||||||
size_hint: 1, None
|
BigLabel:
|
||||||
text_size: self.width, None
|
text: root.title
|
||||||
height: self.texture_size[1]
|
|
||||||
text: "[b]MASTER PUBLIC KEY[/b]"
|
|
||||||
GridLayout
|
GridLayout
|
||||||
cols: 1
|
cols: 1
|
||||||
padding: 0, '12dp'
|
padding: 0, '12dp'
|
||||||
@ -315,12 +315,11 @@ Builder.load_string('''
|
|||||||
size_hint: 1, None
|
size_hint: 1, None
|
||||||
height: self.minimum_height
|
height: self.minimum_height
|
||||||
SeedButton:
|
SeedButton:
|
||||||
id: text_input_seed
|
id: text_input
|
||||||
text: ''
|
text: ''
|
||||||
on_text: Clock.schedule_once(root.on_text)
|
on_text: Clock.schedule_once(root.check_text)
|
||||||
SeedLabel:
|
SeedLabel:
|
||||||
text: root.message
|
text: root.message
|
||||||
|
|
||||||
GridLayout
|
GridLayout
|
||||||
rows: 1
|
rows: 1
|
||||||
spacing: '12dp'
|
spacing: '12dp'
|
||||||
@ -340,15 +339,44 @@ Builder.load_string('''
|
|||||||
on_release: root.do_clear()
|
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>
|
<ShowSeedDialog>
|
||||||
spacing: '12dp'
|
spacing: '12dp'
|
||||||
value: 'next'
|
value: 'next'
|
||||||
Label:
|
BigLabel:
|
||||||
color: root.text_color
|
text: "PLEASE WRITE DOWN YOUR SEED PHRASE"
|
||||||
size_hint: 1, None
|
|
||||||
text_size: self.width, None
|
|
||||||
height: self.texture_size[1]
|
|
||||||
text: "[b]PLEASE WRITE DOWN YOUR SEED PHRASE[/b]"
|
|
||||||
GridLayout:
|
GridLayout:
|
||||||
id: grid
|
id: grid
|
||||||
cols: 1
|
cols: 1
|
||||||
@ -546,30 +574,50 @@ class RestoreSeedDialog(WizardDialog):
|
|||||||
tis._keyboard.unbind(on_key_down=self.on_key_down)
|
tis._keyboard.unbind(on_key_down=self.on_key_down)
|
||||||
tis.focus = False
|
tis.focus = False
|
||||||
|
|
||||||
class AddXpubDialog(WizardDialog):
|
|
||||||
|
|
||||||
message = StringProperty('')
|
class ShowXpubDialog(WizardDialog):
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super(AddXpubDialog, self).__init__(**kwargs)
|
WizardDialog.__init__(self, **kwargs)
|
||||||
self._test = kwargs['test']
|
|
||||||
self.app = App.get_running_app()
|
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):
|
def get_text(self):
|
||||||
ti = self.ids.text_input_seed
|
ti = self.ids.text_input
|
||||||
return unicode(ti.text).strip()
|
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 scan_xpub(self):
|
||||||
def on_complete(text):
|
def on_complete(text):
|
||||||
self.ids.text_input_seed.text = text
|
self.ids.text_input.text = text
|
||||||
self.app.scan_qr(on_complete)
|
self.app.scan_qr(on_complete)
|
||||||
|
|
||||||
def do_paste(self):
|
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):
|
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
|
from functools import partial
|
||||||
import weakref
|
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
|
from password_dialog import PasswordDialog
|
||||||
|
|
||||||
|
|
||||||
@ -135,8 +135,9 @@ class InstallWizard(Widget):
|
|||||||
return
|
return
|
||||||
text = _dlg.get_text()
|
text = _dlg.get_text()
|
||||||
self.run('create_wallet', (text, None))
|
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.')
|
title = "MASTER PUBLIC KEY"
|
||||||
AddXpubDialog(test=Wallet.is_mpk, message=msg, on_release=on_xpub).open()
|
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):
|
def create_standard(self):
|
||||||
self.wallet_type = 'standard'
|
self.wallet_type = 'standard'
|
||||||
@ -158,15 +159,30 @@ class InstallWizard(Widget):
|
|||||||
action = self.wallet.get_action()
|
action = self.wallet.get_action()
|
||||||
self.run(action)
|
self.run(action)
|
||||||
|
|
||||||
|
|
||||||
def add_cosigners(self):
|
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):
|
def on_xpub(_dlg, btn):
|
||||||
xpub = _dlg.get_text()
|
xpub = _dlg.get_text()
|
||||||
_dlg.close()
|
_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()
|
action = self.wallet.get_action()
|
||||||
|
if action == 'add_cosigners': action = 'add_cosigner'
|
||||||
self.run(action)
|
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):
|
def create_main_account(self):
|
||||||
self.wallet.create_main_account()
|
self.wallet.create_main_account()
|
||||||
|
|||||||
@ -357,20 +357,8 @@ class ReceiveScreen(CScreen):
|
|||||||
qr.set_data(uri)
|
qr.set_data(uri)
|
||||||
|
|
||||||
def do_share(self):
|
def do_share(self):
|
||||||
if platform != 'android':
|
|
||||||
return
|
|
||||||
uri = self.get_URI()
|
uri = self.get_URI()
|
||||||
from jnius import autoclass, cast
|
self.app.do_share(uri)
|
||||||
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)
|
|
||||||
|
|
||||||
def do_copy(self):
|
def do_copy(self):
|
||||||
uri = self.get_URI()
|
uri = self.get_URI()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user