Skip to content

Commit f68bae6

Browse files
Update README.md
- Add Github badges - Add MSRV (1.41.1) - Add an example - Delete supported commands - Delete tested devices
1 parent c92f3a0 commit f68bae6

File tree

1 file changed

+44
-57
lines changed

1 file changed

+44
-57
lines changed

README.md

Lines changed: 44 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# rust-hwi
2-
Rust wrapper for [HWI](https://github.com/bitcoin-core/HWI/).
2+
Rust wrapper for the [Bitcoin Hardware Wallet Interface](https://github.com/bitcoin-core/HWI/) library.
3+
4+
<a href="https://crates.io/crates/hwi"><img alt="Crate Info" src="https://img.shields.io/crates/v/hwi.svg"/></a>
5+
<a href="https://docs.rs/hwi"><img alt="API Docs" src="https://img.shields.io/badge/docs.rs-hwi-green"/></a>
6+
<a href="https://blog.rust-lang.org/2020/02/27/Rust-1.41.1.html"><img alt="Rustc Version 1.41+" src="https://img.shields.io/badge/rustc-1.41%2B-lightgrey.svg"/></a>
7+
<a href="https://discord.gg/d7NkDKm"><img alt="Chat on Discord" src="https://img.shields.io/discord/753336465005608961?logo=discord"></a>
8+
9+
This library internally uses PyO3 to call HWI's functions. It is not a re-implementation of HWI in native Rust.
310

411
## Prerequisites
512

@@ -24,7 +31,7 @@ brew install libusb
2431

2532
- Clone the repo
2633
```
27-
git clone https://github.com/MagicalBitcoin/rust-hwi.git && cd rust-hwi
34+
git clone https://github.com/bitcoindevkit/rust-hwi.git && cd rust-hwi
2835
```
2936

3037
- Create a virtualenv:
@@ -40,58 +47,38 @@ source venv/bin/activate
4047
pip install -r requirements.txt
4148
```
4249

43-
## Supported commands
44-
45-
| Command | Supported? |
46-
|:---:|:---: |
47-
| enumerate | YES |
48-
| getmasterxpub | YES |
49-
| signtx | YES |
50-
| getxpub | YES |
51-
| signmessage | YES |
52-
| getkeypool | YES |
53-
| getdescriptors | YES |
54-
| displayaddress | YES |
55-
| setup | Planned |
56-
| wipe | Planned |
57-
| restore | Planned |
58-
| backup | Planned |
59-
| promptpin | Planned |
60-
| sendpin | Planned |
61-
62-
| Flag | Supported? |
63-
|:---:|:---:|
64-
| --device-path | YES |
65-
| --device-type | YES |
66-
| --password | Planned |
67-
| --stdinpass | NO |
68-
| --testnet | Planned |
69-
| --debug | Planned |
70-
| --fingerprint | YES |
71-
| --version | Planned |
72-
| --stdin | NO |
73-
| --interactive | Planned |
74-
| --expert | YES |
75-
76-
## Tests
77-
78-
At the moment you'll need a HW plugged in to be able to run tests.
79-
80-
If you don't have a hardware wallet, you can try [coldcard simulator](https://github.com/Coldcard/firmware).
81-
82-
To run tests you should:
83-
84-
- Install requirements and activate the virtualenv, as specified before
85-
- Plug in a HW.
86-
- `cargo test`
87-
88-
## Devices tested
89-
| Device | Tested |
90-
|:---:|:---:|
91-
| Ledger Nano X | NO
92-
| Ledger Nano S | YES
93-
| Trezor One | NO
94-
| Trezor Model T | YES
95-
| Digital BitBox | NO
96-
| KeepKey | NO
97-
| Coldcard | YES
50+
## Usage
51+
52+
```rust
53+
use bitcoin::util::bip32::DerivationPath;
54+
use hwi::error::Error;
55+
use hwi::{interface, types, HWIClient};
56+
use std::str::FromStr;
57+
58+
fn main() -> Result<(), Error> {
59+
let devices = interface::HWIClient::enumerate()?;
60+
let device = devices.first().expect("No devices found");
61+
let client = HWIClient::get_client(
62+
&device,
63+
true,
64+
types::HWIChain::Test,
65+
)?;
66+
let derivation_path = DerivationPath::from_str("m/44'/1'/0'/0/0").unwrap();
67+
let s = client.sign_message("I love BDK wallet", &derivation_path)?;
68+
println!("{:?}", s.signature);
69+
Ok(())
70+
}
71+
```
72+
73+
## Testing
74+
75+
To run the tests, you need to have a hardware wallet plugged in. If you don't have a HW for testing, you can try:
76+
- [Coldcard simulator](https://github.com/Coldcard/firmware)
77+
- [Trezor simulator](https://docs.trezor.io/trezor-firmware/core/emulator/index.html)
78+
- [Ledger simulator](https://github.com/LedgerHQ/speculos)
79+
80+
**Don't use a device with funds for testing!**
81+
82+
Either use a testing device with no funds, or use a simulator.
83+
84+
You can run the tests with `cargo test`.

0 commit comments

Comments
 (0)