mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
add password_dialog
This commit is contained in:
parent
2e8801fdda
commit
a199061462
4 changed files with 61 additions and 18 deletions
|
@ -381,15 +381,10 @@ class ElectrumWindow(App):
|
||||||
''' Initialize The Ux part of electrum. This function performs the basic
|
''' Initialize The Ux part of electrum. This function performs the basic
|
||||||
tasks of setting up the ui.
|
tasks of setting up the ui.
|
||||||
'''
|
'''
|
||||||
global ref
|
from weakref import ref
|
||||||
if not ref:
|
|
||||||
from weakref import ref
|
|
||||||
|
|
||||||
set_language(self.electrum_config.get('language'))
|
set_language(self.electrum_config.get('language'))
|
||||||
|
|
||||||
self.funds_error = False
|
self.funds_error = False
|
||||||
self.completions = []
|
|
||||||
|
|
||||||
# setup UX
|
# setup UX
|
||||||
self.screens = {}
|
self.screens = {}
|
||||||
|
|
||||||
|
@ -806,3 +801,18 @@ class ElectrumWindow(App):
|
||||||
if not pos:
|
if not pos:
|
||||||
pos = (win.center[0], win.center[1] - (info_bubble.height/2))
|
pos = (win.center[0], win.center[1] - (info_bubble.height/2))
|
||||||
info_bubble.show(pos, duration, width, modal=modal, exit=exit)
|
info_bubble.show(pos, duration, width, modal=modal, exit=exit)
|
||||||
|
|
||||||
|
|
||||||
|
def password_dialog(self, f, args):
|
||||||
|
if self.wallet.use_encryption:
|
||||||
|
popup = Builder.load_file('gui/kivy/uix/ui_screens/password.kv')
|
||||||
|
def callback():
|
||||||
|
pw = popup.ids.text_input.text
|
||||||
|
Clock.schedule_once(lambda x: apply(f, args + (pw,)), 0.5)
|
||||||
|
popup.on_dismiss = callback
|
||||||
|
popup.open()
|
||||||
|
else:
|
||||||
|
apply(f, args + (None,))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ from weakref import ref
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
import re
|
import re
|
||||||
import datetime
|
import datetime
|
||||||
|
import traceback, sys
|
||||||
|
|
||||||
from kivy.app import App
|
from kivy.app import App
|
||||||
from kivy.cache import Cache
|
from kivy.cache import Cache
|
||||||
|
@ -96,11 +97,9 @@ class HistoryScreen(CScreen):
|
||||||
time_str = _("unknown")
|
time_str = _("unknown")
|
||||||
if conf > 0:
|
if conf > 0:
|
||||||
try:
|
try:
|
||||||
time_str = datetime.datetime.fromtimestamp(
|
time_str = datetime.datetime.fromtimestamp(timestamp).isoformat(' ')[:-3]
|
||||||
timestamp).isoformat(' ')[:-3]
|
|
||||||
except Exception:
|
except Exception:
|
||||||
time_str = _("error")
|
time_str = _("error")
|
||||||
|
|
||||||
if conf == -1:
|
if conf == -1:
|
||||||
time_str = _('unverified')
|
time_str = _('unverified')
|
||||||
icon = "atlas://gui/kivy/theming/light/close"
|
icon = "atlas://gui/kivy/theming/light/close"
|
||||||
|
@ -153,7 +152,6 @@ class HistoryScreen(CScreen):
|
||||||
ri = RecentActivityItem()
|
ri = RecentActivityItem()
|
||||||
ri.icon = icon
|
ri.icon = icon
|
||||||
ri.date = date_time
|
ri.date = date_time
|
||||||
mintimestr = date_time.split()[0]
|
|
||||||
ri.address = address
|
ri.address = address
|
||||||
ri.amount = amount
|
ri.amount = amount
|
||||||
ri.quote_text = quote_text
|
ri.quote_text = quote_text
|
||||||
|
@ -223,17 +221,16 @@ class SendScreen(CScreen):
|
||||||
app.show_error(_('Invalid Fee'))
|
app.show_error(_('Invalid Fee'))
|
||||||
return
|
return
|
||||||
|
|
||||||
message = 'sending {} {} to {}'.format(self.app.base_unit, scrn.amount_e.text, r)
|
|
||||||
# assume no password and fee is None
|
|
||||||
password = None
|
|
||||||
fee = None
|
fee = None
|
||||||
self.send_tx([('address', to_address, amount)], fee, label, password)
|
message = 'sending {} {} to {}'.format(self.app.base_unit, scrn.amount_e.text, r)
|
||||||
|
outputs = [('address', to_address, amount)]
|
||||||
|
self.app.password_dialog(self.send_tx, (outputs, fee, label))
|
||||||
|
|
||||||
def send_tx(self, outputs, fee, label, password):
|
def send_tx(self, outputs, fee, label, password):
|
||||||
# make unsigned transaction
|
# make unsigned transaction
|
||||||
coins = self.app.wallet.get_spendable_coins()
|
coins = self.app.wallet.get_spendable_coins()
|
||||||
try:
|
try:
|
||||||
tx = self.app.wallet.make_unsigned_transaction(coins, outputs, self.electrum_config, fee)
|
tx = self.app.wallet.make_unsigned_transaction(coins, outputs, self.app.electrum_config, fee)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
traceback.print_exc(file=sys.stdout)
|
traceback.print_exc(file=sys.stdout)
|
||||||
self.app.show_error(str(e))
|
self.app.show_error(str(e))
|
||||||
|
@ -246,8 +243,8 @@ class SendScreen(CScreen):
|
||||||
self.app.show_error(str(e))
|
self.app.show_error(str(e))
|
||||||
return
|
return
|
||||||
# broadcast
|
# broadcast
|
||||||
self.wallet.sendtx(tx)
|
ok, txid = self.app.wallet.sendtx(tx)
|
||||||
|
self.app.show_info(txid)
|
||||||
|
|
||||||
|
|
||||||
class ReceiveScreen(CScreen):
|
class ReceiveScreen(CScreen):
|
||||||
|
|
27
gui/kivy/uix/ui_screens/password.kv
Normal file
27
gui/kivy/uix/ui_screens/password.kv
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
Popup:
|
||||||
|
id: pw
|
||||||
|
title: _('Password')
|
||||||
|
|
||||||
|
BoxLayout:
|
||||||
|
|
||||||
|
orientation: 'vertical'
|
||||||
|
size_hint: 1, None
|
||||||
|
|
||||||
|
GridLayout:
|
||||||
|
size_hint: 1, None
|
||||||
|
cols: 2
|
||||||
|
Label:
|
||||||
|
text: 'Password'
|
||||||
|
height: '48dp'
|
||||||
|
TextInput:
|
||||||
|
id: text_input
|
||||||
|
password:True
|
||||||
|
|
||||||
|
Button:
|
||||||
|
size_hint_y: None
|
||||||
|
height: '48dp'
|
||||||
|
text: _('Close')
|
||||||
|
on_release: pw.dismiss()
|
||||||
|
|
||||||
|
Widget:
|
||||||
|
size_hint_y: 1
|
|
@ -5,17 +5,26 @@ Popup:
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
|
|
||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
size_hint_y: None
|
size_hint: 1, None
|
||||||
|
|
||||||
GridLayout:
|
GridLayout:
|
||||||
cols: 2
|
cols: 2
|
||||||
Label:
|
Label:
|
||||||
text: _('Base unit')
|
text: _('Base unit')
|
||||||
height: '48dp'
|
height: '48dp'
|
||||||
|
size_hint: 1, None
|
||||||
Spinner:
|
Spinner:
|
||||||
text: 'BTC'
|
text: 'BTC'
|
||||||
values: ('BTC', 'mBTC')
|
values: ('BTC', 'mBTC')
|
||||||
height: '48dp'
|
height: '48dp'
|
||||||
|
|
||||||
|
Label:
|
||||||
|
size_hint: 1, None
|
||||||
|
text: 'OpenAlias'
|
||||||
|
height: '48dp'
|
||||||
|
TextInput:
|
||||||
|
size_hint: 1, None
|
||||||
|
|
||||||
|
|
||||||
Button:
|
Button:
|
||||||
#size_hint_y: None
|
#size_hint_y: None
|
||||||
|
|
Loading…
Add table
Reference in a new issue