Skip to content

Commit bcc524e

Browse files
authored
Docco tweak and Termux Fixes (#585)
1 parent d8289c6 commit bcc524e

File tree

5 files changed

+53
-13
lines changed

5 files changed

+53
-13
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ If you need help, [your best bet is to look at my BTCRecover playlist on YouTube
112112
* [Damaged Raw Eth Private Keys]() Individual Private keys that are missing characters.
113113
* [Toastwallet](https://toastwallet.github.io/browser/) Toastwallet Passphrase
114114
* [Free and Open Source](http://en.wikipedia.org/wiki/Free_and_open-source_software) - anyone can download, inspect, use, and redistribute this software
115-
* Supported on Windows, Linux, and OS X
115+
* Supported on Windows, Linux, and MacOS
116116
* Support for Unicode passwords and seeds
117117
* Multithreaded searches, with user-selectable thread count
118118
* Ability to spread search workload over multiple devices
@@ -126,7 +126,7 @@ If you need help, [your best bet is to look at my BTCRecover playlist on YouTube
126126
* “Offline” mode for nearly all supported wallets - use one of the [extract scripts (click for more information)](docs/Extract_Scripts.md) to extract just enough information to attempt password recovery, without giving *btcrecover* or whoever runs it access to *any* of the addresses or private keys in your Bitcoin wallet.
127127

128128
## Setup and Usage Tutorials ##
129-
BTCRecover is a Python (3.8, 3.9, 3.10, 3.11) script so will run on Windows, Linux and Mac environments. [See the installation guide for more info](docs/INSTALL.md)
129+
BTCRecover is a Python (3.9, 3.10, 3.11, 3.12 and 3.13) script so will run on Windows, Linux, Mac and even Android environments. [See the installation guide for more info](docs/INSTALL.md)
130130

131131
[I have created a growing playlist](https://www.youtube.com/playlist?list=PL7rfJxwogDzmd1IanPrmlTg3ewAIq-BZJ) that covers a number of usage examples for using this tool to recover seed phrases, BIP39 passphrases, etc.
132132

btcrecover/btcrseed.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
# Import modules bundled with BTCRecover
3333
from . import btcrpass
3434
from .addressset import AddressSet
35-
from lib.bitcoinlib_mod import encoding as encoding_mod
3635
from lib.bitcoinlib import encoding
3736
from lib.cashaddress import convert, base58
3837
from lib.base58_tools import base58_tools
@@ -44,6 +43,15 @@
4443
import lib.stacks.c32 as c32
4544
from lib.p2tr_helper import P2TR_tools
4645

46+
# import bundled modules that won't work in some environments
47+
bundled_bitcoinlib_mod_available = False
48+
try:
49+
from lib.bitcoinlib_mod import encoding as encoding_mod
50+
51+
bundled_bitcoinlib_mod_available = True
52+
except:
53+
pass
54+
4755
# Enable functions that may not work for some standard libraries in some environments
4856
hashlib_ripemd160_available = False
4957

@@ -356,12 +364,14 @@ def _addresses_to_hash160s(addresses):
356364
try:
357365
hash160 = binascii.unhexlify(encoding.addr_bech32_to_pubkeyhash(address, prefix=None, include_witver=False, as_hex=True)) #Base58 conversion above will give a keyError if attempted with a Bech32 address for things like BTC
358366
except Exception as e:
359-
# Try for some obscure altcoins which require modified versions of Bitcoinlib
360-
try:
361-
hash160 = binascii.unhexlify(encoding_mod.grs_addr_base58_to_pubkeyhash(address, True))
362-
except Exception as e:
363-
hash160 = binascii.unhexlify(encoding_mod.addr_bech32_to_pubkeyhash(address, prefix=None, include_witver=False, as_hex=True)) #
364-
367+
if bundled_bitcoinlib_mod_available:
368+
# Try for some obscure altcoins which require modified versions of Bitcoinlib
369+
try:
370+
hash160 = binascii.unhexlify(encoding_mod.grs_addr_base58_to_pubkeyhash(address, True))
371+
except Exception as e:
372+
hash160 = binascii.unhexlify(encoding_mod.addr_bech32_to_pubkeyhash(address, prefix=None, include_witver=False, as_hex=True))
373+
else:
374+
print("Address not valid and unable to load modified bitcoinlib on this platform...")
365375

366376
hash160s.add(hash160)
367377
return hash160s

btcrecover/test/test_seeds.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,19 @@ def can_load_staking_deposit():
114114
eth2_staking_deposit_available = False
115115
return eth2_staking_deposit_available
116116

117+
# import bundled modules that won't work in some environments
118+
bundled_bitcoinlib_mod_available = None
119+
def can_load_bundled_bitcoinlib_mod():
120+
global bundled_bitcoinlib_mod_available
121+
if bundled_bitcoinlib_mod_available is None:
122+
try:
123+
from lib.bitcoinlib_mod import encoding as encoding_mod
124+
125+
bundled_bitcoinlib_mod_available = True
126+
except:
127+
bundled_bitcoinlib_mod_available = False
128+
return bundled_bitcoinlib_mod_available
129+
117130
# Similar to unittest.skipUnless, except the first arg is a function returning a bool instead
118131
# of just a bool. This function isn't called until just before the test is to be run. This
119132
# permits checking the character mode (which isn't set until later) and prevents multiprocessing
@@ -658,6 +671,7 @@ def test_bip44_addr_BTC(self):
658671
"certain come keen collect slab gauge photo inside mechanic deny leader drop",
659672
["m/44'/0'/0'/0"])
660673

674+
@skipUnless(can_load_bundled_bitcoinlib_mod,"Unable to load modified bitcoinlib in this environment")
661675
def test_bip44_addr_TerraLuna(self):
662676
self.address_tester(btcrseed.WalletBIP39, "terra1negkjtkr6wu2uzcwcuz0kj8w4z64uax3w0dv5u", 2,
663677
"earth jelly weapon word focus shaft danger cruel inflict strong palace barrel peace strike timber orbit orphan tower size series scatter kiwi fat filter",

docs/INSTALL.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Ubuntu Linux: <https://youtu.be/Met3NbxcZTU>
2424

2525
MacOS: <https://youtu.be/Qzc3oHzbcAo>
2626

27+
Android via Termux: TBC
2728

2829
## 1) Downloading *btcrecover* ##
2930

@@ -32,12 +33,12 @@ Just download the latest version from <https://github.com/3rdIteration/btcrecove
3233

3334
## 2) Install Python ##
3435

35-
**Note:** Only Python 3.8 and later are officially supported... BTCRecover is automatically tested with all supported Python versions (3.8, 3.9, 3.10, 3.11) on all supported environments (Windows, Linux, Mac), so you can be sure that both BTCRecover and all required packages will work correctly. Some features of BTCRecover may work on earlier versions of Python, your best bet is to use run-all-tests.py to see what works and what doesn't...
36+
**Note:** Only Python 3.9 and later are officially supported... BTCRecover is automatically tested with all supported Python versions (3.9, 3.10, 3.11, 3.12, 3.13) on all supported environments (Windows, Linux, Mac), so you can be sure that both BTCRecover and all required packages will work correctly. Some features of BTCRecover may work on earlier versions of Python, your best bet is to use run-all-tests.py to see what works and what doesn't...
3637

3738
### Windows ###
3839
Video Demo of Installing BTCRecover in Windows: <https://youtu.be/8q65eqpf4gE>
3940

40-
Visit the Python download page here: <https://www.python.org/downloads/windows/>, and click the link for the latest **Python 3.10** release (Python 3.11, etc, will work, but Python 3.10 has simpler installation of required modules) release near the top of the page under the heading *Python Releases for Windows*. Download and run either the `Windows x86 MSI installer` for the 32-bit version of Python, or the `Windows x86-64 MSI installer` for the 64-bit one. Modern PCs should use the 64-bit version, however if you're unsure which one is compatible with your PC, choose the 32-bit one.
41+
Visit the Python download page here: <https://www.python.org/downloads/windows/>, and click the link for the latest **Python 3.12** release (Python 3.13, etc, will work, but Python 3.12 has simpler installation of required modules) release near the top of the page under the heading *Python Releases for Windows*. Download and run either the `Windows x86 MSI installer` for the 32-bit version of Python, or the `Windows x86-64 MSI installer` for the 64-bit one. Modern PCs should use the 64-bit version, however if you're unsure which one is compatible with your PC, choose the 32-bit one.
4142

4243
_**When installing Python in Windows, be sure to select to "Add Python to PATH" on the first screen of the installer...**_
4344

@@ -60,8 +61,24 @@ If you get a message that there is no installation candidate for Python3-pip, yo
6061

6162
You can then re-run the command to install python3-pip from above.
6263

64+
### Android via Termux ###
65+
Some warnings and notes...
66+
* Termux is not automatically tested like other platforms...
67+
* Your phone may not have sufficient cooling to run BTCRecover for any meaninful length of time
68+
* Performance will also vary dramatically between phones and Android versions... (Though it is actually fast enough to be useful for simple recoveries)
69+
* Termux is not a standard Linux environment and is not officially supported, but might work following the process below... (And if it doesn't, just use a PC instead...)
70+
* Install Termux following the instructions here: https://termux.dev/en/ (Currently not officially distributed on Google Play and the version on Google Play is not currently up-to-date)
71+
72+
You will then need to install Python as well as some other packages (Mostly the Coincurve build requirements)
73+
74+
pkg install python-pip git autoconf automake build-essential libtool pkg-config binutils-is-llvm rust
75+
76+
Once this is done, you can install the base requirements for BTCRecover that allow recovery of common wallet types. (The full requirements have a lot of packages that won't easily work with Termux) You can also install py-crypto-hd-wallet via pip3 for extended wallet support.(This will take a while to build)
77+
6378
#### Enabling Native RIPEMD160 Support
64-
As of OpenSSL v3 (Late 2021), ripemd160 is no longer enabled by default and is now part of the "Legacy" set of hash functions. In Linux/MacOS environments, the hashlib module in Python relies on OpenSSL for ripemd160, so if you want full performance in these environments, you may need modify your OpenSSL settings to enable the legacy provider.
79+
As of OpenSSL v3 (Late 2021), ripemd160 is no longer enabled by default in some Linux environments and is now part of the "Legacy" set of hash functions. In Linux/MacOS environments, the hashlib module in Python relies on OpenSSL for ripemd160, so if you want full performance in these environments, you may need modify your OpenSSL settings to enable the legacy provider.
80+
81+
You can check if this is required by running `python check_ripemd160.py`
6582

6683
As of July 2022, BTCRecover does include a "pure Python" implementation of RIPEMD160, but this only offers about 1/3 of the performance when compared to a native implementation via hashlib.
6784

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
coincurve~=19.0.0
2-
green~=4.0.2
32
protobuf~=3.19.1
43
pycryptodome~=3.19.1

0 commit comments

Comments
 (0)