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 Sep 18, 2024
2 parents 57ba4f5 + ba3935c commit d15d633
Show file tree
Hide file tree
Showing 29 changed files with 176 additions and 179 deletions.
4 changes: 2 additions & 2 deletions contrib/deterministic-build/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ protobuf==3.20.3 \
--hash=sha256:2e3427429c9cffebf259491be0af70189607f365c2f41c7c3764af6f337105f2
python-socks==2.4.4 \
--hash=sha256:e5a8e4f78203612c813946feacd87b98943965a04389fe221fa1e9ab263ad22e
QDarkStyle==3.1 \
--hash=sha256:600584d625343e0ddd128de08393d3c35637786a49827f174d29aa7caa8279c1
QDarkStyle==3.2.3 \
--hash=sha256:0c0b7f74a6e92121008992b369bab60468157db1c02cd30d64a5e9a3b402f1ae
qrcode==7.3.1 \
--hash=sha256:375a6ff240ca9bd41adc070428b5dfc1dcfbb0f2507f1ac848f6cded38956578
QtPy==2.4.1 \
Expand Down
1 change: 1 addition & 0 deletions electrum_grs/checkpoints_testnet4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions electrum_grs/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,7 @@ def add_global_options(parser):
group.add_argument("-D", "--dir", dest="electrum_path", help="electrum-grs directory")
group.add_argument("-P", "--portable", action="store_true", dest="portable", default=False, help="Use local 'electrum-grs_data' directory")
group.add_argument("--testnet", action="store_true", dest="testnet", default=False, help="Use Testnet")
group.add_argument("--testnet4", action="store_true", dest="testnet4", default=False, help="Use Testnet4")
group.add_argument("--regtest", action="store_true", dest="regtest", default=False, help="Use Regtest")
group.add_argument("--simnet", action="store_true", dest="simnet", default=False, help="Use Simnet")
group.add_argument("--signet", action="store_true", dest="signet", default=False, help="Use Signet")
Expand Down
34 changes: 14 additions & 20 deletions electrum_grs/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ def max_checkpoint(cls) -> int:
def rev_genesis_bytes(cls) -> bytes:
return bytes.fromhex(cls.GENESIS)[::-1]

@classmethod
def set_as_network(cls) -> None:
global net
net = cls


class BitcoinMainnet(AbstractNet):

Expand Down Expand Up @@ -153,6 +158,15 @@ class BitcoinTestnet(AbstractNet):
]


class BitcoinTestnet4(BitcoinTestnet):

NET_NAME = "testnet4"
GENESIS = "00000000da84f2bafbbc53dee25a72ae507ff4914b867c565be350b0da8bf043"
DEFAULT_SERVERS = read_json('servers_testnet4.json', {})
CHECKPOINTS = read_json('checkpoints_testnet4.json', [])
LN_DNS_SEEDS = []


class BitcoinRegtest(BitcoinTestnet):

NET_NAME = "regtest"
Expand Down Expand Up @@ -192,23 +206,3 @@ class BitcoinSignet(BitcoinTestnet):

# don't import net directly, import the module instead (so that net is singleton)
net = BitcoinMainnet # type: Type[AbstractNet]

def set_signet():
global net
net = BitcoinSignet

def set_simnet():
global net
net = BitcoinSimnet

def set_mainnet():
global net
net = BitcoinMainnet

def set_testnet():
global net
net = BitcoinTestnet

