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

plugins: keepkey: vendor keepkeylib #9581

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
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
3 changes: 2 additions & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ task:
install_script:
- pip install "flake8==7.0.0" "flake8-bugbear==24.1.16"
flake8_script:
- flake8 . --count --select="$ELECTRUM_LINTERS" --ignore="$ELECTRUM_LINTERS_IGNORE" --show-source --statistics --exclude "*_pb2.py,electrum/_vendor/"
- flake8 . --count --select="$ELECTRUM_LINTERS" --ignore="$ELECTRUM_LINTERS_IGNORE" --show-source --statistics --exclude "$ELECTRUM_EXCLUDE"
env:
ELECTRUM_IMAGE: python:3.10
ELECTRUM_REQUIREMENTS: contrib/requirements/requirements.txt
Expand All @@ -166,6 +166,7 @@ task:
# - https://github.com/PyCQA/flake8-bugbear/tree/8c0e7eb04217494d48d0ab093bf5b31db0921989#list-of-warnings
ELECTRUM_LINTERS: E9,E101,E129,E273,E274,E703,E71,E722,F63,F7,F82,W191,W29,B
ELECTRUM_LINTERS_IGNORE: B007,B009,B010,B019,B036
ELECTRUM_EXCLUDE: "*_pb2.py,electrum/_vendor/,electrum/plugins/keepkey/keepkeylib/"
- name: "linter: Flake8 Non-Mandatory"
env:
ELECTRUM_LINTERS: E,F,W,C90,B
Expand Down
1 change: 0 additions & 1 deletion contrib/build-wine/deterministic.spec
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ datas += collect_data_files(f"{PYPKG}.plugins")
datas += collect_data_files('trezorlib') # TODO is this needed? and same question for other hww libs
datas += collect_data_files('safetlib')
datas += collect_data_files('btchip')
datas += collect_data_files('keepkeylib')
datas += collect_data_files('ckcc')
datas += collect_data_files('bitbox02')

Expand Down
4 changes: 0 additions & 4 deletions contrib/deterministic-build/requirements-hw.txt
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,6 @@ hidapi==0.14.0 \
idna==3.6 \
--hash=sha256:9ecdbbd083b06798ae1e86adcbfe8ab1479cf864e4ee30fe4e46a003d12491ca \
--hash=sha256:c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f
keepkey==6.3.1 \
--hash=sha256:88e2b5291c85c8e8567732f675697b88241082884aa1aba32257f35ee722fc09 \
--hash=sha256:cef1e862e195ece3e42640a0f57d15a63086fd1dedc8b5ddfcbc9c2657f0bb1e \
--hash=sha256:f369d640c65fec7fd8e72546304cdc768c04224a6b9b00a19dc2cd06fa9d2a6b
ledger-bitcoin==0.3.0 \
--hash=sha256:ad9cdeaf33a45562bbd5bae6751025b869a2f81d6eb0267dd062a01f5925a4d5 \
--hash=sha256:e7c33404d02044c3810b294a510f7ad97bc65ab12dbdd180d873f2b4ebc0711a
Expand Down
1 change: 0 additions & 1 deletion contrib/osx/osx.spec
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ datas += collect_data_files(f"{PYPKG}.plugins")
datas += collect_data_files('trezorlib') # TODO is this needed? and same question for other hww libs
datas += collect_data_files('safetlib')
datas += collect_data_files('btchip')
datas += collect_data_files('keepkeylib')
datas += collect_data_files('ckcc')
datas += collect_data_files('bitbox02')

Expand Down
10 changes: 5 additions & 5 deletions contrib/requirements/requirements-hw.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ trezor[hidapi]>=0.13.0,<0.14
safet>=0.1.5

# device plugin: keepkey
keepkey>=6.3.1
ecdsa>=0.9
protobuf>=3.20
mnemonic>=0.8
hidapi>=0.7.99.post15
libusb1>=1.6

# device plugin: ledger
# note: btchip-python only needed for "legacy" protocol and HW.1 support
Expand All @@ -25,10 +29,6 @@ bitbox02>=6.2.0
cbor2>=5.4.6,<6.0.0
pyserial>=3.5.0,<4.0.0

# prefer older protobuf (see #7922)
# (pulled in via e.g. keepkey and bitbox02)
protobuf>=3.20,<4

# prefer older colorama to avoid needing hatchling
# (pulled in via trezor -> click -> colorama)
# (pulled in via safet -> click -> colorama)
Expand Down
2 changes: 1 addition & 1 deletion contrib/requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
qrcode
protobuf>=3.20,<4
protobuf>=3.20
qdarkstyle>=3.2
aiorpcx>=0.22.0,<0.25
aiohttp>=3.3.0,<4.0.0
Expand Down
2 changes: 1 addition & 1 deletion electrum/plugins/keepkey/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from keepkeylib.client import proto, BaseClient, ProtocolMixin
from .keepkeylib.client import proto, BaseClient, ProtocolMixin
from .clientbase import KeepKeyClientBase

class KeepKeyClient(KeepKeyClientBase, ProtocolMixin, BaseClient):
Expand Down
14 changes: 14 additions & 0 deletions electrum/plugins/keepkey/device-protocol/build_pb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -e

PLUGIN_KEEPKEY="$(dirname "$(readlink -e "$0")")/.."
cd "$PLUGIN_KEEPKEY/device-protocol"

echo "Building with protoc version: $(protoc --version)"
for i in messages types exchange ; do
protoc --python_out="$PLUGIN_KEEPKEY/keepkeylib/" -I/usr/include -I. $i.proto
i=${i/-/_}
sed -i -Ee 's/^import ([^.]+_pb2)/from . import \1/' "$PLUGIN_KEEPKEY"/keepkeylib/"$i"_pb2.py
done

sed -i 's/5000\([2-5]\)/6000\1/g' "$PLUGIN_KEEPKEY"/keepkeylib/types_pb2.py
47 changes: 47 additions & 0 deletions electrum/plugins/keepkey/device-protocol/exchange.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Exchange communication
*
*/

syntax = "proto2";

// Sugar for easier handling in Java
option java_package = "com.keepkey.device-protocol";
option java_outer_classname = "KeepKeyExchange";

/**
* Structure representing address for various coin types (BTC, LTC, and etc).
* @used in ExchangeResponse
*/
message ExchangeAddress {
optional string coin_type = 1;
optional string address = 2;
optional string dest_tag = 3;
// formerly rs_address = 4;
}

enum OrderType {
Precise = 0;
Quick = 1;
}

message ExchangeResponseV2 {
optional ExchangeAddress deposit_address = 1;
optional bytes deposit_amount = 2;
optional int64 expiration = 3;
optional bytes quoted_rate = 4;
optional ExchangeAddress withdrawal_address = 5;
optional bytes withdrawal_amount = 6;
optional ExchangeAddress return_address = 7;
optional bytes api_key = 8;
optional bytes miner_fee = 9;
optional bytes order_id = 10;
optional OrderType type = 11 [default=Precise];
}

message SignedExchangeResponse {
// Formerly response = 1;
optional bytes signature = 2;
optional ExchangeResponseV2 responseV2 = 3;
}

Loading