Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gruve-p committed Oct 6, 2023
2 parents 6aff83e + cbcafe8 commit 297f7e4
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 57 deletions.
35 changes: 11 additions & 24 deletions electrum_grs/gui/qml/components/OpenWalletDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ElDialog {
property string name
property string path

property bool _invalidPassword: false
property bool _unlockClicked: false

title: qsTr('Open Wallet')
Expand All @@ -38,17 +39,15 @@ ElDialog {

InfoTextArea {
id: notice
text: Daemon.singlePasswordEnabled
text: Daemon.singlePasswordEnabled || !Daemon.currentWallet
? qsTr('Please enter password')
: qsTr('Wallet <b>%1</b> requires password to unlock').arg(name)
visible: wallet_db.needsPassword
iconStyle: InfoTextArea.IconStyle.Warn
Layout.fillWidth: true
}

Label {
text: qsTr('Password')
visible: wallet_db.needsPassword
Layout.fillWidth: true
color: Material.accentColor
}
Expand All @@ -57,7 +56,6 @@ ElDialog {
id: password
Layout.fillWidth: true
Layout.leftMargin: constants.paddingXLarge
visible: wallet_db.needsPassword

onTextChanged: {
unlockButton.enabled = true
Expand All @@ -70,7 +68,7 @@ ElDialog {

Label {
Layout.alignment: Qt.AlignHCenter
text: !wallet_db.validPassword && _unlockClicked ? qsTr("Invalid Password") : ''
text: _invalidPassword && _unlockClicked ? qsTr("Invalid Password") : ''
color: constants.colorError
font.pixelSize: constants.fontSizeLarge
}
Expand All @@ -79,7 +77,6 @@ ElDialog {
FlatButton {
id: unlockButton
Layout.fillWidth: true
visible: wallet_db.needsPassword
icon.source: '../../icons/unlock.png'
text: qsTr("Unlock")
onClicked: {
Expand All @@ -92,32 +89,22 @@ ElDialog {
function unlock() {
unlockButton.enabled = false
_unlockClicked = true
wallet_db.password = password.text
wallet_db.verify()
Daemon.loadWallet(openwalletdialog.path, password.text)
}

WalletDB {
id: wallet_db
path: openwalletdialog.path
onReadyChanged: {
if (ready) {
Daemon.loadWallet(openwalletdialog.path, password.text)
openwalletdialog.close()
}
}
onInvalidPassword: {
Connections {
target: Daemon
function onWalletRequiresPassword() {
console.log('invalid password')
_invalidPassword = true
password.tf.forceActiveFocus()
}
onNeedsPasswordChanged: {
notice.visible = needsPassword
}
onWalletOpenProblem: {
function onWalletLoaded() {
openwalletdialog.close()
Daemon.onWalletOpenProblem(error)
}
}

Component.onCompleted: {
wallet_db.verify()
password.tf.forceActiveFocus()
}
}
19 changes: 10 additions & 9 deletions electrum_grs/gui/qml/components/controls/ServerConfig.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import QtQuick.Controls.Material 2.0

import org.electrum 1.0


Item {
id: root

property bool showAutoselectServer: true
property alias auto_connect: auto_server_cb.checked
property alias address: address_tf.text

Expand All @@ -22,27 +24,26 @@ Item {

CheckBox {
id: auto_server_cb
visible: showAutoselectServer
text: qsTr('Select server automatically')
checked: true
}

GridLayout {
columns: 2
Layout.fillWidth: true
Label {
text: qsTr("Server")
enabled: address_tf.enabled
}

Label {
text: qsTr("Server")
enabled: address_tf.enabled
}
TextHighlightPane {
Layout.fillWidth: true

TextField {
id: address_tf
enabled: !auto_server_cb.checked
Layout.fillWidth: true
width: parent.width
}
}


ColumnLayout {
Heading {
text: qsTr('Servers')
Expand Down
11 changes: 9 additions & 2 deletions electrum_grs/gui/qml/components/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -496,12 +496,19 @@ ApplicationWindow
}
}

property var _opendialog: undefined

Connections {
target: Daemon
function onWalletRequiresPassword(name, path) {
console.log('wallet requires password')
var dialog = openWalletDialog.createObject(app, { path: path, name: name })
dialog.open()
if (_opendialog == undefined) {
_opendialog = openWalletDialog.createObject(app, { path: path, name: name })
_opendialog.closed.connect(function() {
_opendialog = undefined
})
_opendialog.open()
}
}
function onWalletOpenError(error) {
console.log('wallet open error')
Expand Down
1 change: 1 addition & 0 deletions electrum_grs/gui/qml/components/wizard/WCAutoConnect.qml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import QtQuick 2.15
import QtQuick.Layouts 1.0
import QtQuick.Controls 2.1

Expand Down
4 changes: 0 additions & 4 deletions electrum_grs/gui/qml/components/wizard/WCProxyConfig.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ WizardComponent {
width: parent.width
spacing: constants.paddingLarge

Label {
text: qsTr('Proxy settings')
}

ProxyConfig {
id: pc
Layout.fillWidth: true
Expand Down
9 changes: 3 additions & 6 deletions electrum_grs/gui/qml/components/wizard/WCServerConfig.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,18 @@ WizardComponent {
last: true

function apply() {
wizard_data['autoconnect'] = sc.auto_connect
wizard_data['autoconnect'] = false
wizard_data['server'] = sc.address
}

ColumnLayout {
anchors.fill: parent
spacing: constants.paddingLarge

Label {
text: qsTr('Server settings')
}

ServerConfig {
id: sc
width: parent.width
showAutoselectServer: false
Layout.fillWidth: true
Layout.fillHeight: true
}
}
Expand Down
3 changes: 3 additions & 0 deletions electrum_grs/gui/qt/utxo_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ def clipboard_contains_address(self):
return is_address(text)

def pay_to_clipboard_address(self, coins):
if not self.clipboard_contains_address():
self.main_window.show_error(_('Clipboard doesn\'t contain a valid address'))
return
addr = self.main_window.app.clipboard().text()
outputs = [PartialTxOutput.from_address_and_value(addr, '!')]
#self.clear_coincontrol()
Expand Down
14 changes: 9 additions & 5 deletions electrum_grs/lnworker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1013,10 +1013,8 @@ def get_lightning_history(self):
if swap:
if swap.is_reverse:
item['group_id'] = swap.spending_txid
item['group_label'] = 'Reverse swap' + ' ' + self.config.format_amount_and_units(swap.lightning_amount)
else:
item['group_id'] = swap.funding_txid
item['group_label'] = 'Forward swap' + ' ' + self.config.format_amount_and_units(swap.onchain_amount)
# done
out[payment_hash] = item
return out
Expand Down Expand Up @@ -1088,20 +1086,26 @@ def get_onchain_history(self):
direction, amount_msat, fee_msat, timestamp = self.get_payment_value(info, plist)
else:
amount_msat = 0
label = 'Reverse swap' if swap.is_reverse else 'Forward swap'

if swap.is_reverse:
group_label = 'Reverse swap' + ' ' + self.config.format_amount_and_units(swap.lightning_amount)
else:
group_label = 'Forward swap' + ' ' + self.config.format_amount_and_units(swap.onchain_amount)
self._labels_cache[txid] = group_label

label = _('Claim transaction') if swap.is_reverse else _('Funding transaction')
delta = current_height - swap.locktime
if self.wallet.adb.is_mine(swap.lockup_address):
tx_height = self.wallet.adb.get_tx_height(swap.funding_txid)
if swap.is_reverse and tx_height.height <= 0:
label += ' (%s)' % _('waiting for funding tx confirmation')
if not swap.is_reverse and not swap.is_redeemed and swap.spending_txid is None and delta < 0:
label += f' (refundable in {-delta} blocks)' # fixme: only if unspent
self._labels_cache[txid] = label
out[txid] = {
'group_id': txid,
'amount_msat': 0, # must be zero for onchain tx
'type': 'swap',
'label': _('Funding transaction'),
'label': label,
}
if not swap.is_reverse:
# if the spending_tx is in the wallet, this will add it
Expand Down
13 changes: 6 additions & 7 deletions electrum_grs/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1292,9 +1292,10 @@ def sort_key(x):
else:
key = 'group:' + group_id
parent = transactions.get(key)
label = self.get_label_for_txid(group_id)
if parent is None:
parent = {
'label': tx_item.get('group_label'),
'label': label,
'fiat_value': Fiat(Decimal(0), fx.ccy) if fx else None,
'bc_value': Satoshis(0),
'ln_value': Satoshis(0),
Expand Down Expand Up @@ -1527,24 +1528,22 @@ def get_label_for_txid(self, tx_hash: str) -> str:
return self._labels.get(tx_hash) or self._get_default_label_for_txid(tx_hash)

def _get_default_label_for_txid(self, tx_hash: str) -> str:
if self.lnworker and (label:= self.lnworker.get_label_for_txid(tx_hash)):
return label
labels = []
# note: we don't deserialize tx as the history calls us for every tx, and that would be slow
if not self.db.get_txi_addresses(tx_hash):
# no inputs are ismine -> likely incoming payment -> concat labels of output addresses
labels = []
for addr in self.db.get_txo_addresses(tx_hash):
label = self.get_label_for_address(addr)
if label:
labels.append(label)
return ', '.join(labels)
else:
# some inputs are ismine -> likely outgoing payment
labels = []
for invoice in self.get_relevant_invoices_for_tx(tx_hash):
if invoice.message:
labels.append(invoice.message)
return ', '.join(labels)
if not labels and self.lnworker and (label:= self.lnworker.get_label_for_txid(tx_hash)):
labels.append(label)
return ', '.join(labels)

def _get_default_label_for_rhash(self, rhash: str) -> str:
req = self.get_request(rhash)
Expand Down

0 comments on commit 297f7e4

Please sign in to comment.