Skip to content

Commit

Permalink
Merge remote-tracking branch 'electrum/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
lateminer committed Jan 6, 2024
2 parents f7001b7 + f7ea2e0 commit 68692ba
Show file tree
Hide file tree
Showing 14 changed files with 116 additions and 147 deletions.
3 changes: 3 additions & 0 deletions electrum_blk/bip21.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def parse_bip21_URI(uri: str) -> dict:
for k, v in pq.items():
if len(v) != 1:
raise InvalidBitcoinURI(f'Duplicate Key: {repr(k)}')
if k.startswith('req-'):
# we have no support for any req-* query parameters
raise InvalidBitcoinURI(f'Unsupported Key: {repr(k)}')

out = {k: v[0] for k, v in pq.items()}
if address:
Expand Down
5 changes: 3 additions & 2 deletions electrum_blk/gui/qml/components/controls/FormattedAmount.qml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ GridLayout {
if (historic && timestamp)
fiatLabel.text = '(' + Daemon.fx.fiatValueHistoric(amount, timestamp) + ' ' + Daemon.fx.fiatCurrency + ')'
else
fiatLabel.text = '(' + Daemon.fx.fiatValue(amount) + ' ' + Daemon.fx.fiatCurrency + ')'

fiatLabel.text = Daemon.fx.isRecent(timestamp)
? '(' + Daemon.fx.fiatValue(amount) + ' ' + Daemon.fx.fiatCurrency + ')'
: ''
}

onAmountChanged: setFiatValue()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,14 @@ Item {
function updateText() {
if (!Daemon.fx.enabled) {
text = ''
} else if (Daemon.fx.historicRates) {
} else if (Daemon.fx.historicRates && model.timestamp) {
text = Daemon.fx.fiatValueHistoric(model.value, model.timestamp) + ' ' + Daemon.fx.fiatCurrency
} else {
text = Daemon.fx.fiatValue(model.value, false) + ' ' + Daemon.fx.fiatCurrency
if (Daemon.fx.isRecent(model.timestamp)) {
text = Daemon.fx.fiatValue(model.value, false) + ' ' + Daemon.fx.fiatCurrency
} else {
text = ''
}
}
}
Component.onCompleted: updateText()
Expand Down
14 changes: 13 additions & 1 deletion electrum_blk/gui/qml/qefx.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
from datetime import datetime, timedelta
from decimal import Decimal

from PyQt6.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject, QRegularExpression
Expand Down Expand Up @@ -164,3 +164,15 @@ def satoshiValue(self, fiat, plain=True):
return str(v.to_integral_value())
else:
return self.config.format_amount(v)

@pyqtSlot(str, result=bool)
def isRecent(self, timestamp):
# return True if unknown, e.g. timestamp not known yet, tx in mempool
try:
td = Decimal(timestamp)
if td == 0:
return True
except Exception:
return True
dt = datetime.fromtimestamp(int(td))
return dt + timedelta(days=1) > datetime.today()
5 changes: 3 additions & 2 deletions electrum_blk/gui/qml/qetxdetails.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,10 @@ def onBroadcastFailed(self, txid, code, reason):

@pyqtSlot()
@pyqtSlot(bool)
def removeLocalTx(self, confirm = False):
assert self._can_remove
def removeLocalTx(self, confirm=False):
assert self._can_remove, 'cannot remove'
txid = self._txid
assert txid, 'txid unset'

if not confirm:
num_child_txs = len(self._wallet.wallet.adb.get_depending_transactions(txid))
Expand Down
3 changes: 2 additions & 1 deletion electrum_blk/gui/qt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,12 +451,13 @@ def _start_wizard_to_select_or_create_wallet(self, path) -> Optional[Abstract_Wa
xprv = k1.get_master_private_key(d['password'])
else:
xprv = db.get('x1')['xprv']
data = {
_wiz_data_updates = {
'wallet_name': os.path.basename(wallet_file),
'xprv1': xprv,
'xpub1': db.get('x1')['xpub'],
'xpub2': db.get('x2')['xpub'],
}
data = {**d, **_wiz_data_updates}
wizard = QENewWalletWizard(self.config, self.app, self.plugins, self.daemon, path,
start_viewstate=WizardViewState('trustedcoin_tos', data, {}))
result = wizard.exec()
Expand Down
8 changes: 6 additions & 2 deletions electrum_blk/gui/qt/seed_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
QScrollArea, QWidget, QPushButton)

from electrum_blk.i18n import _
from electrum_blk.mnemonic import Mnemonic, seed_type
from electrum_blk.mnemonic import Mnemonic, seed_type, is_any_2fa_seed_type
from electrum_blk import old_mnemonic
from electrum_blk import slip39

Expand Down Expand Up @@ -295,10 +295,14 @@ def on_edit(self):
t = seed_type(s)
label = _('Seed Type') + ': ' + t if t else ''
if t and not b: # electrum seed, but does not conform to dialog rules
# FIXME we should just accept any electrum seed and "redirect" the wizard automatically.
# i.e. if user selected wallet_type=="standard" but entered a 2fa seed, accept and redirect
# if user selected wallet_type=="2fa" but entered a std electrum seed, accept and redirect
wiztype_fullname = _('Wallet with two-factor authentication') if is_any_2fa_seed_type(t) else _("Standard wallet")
msg = ' '.join([
'<b>' + _('Warning') + ':</b> ',
_("Looks like you have entered a valid seed of type '{}' but this dialog does not support such seeds.").format(t),
_("If unsure, try restoring as '{}'.").format(_("Standard wallet")),
_("If unsure, try restoring as '{}'.").format(wiztype_fullname),
])
self.seed_warning.setText(msg)
else:
Expand Down
7 changes: 7 additions & 0 deletions electrum_blk/gui/qt/util.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from abc import ABC, ABCMeta
import os.path
import time
import sys
Expand Down Expand Up @@ -1430,6 +1431,12 @@ def decorator(self, *args):
return decorator


class _ABCQObjectMeta(type(QObject), ABCMeta): pass
class _ABCQWidgetMeta(type(QWidget), ABCMeta): pass
class AbstractQObject(QObject, ABC, metaclass=_ABCQObjectMeta): pass
class AbstractQWidget(QWidget, ABC, metaclass=_ABCQWidgetMeta): pass


if __name__ == "__main__":
app = QApplication([])
t = WaitingDialog(None, 'testing ...', lambda: [time.sleep(1)], lambda x: QMessageBox.information(None, 'done', "done"))
Expand Down
Loading

0 comments on commit 68692ba

Please sign in to comment.