def set_regtest():
global net
net = BitcoinRegtest
9 changes: 6 additions & 3 deletions electrum_grs/gui/qml/components/controls/HelpDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,28 @@ ElDialog {

ColumnLayout {
id: rootLayout
width: dialog.parent.width * 2/3
width: dialog.parent.width * 3/4
spacing: constants.paddingLarge

RowLayout {
Layout.fillWidth: true
Image {
source: Qt.resolvedUrl('../../../icons/info.png')
Layout.preferredWidth: constants.iconSizeSmall
Layout.preferredHeight: constants.iconSizeSmall
}
Label {
text: dialog.heading
font.pixelSize: constants.fontSizeMedium
font.underline: true
font.italic: true
}
}
TextArea {
Label {
id: message
Layout.fillWidth: true
readOnly: true
text: dialog.text
font.pixelSize: constants.fontSizeSmall
wrapMode: TextInput.WordWrap
textFormat: TextEdit.RichText
background: Rectangle {
Expand Down
22 changes: 3 additions & 19 deletions electrum_grs/gui/qt/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from functools import partial
import queue
import asyncio
from typing import Optional, TYPE_CHECKING, Sequence, List, Union, Dict, Set, Mapping
from typing import Optional, TYPE_CHECKING, Sequence, Union, Dict, Mapping
import concurrent.futures

from PyQt5.QtGui import QPixmap, QKeySequence, QIcon, QCursor, QFont, QFontMetrics
Expand All @@ -45,7 +45,7 @@
QHBoxLayout, QPushButton, QScrollArea, QTextEdit,
QShortcut, QMainWindow, QInputDialog,
QWidget, QSizePolicy, QStatusBar, QToolTip,
QMenu, QAction, QStackedWidget, QToolButton)
QMenu, QAction, QToolButton)

import electrum_grs
from electrum_grs.gui import messages
Expand Down Expand Up @@ -82,7 +82,7 @@
from .transaction_dialog import show_transaction
from .fee_slider import FeeSlider, FeeComboBox
from .util import (read_QIcon, ColorScheme, text_dialog, icon_path, WaitingDialog,
WindowModalDialog, ChoicesLayout, HelpLabel, Buttons,
WindowModalDialog, HelpLabel, Buttons,
OkButton, InfoButton, WWLabel, TaskThread, CancelButton,
CloseButton, HelpButton, MessageBoxMixin, EnterButton,
import_meta_gui, export_meta_gui,
Expand Down Expand Up @@ -1370,22 +1370,6 @@ def on_open_channel_success(self, args):
else:
self.show_message(message)

def query_choice(self, msg, choices, title=None, default_choice=None):
# Needed by QtHandler for hardware wallets
if title is None:
title = _('Question')
dialog = WindowModalDialog(self.top_level_window(), title=title)
dialog.setMinimumWidth(400)
clayout = ChoicesLayout(msg, choices, checked_index=default_choice)
vbox = QVBoxLayout(dialog)
vbox.addLayout(clayout.layout())
cancel_button = CancelButton(dialog)
vbox.addLayout(Buttons(cancel_button, OkButton(dialog)))
cancel_button.setFocus()
if not dialog.exec_():
return None
return clayout.selected_index()

def handle_payment_identifier(self, text: str):
pi = PaymentIdentifier(self.wallet, text)
if pi.is_valid():
Expand Down
3 changes: 2 additions & 1 deletion electrum_grs/gui/qt/receive_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ def expiry_dialog(self):
_('For Lightning requests, payments will not be accepted after the expiration.'),
])
expiry = self.config.WALLET_PAYREQ_EXPIRY_SECONDS
v = self.window.query_choice(msg, pr_expiration_values(), title=_('Expiry'), default_choice=expiry)
choices = list(pr_expiration_values().items())
v = self.window.query_choice(msg, choices, title=_('Expiry'), default_choice=expiry)
if v is None:
return
self.config.WALLET_PAYREQ_EXPIRY_SECONDS = v
Expand Down
18 changes: 8 additions & 10 deletions electrum_grs/gui/qt/seed_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
from electrum_grs import slip39

from .util import (Buttons, OkButton, WWLabel, ButtonsTextEdit, icon_path,
EnterButton, CloseButton, WindowModalDialog, ColorScheme,
ChoicesLayout, font_height)
EnterButton, CloseButton, WindowModalDialog, ColorScheme, font_height, ChoiceWidget)
from .qrtextedit import ShowQRTextEdit, ScanQRTextEdit
from .completion_text_edit import CompletionTextEdit

Expand Down Expand Up @@ -87,15 +86,15 @@ def seed_options(self):
)
if value in self.options or value == 'electrum'
]
seed_type_values = [t[0] for t in seed_types]

