这是indexloc提供的服务,不要输入任何密码
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
208 changes: 208 additions & 0 deletions packages/electrum/0001-termux-unset-all-android-checks.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
From f63d200b667ac3438816479e82a69b5825201e4c Mon Sep 17 00:00:00 2001
From: Henrik Grimler <henrik@grimler.se>
Date: Sun, 16 Feb 2025 20:48:02 +0100
Subject: [PATCH] termux: unset all android checks

Electrum expects android builds to be a "standard" java app. This will
not work in termux, as termux is more similar to a full linux
environment, so let's unset all the android checks.
---
electrum/ecc_fast.py | 2 +-
electrum/electrum | 2 +-
electrum/gui/default_lang.py | 2 +-
electrum/gui/qml/qeapp.py | 4 ++--
electrum/gui/qml/qeqrscanner.py | 6 +++---
electrum/logging.py | 2 +-
electrum/qrreader/zbar.py | 2 +-
electrum/simple_config.py | 2 +-
electrum/util.py | 8 ++++----
run_electrum | 2 +-
10 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/electrum/ecc_fast.py b/electrum/ecc_fast.py
index a27e2114961f..b88d9acf7dc2 100644
--- a/electrum/ecc_fast.py
+++ b/electrum/ecc_fast.py
@@ -47,7 +47,7 @@ def load_library():
elif sys.platform in ('windows', 'win32'):
for v in tested_libversions:
libnames.append(f"libsecp256k1-{v}.dll")
- elif 'ANDROID_DATA' in os.environ:
+ elif False:
libnames = ['libsecp256k1.so', ] # don't care about version number. we built w/e is available.
else: # desktop Linux and similar
for v in tested_libversions:
diff --git a/electrum/electrum b/electrum/electrum
index dc997981c2f8..6d60af24bf00 100755
--- a/electrum/electrum
+++ b/electrum/electrum
@@ -42,7 +42,7 @@ from typing import TYPE_CHECKING, Optional

script_dir = os.path.dirname(os.path.realpath(__file__))
is_pyinstaller = getattr(sys, 'frozen', False)
-is_android = 'ANDROID_DATA' in os.environ
+is_android = False
is_appimage = 'APPIMAGE' in os.environ
is_binary_distributable = is_pyinstaller or is_android or is_appimage
# is_local: unpacked tar.gz but not pip installed, or git clone
diff --git a/electrum/gui/default_lang.py b/electrum/gui/default_lang.py
index aacf8112f05e..c8c1d07afb74 100644
--- a/electrum/gui/default_lang.py
+++ b/electrum/gui/default_lang.py
@@ -13,7 +13,7 @@ from electrum.i18n import languages


jLocale = None
-if "ANDROID_DATA" in os.environ:
+if False:
from jnius import autoclass, cast
jLocale = autoclass("java.util.Locale")

diff --git a/electrum/gui/qml/qeapp.py b/electrum/gui/qml/qeapp.py
index 87f5ad7a6e17..4df3dee1faa2 100644
--- a/electrum/gui/qml/qeapp.py
+++ b/electrum/gui/qml/qeapp.py
@@ -49,7 +49,7 @@ if TYPE_CHECKING:
from electrum.daemon import Daemon
from electrum.plugin import Plugins

-if 'ANDROID_DATA' in os.environ:
+if False:
from jnius import autoclass, cast
from android import activity

@@ -281,7 +281,7 @@ class QEAppController(BaseCrashReporter, QObject):

@pyqtSlot(result=bool)
def isAndroid(self):
- return 'ANDROID_DATA' in os.environ
+ return False

@pyqtSlot(result='QVariantMap')
def crashData(self):
diff --git a/electrum/gui/qml/qeqrscanner.py b/electrum/gui/qml/qeqrscanner.py
index a301cdaa93f5..712d5dadec88 100644
--- a/electrum/gui/qml/qeqrscanner.py
+++ b/electrum/gui/qml/qeqrscanner.py
@@ -9,7 +9,7 @@ from electrum.logging import get_logger
from electrum.i18n import _


