Skip to content
Merged
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
45 changes: 30 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,35 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features -- -D warnings
test_ledger:
test_emulators:
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- version: 1.61.0 # STABLE
- version: 1.41.1 # MSRV
emulator:
- name: trezor
- name: ledger
steps:
- uses: actions/checkout@v3
- run: wget "https://github.com/LedgerHQ/speculos/blob/master/apps/nanos%23btc%232.1%231c8db8da.elf?raw=true" -O ci/btc.elf
- run: docker build -t hwi/ledger_emulator ./ci -f ci/Dockerfile.ledger
- run: docker run --rm --name simulator --publish 41000:41000 hwi/ledger_emulator --display headless --vnc-port 41000 btc.elf &
- run: docker cp ./ simulator:/rust-hwi/
- run: docker exec -w /rust-hwi simulator /root/.cargo/bin/cargo test
test_trezor:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: docker build -t hwi/trezor_emulator ./ci -f ci/Dockerfile.trezor
- run: docker run --name simulator hwi/trezor_emulator &
- run: docker cp ./ simulator:/rust-hwi/
- run: docker exec -w /rust-hwi simulator cargo test
- name: Checkout
uses: actions/checkout@v3
- name: Build simulator image
run: docker build -t hwi/${{ matrix.emulator.name }}_emulator ./ci -f ci/Dockerfile.${{ matrix.emulator.name }}
- name: Run simulator image
run: docker run --name simulator --network=host hwi/${{ matrix.emulator.name }}_emulator &
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- name: Install python dependencies
run: pip install -r requirements.txt
- name: Set default toolchain
run: rustup default ${{ matrix.rust.version }}
- name: Set profile
run: rustup set profile minimal
- name: Update toolchain
run: rustup update
- name: Test
run: cargo test
6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ version = "0.1.3"
authors = ["Daniela Brozzoni <danielabrozzoni@protonmail.com>"]
edition = "2018"
license = "MIT"
description = "Rust wrapper for Bitcoin Core Hardware Wallet Interface."
repository = "https://github.com/MagicalBitcoin/rust-hwi"
description = "Rust wrapper for the Bitcoin Core Hardware Wallet Interface."
repository = "https://github.com/bitcoindevkit/rust-hwi"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bitcoin = { version = "0.28", features = ["use-serde", "base64"] }
serde = { version = "^1.0", features = ["derive"] }
serde_json = { version = "^1.0" }
strum_macros = "0.24.0"
base64 = "^0.13.0"
pyo3 = { version = "0.15.1", features = ["auto-initialize"]}

[dev-dependencies]
Expand Down
8 changes: 3 additions & 5 deletions ci/Dockerfile.ledger
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
FROM ghcr.io/ledgerhq/speculos

ADD btc.elf /speculos/btc.elf
RUN apt-get update
RUN apt-get install libusb-1.0-0-dev build-essential curl git -y
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
RUN pip install protobuf==3.20.1 hwi
RUN apt-get install wget -y
RUN wget "https://github.com/LedgerHQ/speculos/blob/master/apps/nanos%23btc%232.1%231c8db8da.elf?raw=true" -O /speculos/btc.elf
ADD automation.json /speculos/automation.json

ENTRYPOINT ["python", "./speculos.py", "--automation", "file:automation.json"]
ENTRYPOINT ["python", "./speculos.py", "--automation", "file:automation.json", "--display", "headless", "--vnc-port", "41000", "btc.elf"]
2 changes: 1 addition & 1 deletion ci/Dockerfile.trezor
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ RUN apt-get update
RUN apt-get install scons libsdl2-dev python3 python3-pip libsdl2-image-dev llvm-dev libclang-dev clang protobuf-compiler libusb-1.0-0-dev -y
RUN git clone --recursive https://github.com/trezor/trezor-firmware/ trezor-firmware
WORKDIR /trezor-firmware/core
RUN pip install poetry protobuf==3.20.1 hwi
RUN pip install poetry
RUN poetry install
RUN poetry run make build_unix
CMD ["poetry", "run", "./emu.py", "--headless", "--slip0014", "-q"]
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
hwi>=2.1.1,<3
hwi>=2.1.1,<3
protobuf==3.20.1
2 changes: 1 addition & 1 deletion src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use bitcoin::consensus::encode::serialize;
use bitcoin::util::bip32::DerivationPath;
use bitcoin::util::psbt::PartiallySignedTransaction;

use base64;
use bitcoin::base64;

use serde_json::value::Value;

Expand Down
2 changes: 1 addition & 1 deletion src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct HWISignature {

fn from_b64<'de, D: Deserializer<'de>>(d: D) -> Result<Vec<u8>, D::Error> {
let b64_string = String::deserialize(d)?;
base64::decode(&b64_string)
bitcoin::base64::decode(&b64_string)
.map_err(|_| serde::de::Error::custom("Error while Deserializing Signature"))
}

Expand Down