diff --git a/electrum/ecc_fast.py b/electrum/ecc_fast.py index fcd13c64d..ba75498f2 100644 --- a/electrum/ecc_fast.py +++ b/electrum/ecc_fast.py @@ -37,16 +37,23 @@ class LibModuleMissing(Exception): pass def load_library(): + # note: for a mapping between bitcoin-core/secp256k1 git tags and .so.V libtool version numbers, + # see https://github.com/bitcoin-core/secp256k1/pull/1055#issuecomment-1227505189 + tested_libversions = [2, 1, 0, ] # try latest version first + libnames = [] if sys.platform == 'darwin': - libnames = ['libsecp256k1.1.dylib', 'libsecp256k1.0.dylib', ] + for v in tested_libversions: + libnames.append(f"libsecp256k1.{v}.dylib") elif sys.platform in ('windows', 'win32'): - libnames = ['libsecp256k1-1.dll', 'libsecp256k1-0.dll', ] + for v in tested_libversions: + libnames.append(f"libsecp256k1-{v}.dll") elif 'ANDROID_DATA' in os.environ: - libnames = ['libsecp256k1.so', ] - elif 'freebsd' in sys.platform: - libnames = ['libsecp256k1.so', ] + libnames = ['libsecp256k1.so', ] # don't care about version number. we built w/e is available. else: # desktop Linux and similar - libnames = ['libsecp256k1.so.1', 'libsecp256k1.so.0', ] + for v in tested_libversions: + libnames.append(f"libsecp256k1.so.{v}") + # maybe we could fall back to trying "any" version? maybe guarded with an env var? + #libnames.append(f"libsecp256k1.so") library_paths = [] for libname in libnames: # try local files in repo dir first library_paths.append(os.path.join(os.path.dirname(__file__), libname))