-if 'ANDROID_DATA' in os.environ:
+if False:
from jnius import autoclass
from android import activity

@@ -54,7 +54,7 @@ class QEQRScanner(QObject):

@pyqtSlot()
def open(self):
- if 'ANDROID_DATA' not in os.environ:
+ if True:
self._scan_qr_non_android()
return
jSimpleScannerActivity = autoclass("org.electrum.qr.SimpleScannerActivity")
@@ -77,7 +77,7 @@ class QEQRScanner(QObject):

@pyqtSlot()
def _unbind(self):
- if 'ANDROID_DATA' in os.environ:
+ if False:
activity.unbind(on_activity_result=self.on_qr_activity_result)

def _scan_qr_non_android(self):
diff --git a/electrum/logging.py b/electrum/logging.py
index efe01f6c25cd..bf06d551f734 100644
--- a/electrum/logging.py
+++ b/electrum/logging.py
@@ -359,7 +359,7 @@ def get_logfile_path() -> Optional[pathlib.Path]:


def describe_os_version() -> str:
- if 'ANDROID_DATA' in os.environ:
+ if False:
import jnius
bv = jnius.autoclass('android.os.Build$VERSION')
b = jnius.autoclass('android.os.Build')
diff --git a/electrum/qrreader/zbar.py b/electrum/qrreader/zbar.py
index 8a3ef54dfdf8..73144caf2366 100644
--- a/electrum/qrreader/zbar.py
+++ b/electrum/qrreader/zbar.py
@@ -37,7 +37,7 @@ from .abstract_base import AbstractQrCodeReader, QrCodeResult

_logger = get_logger(__name__)

-if 'ANDROID_DATA' in os.environ:
+if False:
LIBNAME = 'libzbar.so'
elif sys.platform == 'darwin':
LIBNAME = 'libzbar.0.dylib'
diff --git a/electrum/simple_config.py b/electrum/simple_config.py
index 40ee656a5946..762fb447355d 100644
--- a/electrum/simple_config.py
+++ b/electrum/simple_config.py
@@ -436,7 +436,7 @@ class SimpleConfig(Logger):
def get_backup_dir(self) -> Optional[str]:
# this is used to save wallet file backups (without active lightning channels)
# on Android, the export backup button uses android_backup_dir()
- if 'ANDROID_DATA' in os.environ:
+ if False:
return None
else:
return self.WALLET_BACKUP_DIRECTORY
diff --git a/electrum/util.py b/electrum/util.py
index a62abd86acac..597c061550b7 100644
--- a/electrum/util.py
+++ b/electrum/util.py
@@ -420,7 +420,7 @@ class DaemonThread(threading.Thread, Logger):
self.wake_up_event.clear()

def on_stop(self):
- if 'ANDROID_DATA' in os.environ:
+ if False:
import jnius
jnius.detach()
self.logger.info("jnius detach")
@@ -563,7 +563,7 @@ def get_new_wallet_name(wallet_folder: str) -> str:


def is_android_debug_apk() -> bool:
- is_android = 'ANDROID_DATA' in os.environ
+ is_android = False
if not is_android:
return False
from jnius import autoclass
@@ -573,7 +573,7 @@ def is_android_debug_apk() -> bool:


def get_android_package_name() -> str:
- is_android = 'ANDROID_DATA' in os.environ
+ is_android = False
assert is_android
from jnius import autoclass
from android.config import ACTIVITY_CLASS_NAME
@@ -637,7 +637,7 @@ def xor_bytes(a: bytes, b: bytes) -> bytes:
def user_dir():
if "ELECTRUMDIR" in os.environ:
return os.environ["ELECTRUMDIR"]
- elif 'ANDROID_DATA' in os.environ:
+ elif False:
return android_data_dir()
elif os.name == 'posix':
return os.path.join(os.environ["HOME"], ".electrum")
diff --git a/run_electrum b/run_electrum
index dc997981c2f8..6d60af24bf00 100755
--- a/run_electrum
+++ b/run_electrum
@@ -42,7 +42,7 @@ from typing import TYPE_CHECKING, Optional

