Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Satochip hardware wallet #8967

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
fa82f82
Add Satochip hardware wallet support to Electrum v4.5.4
Toporin Mar 20, 2024
20be6e3
Refactor class QRDialog: add optional 'cancel' button
Toporin Mar 20, 2024
7a8d6ca
Satochip: update build scripts for Linux, Windows & MacOS
Toporin Mar 20, 2024
7193d88
Satochip: clean code using flake8
Toporin Mar 20, 2024
ed537de
Satochip: correct flake8 issue in __init__.py
Toporin Mar 21, 2024
88d5092
Merge branch 'master' into electrum-satochip-v4.5.4-0.12
Toporin Jun 8, 2024
040d0ca
Satochip: adapt bitcoin.py/transaction.py calls
Toporin Jun 9, 2024
a41fe39
Clean Satochip plugin code using Flake8 & autopep8
Toporin Jun 20, 2024
fcaacce
Satochip plugin: clean code
Toporin Jun 20, 2024
f075129
Satochip plugin: improve 2FA UX
Toporin Jun 21, 2024
12ff4d1
Satochip plugin: using SeedLayout to import seed in setup Wizard
Toporin Jun 25, 2024
37f719b
Remove unnecessary parenthesis in 'if' statements
Toporin Sep 25, 2024
8d6bd78
Merge branch 'master' into electrum-satochip-v4.5.4-0.12
Toporin Sep 25, 2024
b06e332
qt desktop gui: upgrade qt5->qt6
Toporin Sep 25, 2024
c470901
satochip: fixes and error handling
accumulator Nov 13, 2024
4ba8faf
Merge branch 'master' into electrum-satochip-v4.5.4-0.12
Toporin Jan 21, 2025
133ade3
(minor) correct some PEP8 warnings
Toporin Jan 21, 2025
44cd93d
Patch: electrum.ecc is now a distinct package
Toporin Jan 21, 2025
5bc0b72
Moved Satochip icons from electrum/gui to the satochip plugin folder
Toporin Jan 21, 2025
aa9c241
Remove commented import
Toporin Jan 22, 2025
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
2 changes: 2 additions & 0 deletions contrib/build-linux/appimage/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ RUN apt-get update -q && \
libffi-dev \
libncurses5-dev \
libncurses5 \
libpcsclite-dev \
swig \
libtinfo-dev \
libtinfo5 \
libsqlite3-dev \
Expand Down
2 changes: 1 addition & 1 deletion contrib/build-wine/build-electrum-git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ $WINE_PYTHON -m pip install --no-build-isolation --no-dependencies --no-warn-scr
--cache-dir "$WINE_PIP_CACHE_DIR" -r "$CONTRIB"/deterministic-build/requirements-binaries.txt
info "Installing hardware wallet requirements..."
$WINE_PYTHON -m pip install --no-build-isolation --no-dependencies --no-warn-script-location \
--no-binary :all: --only-binary cffi,cryptography,hidapi \
--no-binary :all: --only-binary cffi,cryptography,hidapi,pyscard \
--cache-dir "$WINE_PIP_CACHE_DIR" -r "$CONTRIB"/deterministic-build/requirements-hw.txt

pushd $WINEPREFIX/drive_c/electrum
Expand Down
1 change: 1 addition & 0 deletions contrib/build-wine/deterministic.spec
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ datas += collect_data_files('btchip')
datas += collect_data_files('keepkeylib')
datas += collect_data_files('ckcc')
datas += collect_data_files('bitbox02')
datas += collect_data_files('pysatochip')

