Skip to content

Commit d6490ca

Browse files
committed
Merge branch 'bip85'
2 parents fd71312 + f871c8e commit d6490ca

File tree

9 files changed

+64
-5
lines changed

9 files changed

+64
-5
lines changed

CHANGELOG-npm.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## [Unreleased]
4+
- Add `bip85AppBip39()`
5+
36
## 0.9.1
47
- WebHID: Automatically connect to a previoulsy connected device
58

CHANGELOG-rust.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## [Unreleased]
4+
- Add `bip85_app_bip39()`
5+
36
## 0.7.0
47
- cardano: add support for 258-tagged sets
58

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "bitbox-api"
33
authors = ["Marko Bencun <[email protected]>"]
4-
version = "0.7.0"
4+
version = "0.8.0"
55
homepage = "https://bitbox.swiss/"
66
repository = "https://github.com/BitBoxSwiss/bitbox-api-rs/"
77
readme = "README-rust.md"

NPM_VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.9.1
1+
0.10.0

sandbox/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sandbox/src/General.tsx

+29
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,32 @@ function ShowMnemonic({ bb02 } : Props) {
8282
);
8383
}
8484

85+
function Bip85AppBip39({ bb02 } : Props) {
86+
const [running, setRunning] = useState(false);
87+
const [err, setErr] = useState<bitbox.Error>();
88+
89+
const actionBip85 = async (e: FormEvent) => {
90+
e.preventDefault();
91+
setRunning(true);
92+
setErr(undefined);
93+
try {
94+
await bb02.bip85AppBip39();
95+
} catch (err) {
96+
setErr(bitbox.ensureError(err));
97+
} finally {
98+
setRunning(false);
99+
}
100+
}
101+
102+
return (
103+
<>
104+
<h4>BIP-85</h4>
105+
<button onClick={actionBip85} disabled={running}>Invoke BIP-85 (BIP-39 app)</button>
106+
<ShowError err={err} />
107+
</>
108+
);
109+
}
110+
85111
export function General({ bb02 } : Props) {
86112
return (
87113
<>
@@ -94,6 +120,9 @@ export function General({ bb02 } : Props) {
94120
<div className="action">
95121
<ShowMnemonic bb02={bb02} />
96122
</div>
123+
<div className="action">
124+
<Bip85AppBip39 bb02={bb02} />
125+
</div>
97126
</>
98127
);
99128
}

src/lib.rs

+17
Original file line numberDiff line numberDiff line change
@@ -392,4 +392,21 @@ impl<R: Runtime> PairedBitBox<R> {
392392
_ => Err(Error::UnexpectedResponse),
393393
}
394394
}
395+
396+
/// Invokes the BIP85-BIP39 workflow on the device, letting the user select the number of words
397+
/// (12, 28, 24) and an index and display a derived BIP-39 mnemonic.
398+
pub async fn bip85_app_bip39(&self) -> Result<(), Error> {
399+
self.validate_version(">=9.17.0")?;
400+
match self
401+
.query_proto(Request::Bip85(pb::Bip85Request {
402+
app: Some(pb::bip85_request::App::Bip39(())),
403+
}))
404+
.await?
405+
{
406+
Response::Bip85(pb::Bip85Response {
407+
app: Some(pb::bip85_response::App::Bip39(())),
408+
}) => Ok(()),
409+
_ => Err(Error::UnexpectedResponse),
410+
}
411+
}
395412
}

src/wasm/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,13 @@ impl PairedBitBox {
563563
let result = self.device.cardano_sign_transaction(tt).await?;
564564
Ok(serde_wasm_bindgen::to_value(&result).unwrap().into())
565565
}
566+
567+
/// Invokes the BIP85-BIP39 workflow on the device, letting the user select the number of words
568+
/// (12, 28, 24) and an index and display a derived BIP-39 mnemonic.
569+
#[wasm_bindgen(js_name = bip85AppBip39)]
570+
pub async fn bip85_app_bip39(&self) -> Result<(), JavascriptError> {
571+
Ok(self.device.bip85_app_bip39().await?)
572+
}
566573
}
567574

568575
#[cfg(test)]

0 commit comments

Comments
 (0)