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
3 changes: 3 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Repository instructions

Read [README.md](README.md) before making changes to this repository.
35 changes: 25 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# BitBox02 Go library

The API of the api packages are currenly unstable. Expect frequent breaking changes until we start
tagging versions.
The API exposed by the `api` packages is currently unstable. Expect frequent breaking changes until
we start tagging versions.

## Comand to update the BitBox02 protobuf message files

Clone the [BitBox02 firmware repo](https://github.com/BitBoxSwiss/bitbox02-firmware):
## Updating the BitBox02 protobuf message files

Make sure you have `protoc` and
[protoc-gen-go](https://developers.google.com/protocol-buffers/docs/reference/go-generated)
installed:
installed, then clone the [BitBox02 firmware repository](https://github.com/BitBoxSwiss/bitbox02-firmware):

`git clone https://github.com/BitBoxSwiss/bitbox02-firmware.git`

Expand All @@ -20,11 +18,28 @@ rm api/firmware/messages/backup.proto
./api/firmware/messages/generate.sh
```

## Updating the Bitcoin transaction test vectors

The vectors in [api/firmware/testdata/btc-transaction-test-vectors.json](api/firmware/testdata/btc-transaction-test-vectors.json)
are generated in the BitBox02 firmware repository. Do not modify this JSON file directly.

The source of truth is the Rust constructors in
[`src/rust/bitbox-test-vectors/src/btc_transaction/cases/`](https://github.com/BitBoxSwiss/bitbox02-firmware/tree/master/src/rust/bitbox-test-vectors/src/btc_transaction/cases).
Make changes there and regenerate the canonical JSON following the
[test vector generation instructions](https://github.com/BitBoxSwiss/bitbox02-firmware/blob/master/src/rust/bitbox-test-vectors/README.md).
Then copy the generated file byte-for-byte into this repository:

```sh
cp /path/to/bitbox02-firmware/src/rust/bitbox-test-vectors/testdata/btc-transaction-test-vectors.json \
api/firmware/testdata/btc-transaction-test-vectors.json
```

## Simulator tests

The `TestSimulator*` tests run integration against BitBox02 simulators. They are automatically
downloaded based on [api/firmware/testdata/simulators.json](api/firmware/testdata/simulators.json),
and each one is tested with.
The `TestSimulator*` integration tests run against BitBox02 simulators. The simulators are
automatically downloaded based on
[api/firmware/testdata/simulators.json](api/firmware/testdata/simulators.json), and the tests run
against each one.

To run them, use:

Expand All @@ -35,5 +50,5 @@ you can run:

SIMULATOR=/path/to/simulator go test -v -run TestSimulator ./...

In this case, only the given simulator will be used, and the ones defined in simulators.json will be
In this case, only the given simulator will be used, and the ones defined in `simulators.json` will be
ignored. Make sure to use an absolute path to the simulator.
Loading