# We don't put these files in to actually include them in the script but to make the Analysis method scan them for imports
a = Analysis([f"{PROJECT_ROOT}/{MAIN_SCRIPT}",
Expand Down
16 changes: 16 additions & 0 deletions contrib/deterministic-build/requirements-hw.txt
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,22 @@ pyaes==1.6.1 \
pycparser==2.21 \
--hash=sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9 \
--hash=sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206
pysatochip==0.12.6 \
--hash=sha256:f751ae93ea784dc3ef77508da56df6222a195d8f7ead53f87d29ea84c7bc8f90 \
--hash=sha256:d1255c5126c0c76b86f5eb1289b1cdc0b14a6f1265c82a63ce07074f6ccb2903
pyscard==2.0.7 \
--hash=sha256:278054525fa75fbe8b10460d87edcd03a70ad94d688b11345e4739987f85c1bf \
--hash=sha256:8e37b697327e8dc4848c481428d1cbd10b7ae2ce037bc799e5b8bbd2fc3ab5ed \
--hash=sha256:beacdcdc3d1516e195f7a38ec3966c5d4df7390c8f036cb41f6fef72bc5cc646 \
--hash=sha256:a2266345bd387854298153264bff8b74f494581880a76e3e8679460c1b090fab \
--hash=sha256:06666a597e1293421fa90e0d4fc2418add447b10b7dc85f49b3cafc23480f046 \
--hash=sha256:5a5865675be294c8d91f22dc91e7d897c4138881e5295fb6b2cd821f7c0389d9 \
--hash=sha256:39e030c47878b37ae08038a917959357be6468da52e8b144e84ffc659f50e6e2 \
--hash=sha256:2d4bdc1f4e0e6c46e417ac1bc9d5990f7cfb24a080e890d453781405f7bd29dc \
--hash=sha256:da70aa5b7be5868b88cdb6d4a419d2791b6165beeb90cd01d2748033302a0f43 \
--hash=sha256:59a466ab7ae20188dd197664b9ca1ea9524d115a5aa5b16b575a6b772cdcb73c \
--hash=sha256:f704ad40dc40306e1c0981941789518ab16aa1f84443b1d52ec0264884092b3b \
--hash=sha256:a0c5edbedafba62c68160884f878d9f53996d7219a3fc11b1cea6bab59c7f34a
pyserial==3.5 \
--hash=sha256:3c77e014170dfffbd816e6ffc205e9842efb10be9f58ec16d3e8675b4925cddb \
--hash=sha256:c4451db6ba391ca6ca299fb3ec7bae67a5c55dde170964c7a14ceefec02f2cf0
Expand Down
2 changes: 1 addition & 1 deletion contrib/osx/make_osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ python3 -m pip install --no-build-isolation --no-dependencies --no-binary :all:
|| fail "Could not install build dependencies (mac)"

info "Installing some build-time deps for compilation..."
brew install autoconf automake libtool gettext coreutils pkgconfig
brew install autoconf automake libtool gettext coreutils pkgconfig swig

info "Building PyInstaller."
PYINSTALLER_REPO="https://github.com/pyinstaller/pyinstaller.git"
Expand Down
1 change: 1 addition & 0 deletions contrib/osx/osx.spec
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ datas += collect_data_files('btchip')
datas += collect_data_files('keepkeylib')
datas += collect_data_files('ckcc')
datas += collect_data_files('bitbox02')
datas += collect_data_files('pysatochip')

# We don't put these files in to actually include them in the script but to make the Analysis method scan them for imports
a = Analysis([f"{PROJECT_ROOT}/{MAIN_SCRIPT}",
Expand Down
4 changes: 4 additions & 0 deletions contrib/requirements/requirements-hw.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ ckcc-protocol>=0.7.7
# device plugin: bitbox02
bitbox02>=6.2.0

# device plugin: satochip
pyscard>=1.9.9
pysatochip==0.12.6

# device plugin: jade
cbor2>=5.4.6,<6.0.0
pyserial>=3.5.0,<4.0.0
Expand Down
20 changes: 16 additions & 4 deletions electrum/gui/qt/qrcodewidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def __init__(
show_text=False,
help_text=None,
show_copy_text_btn=False,
show_cancel_btn=False,
config: SimpleConfig,
):
WindowModalDialog.__init__(self, parent, title)
Expand Down Expand Up @@ -182,10 +183,21 @@ def copy_text_to_clipboard():
hbox.addWidget(b)
b.clicked.connect(print_qr)

b = QPushButton(_("Close"))
hbox.addWidget(b)
b.clicked.connect(self.accept)
b.setDefault(True)
if show_cancel_btn:
b = QPushButton(_("Ok"))
hbox.addWidget(b)
b.clicked.connect(self.accept)
b.setDefault(True)

b = QPushButton(_("Cancel"))
hbox.addWidget(b)
b.clicked.connect(self.reject)
b.setDefault(True)
else:
b = QPushButton(_("Close"))
hbox.addWidget(b)
b.clicked.connect(self.accept)
b.setDefault(True)

vbox.addLayout(hbox)
self.setLayout(vbox)
Expand Down
82 changes: 82 additions & 0 deletions electrum/plugins/satochip/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
Satochip plugin for electrum
=================================================================================

::

Licence: MIT Licence
Author: Toporin
Language: Python (>= 3.6)
Homepage: https://github.com/Toporin/electrum-satochip

Introduction
============

This plugin allows to integrate the Satochip Hardware Wallet with Electrum. To use it, you need a device with the Satochip javacard applet installed (see https://github.com/Toporin/SatochipApplet).
If the wallet is not intialized yet, Electrum will perform the setup (you only need to do this once). During setup, a seed is created: this seed allows you to recover your wallet at anytime, so make sure to BACKUP THE SEED SECURELY! During setup, a PIN code is also created: this PIN allows to unlock th device to access your funds. If you try too many wrong PIN, your device will be locked indefinitely (it is 'bricked'). If you loose your PIN or brick your device, you can only recover your funds with the seed backup.

The Satochip wallet is currently in Beta, use with caution!You can use the software on the Bitcoin testnet using the --testnet option.
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Rem: Electrum uses Python 3.x. In case of error, check first that you are not trying to run Electrum with Python 2.x or with Python 2.x libraries.

Development version (Windows 64bits)
=====================================

Install the latest python 3.6 release from https://www.python.org (https://www.python.org/downloads/release/python-368/)
(Caution: installing another release than 3.6 may cause incompatibility issues with pyscard)

Clone or download the code from GitHub.

Open a PowerShell command line in the electrum folder

In PowerShell, install the electrum dependencies::

python -m pip install .

You may also ned to install Python3-pyqt5::

python -m pip install pyqt5

Install pyscard from https://pyscard.sourceforge.io/
Pyscard is required to connect to the smartcard::

python -m pip install pyscard


In PowerShell, run electrum on the testnet (-v allows for verbose output)::

python .\run_electrum -v --testnet


Development version (Ubuntu)
==============================
(Electrum requires Python 3.6, which should be installed by default on Ubuntu)
(If necessary, install pip: sudo apt-get install python3-pip)

Electrum is a pure python application. To use the
Qt interface, install the Qt dependencies::

sudo apt-get install python3-pyqt5

Check out the code from GitHub::

git clone git://github.com/Toporin/electrum.git
cd electrum

In the electrum folder:

Run install (this should install dependencies)::

python3 -m pip install .

Install pyscard (https://pyscard.sourceforge.io/)
Pyscard is required to connect to the smartcard::
sudo apt-get install pcscd
sudo apt-get install python3-pyscard
(For alternatives, see https://github.com/LudovicRousseau/pyscard/blob/master/INSTALL.md for more detailed installation instructions)


To run Electrum use::
python3 electrum -v --testnet


6 changes: 6 additions & 0 deletions electrum/plugins/satochip/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

fullname = 'Satochip Wallet'
description = 'Provides support for Satochip hardware wallet'
requires = [('satochip', 'github.com/Toporin/pysatochip')]
registers_keystore = ('hardware', 'satochip', "Satochip wallet")
available_for = ['qt']
Loading