Skip to content

Commit

Permalink
Upgrade to bdkpython 0.32.0 (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasgriffin authored Jan 1, 2025
1 parent b68f0ac commit 9cdeebc
Show file tree
Hide file tree
Showing 41 changed files with 293 additions and 203 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ repos:
- types-Pillow
- types-reportlab
- pyqt6
- bdkpython
- "bdkpython==0.32.0"

- repo: local
hooks:
Expand Down
2 changes: 1 addition & 1 deletion bitcoin_safe/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# all import must be absolute, because this is the entry script for pyinstaller
from bitcoin_safe.dynamic_lib_load import ensure_pyzbar_works

# this setsup the logging
# setup the logging
from bitcoin_safe.logging_setup import setup_logging # type: ignore

ensure_pyzbar_works()
Expand Down
38 changes: 14 additions & 24 deletions bitcoin_safe/dynamic_lib_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
import platform
import sys
from ctypes.util import find_library
from importlib.metadata import PackageMetadata
from pathlib import Path
from typing import Optional

import bitcoin_usb
import bitcointx
Expand All @@ -48,12 +46,14 @@


# Function to show the warning dialog before starting the QApplication
def show_message_before_quit(msg: str) -> None:
# Initialize QApplication first
app = QApplication(sys.argv)
# Without an application instance, some features might not work as expected
QMessageBox.warning(None, "Warning", msg, QMessageBox.StandardButton.Ok) # type: ignore[arg-type]
sys.exit(app.exec())
def show_warning_before_failiure(msg: str) -> None:
# Initialize QApplication if not already running
# the variable app, MUST be here, otherwise the QApplication will not be created
app = QApplication.instance() or QApplication(sys.argv)

# Show the warning dialog
QMessageBox().warning(None, "Warning", msg, QMessageBox.StandardButton.Ok)
app.quit()


def get_libsecp256k1_os_path() -> str | None:
Expand Down Expand Up @@ -122,7 +122,11 @@ def setup_libsecp256k1() -> None:
elif get_libsecp256k1_os_path():
logger.info(f"libsecp256k1 was found in the OS")
else:
logger.info(f"libsecp256k1 could not be found.")
msg = translate(
"dynamic_lib_load", "libsecp256k1 could not be found. Please install libsecp256k1 in your OS."
)
logger.info(msg)
show_warning_before_failiure(msg)


def ensure_pyzbar_works() -> None:
Expand All @@ -138,7 +142,7 @@ def ensure_pyzbar_works() -> None:
logger.info(f"pyzbar successfully loaded ")
except: # Do not restrict it to FileNotFoundError, because it can cause other exceptions
logger.info(f"pyzbar not loaded ")
show_message_before_quit(
show_warning_before_failiure(
translate("lib_load", """You are missing the {link}\nPlease install it.""").format(
link=link(
"https://www.microsoft.com/en-US/download/details.aspx?id=40784",
Expand All @@ -150,17 +154,3 @@ def ensure_pyzbar_works() -> None:
else:
# On Linux this shoudn't be a problem, because I include libzar in the package
pass


def get_briefcase_meta_data() -> Optional[PackageMetadata]:
import sys
from importlib import metadata as importlib_metadata

# Find the name of the module that was used to start the app
app_module = sys.modules["__main__"].__package__
if not app_module:
return None
# Retrieve the app's metadata
metadata = importlib_metadata.metadata(app_module)

return metadata
Binary file modified bitcoin_safe/gui/locales/app_ar_AE.qm
Binary file not shown.
8 changes: 4 additions & 4 deletions bitcoin_safe/gui/locales/app_ar_AE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,8 +846,8 @@ the sending value {sent}</source>
<translation>استيراد</translation>
</message>
<message>
<source>Manual</source>
<translation>يدوي</translation>
<source>Advanced</source>
<translation>متقدم</translation>
</message>
<message>
<source>Description</source>
Expand Down Expand Up @@ -1383,8 +1383,8 @@ Location of signing device: .....</source>
<context>
<name>NetworkSettingsUI</name>
<message>
<source>Manual</source>
<translation>يدوي</translation>
<source>Advanced</source>
<translation>متقدم</translation>
</message>
<message>
<source>Mode:</source>
Expand Down
Binary file modified bitcoin_safe/gui/locales/app_de_DE.qm
Binary file not shown.
8 changes: 4 additions & 4 deletions bitcoin_safe/gui/locales/app_de_DE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,8 +846,8 @@ the sending value {sent}</source>
<translation>Importieren</translation>
</message>
<message>
<source>Manual</source>
<translation>Handbuch </translation>
<source>Advanced</source>
<translation>Erweitert </translation>
</message>
<message>
<source>Description</source>
Expand Down Expand Up @@ -1383,8 +1383,8 @@ Location of signing device: .....</source>
<context>
<name>NetworkSettingsUI</name>
<message>
<source>Manual</source>
<translation>Handbuch </translation>
<source>Advanced</source>
<translation>Erweitert </translation>
</message>
<message>
<source>Mode:</source>
Expand Down
Binary file modified bitcoin_safe/gui/locales/app_es_ES.qm
Binary file not shown.
8 changes: 4 additions & 4 deletions bitcoin_safe/gui/locales/app_es_ES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,8 +846,8 @@ the sending value {sent}</source>
<translation>Importar</translation>
</message>
<message>
<source>Manual</source>
<translation>Manual</translation>
<source>Advanced</source>
<translation>Avanzado</translation>
</message>
<message>
<source>Description</source>
Expand Down Expand Up @@ -1383,8 +1383,8 @@ Location of signing device: .....</source>
<context>
<name>NetworkSettingsUI</name>
<message>
<source>Manual</source>
<translation>Manual</translation>
<source>Advanced</source>
<translation>Avanzado</translation>
</message>
<message>
<source>Mode:</source>
Expand Down
Binary file modified bitcoin_safe/gui/locales/app_fr_FR.qm
Binary file not shown.
8 changes: 4 additions & 4 deletions bitcoin_safe/gui/locales/app_fr_FR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,8 +846,8 @@ the sending value {sent}</source>
<translation>Importer </translation>
</message>
<message>
<source>Manual</source>
<translation>Manuel </translation>
<source>Advanced</source>
<translation>Avancé </translation>
</message>
<message>
<source>Description</source>
Expand Down Expand Up @@ -1383,8 +1383,8 @@ Location of signing device: .....</source>
<context>
<name>NetworkSettingsUI</name>
<message>
<source>Manual</source>
<translation>Manuel </translation>
<source>Advanced</source>
<translation>Avancé </translation>
</message>
<message>
<source>Mode:</source>
Expand Down
Binary file modified bitcoin_safe/gui/locales/app_hi_IN.qm
Binary file not shown.
8 changes: 4 additions & 4 deletions bitcoin_safe/gui/locales/app_hi_IN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,8 +846,8 @@ the sending value {sent}</source>
<translation>आयात करें</translation>
</message>
<message>
<source>Manual</source>
<translation>मैनुअल</translation>
<source>Advanced</source>
<translation>उन्नत</translation>
</message>
<message>
<source>Description</source>
Expand Down Expand Up @@ -1383,8 +1383,8 @@ Location of signing device: .....</source>
<context>
<name>NetworkSettingsUI</name>
<message>
<source>Manual</source>
<translation>मैनुअल</translation>
<source>Advanced</source>
<translation>उन्नत</translation>
</message>
<message>
<source>Mode:</source>
Expand Down
Binary file modified bitcoin_safe/gui/locales/app_it_IT.qm
Binary file not shown.
8 changes: 4 additions & 4 deletions bitcoin_safe/gui/locales/app_it_IT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,8 +846,8 @@ the sending value {sent}</source>
<translation>Importa</translation>
</message>
<message>
<source>Manual</source>
<translation>Manuale</translation>
<source>Advanced</source>
<translation>Avanzato</translation>
</message>
<message>
<source>Description</source>
Expand Down Expand Up @@ -1383,8 +1383,8 @@ Location of signing device: .....</source>
<context>
<name>NetworkSettingsUI</name>
<message>
<source>Manual</source>
<translation>Manuale</translation>
<source>Advanced</source>
<translation>Avanzato</translation>
</message>
<message>
<source>Mode:</source>
Expand Down
Binary file modified bitcoin_safe/gui/locales/app_ja_JP.qm
Binary file not shown.
8 changes: 4 additions & 4 deletions bitcoin_safe/gui/locales/app_ja_JP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,8 +846,8 @@ the sending value {sent}</source>
<translation>手動</translation>
</message>
<message>
<source>Manual</source>
<translation>説明</translation>
<source>Advanced</source>
<translation>詳細</translation>
</message>
<message>
<source>Description</source>
Expand Down Expand Up @@ -1383,8 +1383,8 @@ Location of signing device: .....</source>
<context>
<name>NetworkSettingsUI</name>
<message>
<source>Manual</source>
<translation>適用して再起動</translation>
<source>Advanced</source>
<translation>詳細</translation>
</message>
<message>
<source>Mode:</source>
Expand Down
Binary file modified bitcoin_safe/gui/locales/app_pt_PT.qm
Binary file not shown.
8 changes: 4 additions & 4 deletions bitcoin_safe/gui/locales/app_pt_PT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,8 +846,8 @@ the sending value {sent}</source>
<translation>Importar</translation>
</message>
<message>
<source>Manual</source>
<translation>Manual</translation>
<source>Advanced</source>
<translation>Avançado</translation>
</message>
<message>
<source>Description</source>
Expand Down Expand Up @@ -1383,8 +1383,8 @@ Location of signing device: .....</source>
<context>
<name>NetworkSettingsUI</name>
<message>
<source>Manual</source>
<translation>Manual</translation>
<source>Advanced</source>
<translation>Avançado</translation>
</message>
<message>
<source>Mode:</source>
Expand Down
Binary file modified bitcoin_safe/gui/locales/app_ru_RU.qm
Binary file not shown.
8 changes: 4 additions & 4 deletions bitcoin_safe/gui/locales/app_ru_RU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,8 +846,8 @@ the sending value {sent}</source>
<translation>Импорт</translation>
</message>
<message>
<source>Manual</source>
<translation>Ручной</translation>
<source>Advanced</source>
<translation>Расширенные</translation>
</message>
<message>
<source>Description</source>
Expand Down Expand Up @@ -1383,8 +1383,8 @@ Location of signing device: .....</source>
<context>
<name>NetworkSettingsUI</name>
<message>
<source>Manual</source>
<translation>Ручной</translation>
<source>Advanced</source>
<translation>Расширенные</translation>
</message>
<message>
<source>Mode:</source>
Expand Down
Binary file modified bitcoin_safe/gui/locales/app_zh_CN.qm
Binary file not shown.
8 changes: 4 additions & 4 deletions bitcoin_safe/gui/locales/app_zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,8 +846,8 @@ the sending value {sent}</source>
<translation>导入</translation>
</message>
<message>
<source>Manual</source>
<translation>手动</translation>
<source>Advanced</source>
<translation>高级</translation>
</message>
<message>
<source>Description</source>
Expand Down Expand Up @@ -1384,8 +1384,8 @@ Location of signing device: .....</source>
<context>
<name>NetworkSettingsUI</name>
<message>
<source>Manual</source>
<translation>手动</translation>
<source>Advanced</source>
<translation>高级</translation>
</message>
<message>
<source>Mode:</source>
Expand Down
2 changes: 1 addition & 1 deletion bitcoin_safe/gui/qt/keystore_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ def updateUi(self) -> None:
)

self.tabs_import_type.setTabText(self.tabs_import_type.indexOf(self.tab_import), self.tr("Import"))
self.tabs_import_type.setTabText(self.tabs_import_type.indexOf(self.tab_manual), self.tr("Manual"))
self.tabs_import_type.setTabText(self.tabs_import_type.indexOf(self.tab_manual), self.tr("Advanced"))
self.label_description.setText(self.tr("Description"))

self.label_fingerprint.setText(self.tr("Fingerprint"))
Expand Down
13 changes: 6 additions & 7 deletions bitcoin_safe/gui/qt/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
QDialog,
QFileDialog,
QMainWindow,
QScrollArea,
QSizePolicy,
QStyle,
QSystemTrayIcon,
Expand Down Expand Up @@ -142,7 +141,7 @@ def __init__(
self.language_chooser.set_language(self.config.language_code)
self.hwi_tool_gui = ToolGui(self.config.network)
self.hwi_tool_gui.setWindowIcon(read_QIcon("logo.svg"))
self.setupUi(self)
self.setupUi()

self.mempool_data = MempoolData(
network_config=self.config.network_config,
Expand Down Expand Up @@ -247,17 +246,17 @@ def set_title(self) -> None:
title += f" - {qt_wallet.wallet.id}"
self.setWindowTitle(title)

def setupUi(self, MainWindow: QWidget) -> None:
def setupUi(self) -> None:
logger.debug(f"start setupUi")
# sizePolicy = QSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Preferred)
# sizePolicy.setHorizontalStretch(0)
# sizePolicy.setVerticalStretch(0)
# sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth())
# MainWindow.setSizePolicy(sizePolicy)
MainWindow.setWindowIcon(read_QIcon("logo.svg"))
self.setWindowIcon(read_QIcon("logo.svg"))
w, h = 900, 600
MainWindow.resize(w, h)
MainWindow.setMinimumSize(w, h)
self.resize(w, h)
self.setMinimumSize(w, h)

#####
self.tab_wallets = ExtendedTabWidget(
Expand All @@ -274,7 +273,7 @@ def setupUi(self, MainWindow: QWidget) -> None:
self.tab_wallets.currentChanged.connect(self.set_title)

# central_widget
central_widget = QScrollArea()
central_widget = QWidget(self)
vbox = QVBoxLayout(central_widget)
vbox.setSpacing(0)
vbox.setContentsMargins(0, 0, 0, 0) # Left, Top, Right, Bottom margins
Expand Down
2 changes: 1 addition & 1 deletion bitcoin_safe/gui/qt/network_settings/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def __init__(
)

self.cbf_server_typeComboBox = QComboBox(self.compactBlockFiltersTab)
self.cbf_server_typeComboBox.addItem(self.tr("Manual"), CBFServerType.Manual)
self.cbf_server_typeComboBox.addItem(self.tr("Advanced"), CBFServerType.Manual)
self.cbf_server_typeComboBox.addItem(self.tr("Automatic"), CBFServerType.Automatic)
self.cbf_server_typeComboBox.setCurrentIndex(1)

Expand Down
Loading

0 comments on commit 9cdeebc

Please sign in to comment.