script_dir = os.path.dirname(os.path.realpath(__file__))
is_pyinstaller = getattr(sys, 'frozen', False)
-is_android = 'ANDROID_DATA' in os.environ
+is_android = False
is_appimage = 'APPIMAGE' in os.environ
is_binary_distributable = is_pyinstaller or is_android or is_appimage
# is_local: unpacked tar.gz but not pip installed, or git clone
--
2.49.0

Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
From ad45206125a21fc4324e9f4787fffeabe944df97 Mon Sep 17 00:00:00 2001
From: Henrik Grimler <henrik@grimler.se>
Date: Sun, 16 Feb 2025 21:08:03 +0100
Subject: [PATCH] termux: set text gui as default

It is possible to run the other guis as well, with termux-x11 or vnc,
but default should be text gui in our terminal emulator.
---
electrum/daemon.py | 2 +-
electrum/simple_config.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/electrum/daemon.py b/electrum/daemon.py
index ad7a81430271..6d8740307eb0 100644
--- a/electrum/daemon.py
+++ b/electrum/daemon.py
@@ -606,7 +606,7 @@
@@ -612,7 +612,7 @@ class Daemon(Logger):
threading.current_thread().name = 'GUI'
gui_name = self.config.GUI_NAME
if gui_name in ['lite', 'classic']:
Expand All @@ -9,9 +23,11 @@
self._plugins = Plugins(self.config, gui_name) # init plugins
self.logger.info(f'launching GUI: {gui_name}')
try:
diff --git a/electrum/simple_config.py b/electrum/simple_config.py
index 762fb447355d..d34e1ac21679 100644
--- a/electrum/simple_config.py
+++ b/electrum/simple_config.py
@@ -1061,7 +1061,7 @@
@@ -1080,7 +1080,7 @@ Warning: setting this to too low will result in lots of payment failures."""),
RPC_SOCKET_TYPE = ConfigVar('rpcsock', default='auto', type_=str)
RPC_SOCKET_FILEPATH = ConfigVar('rpcsockpath', default=None, type_=str)

Expand All @@ -20,3 +36,6 @@
GUI_LAST_WALLET = ConfigVar('gui_last_wallet', default=None, type_=str)

GUI_QT_COLOR_THEME = ConfigVar(
--
2.49.0

45 changes: 45 additions & 0 deletions packages/electrum/0003-gui-text-init-window-max_pos-to-0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
From 7f497724258ab3efa567dcbd9fb424b22f5dc92a Mon Sep 17 00:00:00 2001
From: Henrik Grimler <grimler@termux.dev>
Date: Sat, 15 Feb 2025 23:48:30 +0100
Subject: [PATCH] gui: text: init window max_pos to 0

Otherwise running the text gui and directly pressing up or down
results in an error like:

2.45 | E | daemon.Daemon | GUI raised exception: AttributeError("'ElectrumGui' object has no attribute 'max_pos'"). shutting down.
2.61 | E | __main__ | daemon.run_gui errored
Traceback (most recent call last):
File "/usr/bin/electrum", line 466, in handle_cmd
d.run_gui()
File "/usr/lib/python3.12/site-packages/electrum/daemon.py", line 598, in run_gui
self.gui_object.main()
File "/usr/lib/python3.12/site-packages/electrum/gui/text.py", line 537, in main
self.run_tab(0, self.print_history, self.run_history_tab)
File "/usr/lib/python3.12/site-packages/electrum/gui/text.py", line 473, in run_tab
c = self.main_command()
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/electrum/gui/text.py", line 458, in main_command
self.increase_cursor(-1)
File "/usr/lib/python3.12/site-packages/electrum/gui/text.py", line 436, in increase_cursor
self.pos = min(self.pos, self.max_pos - 1)
^^^^^^^^^^^^
AttributeError: 'ElectrumGui' object has no attribute 'max_pos'
---
electrum/gui/text.py | 1 +
1 file changed, 1 insertion(+)

diff --git a/electrum/gui/text.py b/electrum/gui/text.py
index c5280f7a466b..73e374319ba0 100644
--- a/electrum/gui/text.py
+++ b/electrum/gui/text.py
@@ -95,6 +95,7 @@ class ElectrumGui(BaseElectrumGui, EventListener):
self.lightning_invoice = None
self.tab = 0
self.pos = 0
+ self.max_pos = 0
self.popup_pos = 0

self.str_recipient = ""
--
2.49.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
From f7ef5d2aad1e7c3e9b4745bb50c6babf5faeca6b Mon Sep 17 00:00:00 2001
From: Henrik Grimler <grimler@termux.dev>
Date: Sat, 15 Feb 2025 23:51:47 +0100
Subject: [PATCH] HACK: gui: text: set fee_per_kb to 0 if it is None

To fix crash when settings tab is opened in text gui:

2.25 | E | daemon.Daemon | GUI raised exception: TypeError('conversion from NoneType to Decimal is not supported'). shutting down.
2.59 | E | __main__ | daemon.run_gui errored
Traceback (most recent call last):
File "/usr/bin/electrum", line 466, in handle_cmd
d.run_gui()
File "/usr/lib/python3.12/site-packages/electrum/daemon.py", line 598, in run_gui
self.gui_object.main()
File "/usr/lib/python3.12/site-packages/electrum/gui/text.py", line 537, in main
self.run_tab(0, self.print_history, self.run_history_tab)
File "/usr/lib/python3.12/site-packages/electrum/gui/text.py", line 473, in run_tab
c = self.main_command()
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/electrum/gui/text.py", line 464, in main_command
self.settings_dialog()
File "/usr/lib/python3.12/site-packages/electrum/gui/text.py", line 763, in settings_dialog
fee = str(Decimal(self.config.fee_per_kb()) / COIN)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: conversion from NoneType to Decimal is not supported
---
electrum/gui/text.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/electrum/gui/text.py b/electrum/gui/text.py
index 73e374319ba0..cffc4230ebf2 100644
--- a/electrum/gui/text.py
+++ b/electrum/gui/text.py
@@ -761,7 +761,7 @@ class ElectrumGui(BaseElectrumGui, EventListener):
self.network.run_from_another_thread(self.network.set_parameters(net_params))

def settings_dialog(self):
- fee = str(Decimal(self.config.fee_per_kb()) / COIN)
+ fee = str(Decimal(self.config.fee_per_kb() if self.config.fee_per_kb() else 0) / COIN)
out = self.run_dialog('Settings', [
{'label':'Default fee', 'type':'satoshis', 'value': fee}
], buttons = 1)
--
2.49.0

27 changes: 27 additions & 0 deletions packages/electrum/0005-ecc_fast-look-for-libsecp256k1.so.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
From c6832bcf17376f9d3bac907db7342e8a7c3fff9a Mon Sep 17 00:00:00 2001
From: Henrik Grimler <grimler@termux.dev>
Date: Thu, 3 Apr 2025 18:29:51 +0200
Subject: [PATCH] ecc_fast: look for libsecp256k1.so

Without .1 or .2 version suffix. Termux's libsecp256k1 library is
called just libsecp256k1.so.
---
electrum/ecc_fast.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/electrum/ecc_fast.py b/electrum/ecc_fast.py
index b88d9acf7dc2..35b14aa62587 100644
--- a/electrum/ecc_fast.py
+++ b/electrum/ecc_fast.py
@@ -47,7 +47,7 @@ def load_library():
elif sys.platform in ('windows', 'win32'):
for v in tested_libversions:
libnames.append(f"libsecp256k1-{v}.dll")
- elif False:
+ elif True:
libnames = ['libsecp256k1.so', ] # don't care about version number. we built w/e is available.
else: # desktop Linux and similar
for v in tested_libversions:
--
2.49.0

Loading