if 'ext' in self.options:
cb_ext = QCheckBox(_('Extend this seed with custom words'))
cb_ext.setChecked(self.is_ext)
vbox.addWidget(cb_ext)

if len(seed_types) >= 2:
def f(choices_layout):
self.seed_type = seed_type_values[choices_layout.selected_index()]
def on_selected(idx):
self.seed_type = seed_type_choice.selected_key
self.is_seed = (lambda x: bool(x)) if self.seed_type != 'electrum' else self.saved_is_seed
self.slip39_current_mnemonic_invalid = None
self.seed_status.setText('')
Expand All @@ -120,16 +119,15 @@ def f(choices_layout):
self.initialize_completer()
self.seed_warning.setText(msg)

checked_index = seed_type_values.index(self.seed_type)
titles = [t[1] for t in seed_types]
clayout = ChoicesLayout(_('Seed type'), titles, on_clicked=f, checked_index=checked_index)
vbox.addLayout(clayout.layout())
seed_type_choice = ChoiceWidget(message=_('Seed type'), choices=seed_types, selected=self.seed_type)
seed_type_choice.itemSelected.connect(on_selected)
vbox.addWidget(seed_type_choice)

vbox.addLayout(Buttons(OkButton(dialog)))
if not dialog.exec_():
return None
self.is_ext = cb_ext.isChecked() if 'ext' in self.options else False
self.seed_type = seed_type_values[clayout.selected_index()] if len(seed_types) >= 2 else 'electrum'
self.seed_type = seed_type_choice.selected_key if len(seed_types) >= 2 else 'electrum'
self.updated.emit()

def __init__(
Expand Down
18 changes: 9 additions & 9 deletions electrum_grs/gui/qt/send_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,31 +672,31 @@ def pay_lightning_invoice(self, invoice: Invoice):
can_pay_with_swap = lnworker.suggest_swap_to_send(amount_sat, coins=coins)
rebalance_suggestion = lnworker.suggest_rebalance_to_send(amount_sat)
can_rebalance = bool(rebalance_suggestion) and self.window.num_tasks() == 0
choices = {}
choices = []
if can_rebalance:
msg = ''.join([
_('Rebalance existing channels'), '\n',
_('Move funds between your channels in order to increase your sending capacity.')
])
choices[0] = msg
choices.append(('rebalance', msg))
if can_pay_with_new_channel:
msg = ''.join([
_('Open a new channel'), '\n',
_('You will be able to pay once the channel is open.')
])
choices[1] = msg
choices.append(('new_channel', msg))
if can_pay_with_swap:
msg = ''.join([
_('Swap onchain funds for lightning funds'), '\n',
_('You will be able to pay once the swap is confirmed.')
])
choices[2] = msg
choices.append(('swap', msg))
if can_pay_onchain:
msg = ''.join([
_('Pay onchain'), '\n',
_('Funds will be sent to the invoice fallback address.')
])
choices[3] = msg
choices.append(('onchain', msg))
msg = _('You cannot pay that invoice using Lightning.')
if lnworker and lnworker.channels:
num_sats_can_send = int(lnworker.num_sats_can_send())
Expand All @@ -709,16 +709,16 @@ def pay_lightning_invoice(self, invoice: Invoice):
r = self.window.query_choice(msg, choices)
if r is not None:
self.save_pending_invoice()
if r == 0:
if r == 'rebalance':
chan1, chan2, delta = rebalance_suggestion
self.window.rebalance_dialog(chan1, chan2, amount_sat=delta)
elif r == 1:
elif r == 'new_channel':
amount_sat, min_amount_sat = can_pay_with_new_channel
self.window.new_channel_dialog(amount_sat=amount_sat, min_amount_sat=min_amount_sat)
elif r == 2:
elif r == 'swap':
chan, swap_recv_amount_sat = can_pay_with_swap
self.window.run_swap_dialog(is_reverse=False, recv_amount_sat=swap_recv_amount_sat, channels=[chan])
elif r == 3:
elif r == 'onchain':
self.pay_onchain_dialog(invoice.get_outputs(), nonlocal_only=True)
return

Expand Down
Loading

0 comments on commit d15d633

Please sign in to comment.