Skip to content

Commit c5b3c9d

Browse files
committed
Merge branch 'change-password'
2 parents 9fd2a05 + b78059e commit c5b3c9d

13 files changed

Lines changed: 87 additions & 5 deletions

CHANGELOG-npm.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 0.13.0
4+
- add `changePassword()` to change the device password (firmware >=9.25.0)
5+
36
## 0.12.0
47
- btc: add support for OP_RETURN outputs
58

CHANGELOG-rust.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 0.12.0
4+
- add `change_password()` to change the device password (firmware >=9.25.0)
5+
36
## 0.11.0
47
- btc: add support for OP_RETURN outputs
58

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "bitbox-api"
33
authors = ["Marko Bencun <benma@bitbox.swiss>"]
4-
version = "0.11.0"
4+
version = "0.12.0"
55
homepage = "https://bitbox.swiss/"
66
repository = "https://github.com/BitBoxSwiss/bitbox-api-rs/"
77
readme = "README-rust.md"

NPM_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.12.0
1+
0.13.0

messages/bitbox02_system.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,6 @@ message SetDeviceNameRequest {
6666
message SetPasswordRequest {
6767
bytes entropy = 1;
6868
}
69+
70+
message ChangePasswordRequest{
71+
}

messages/hww.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ message Request {
6969
CardanoRequest cardano = 27;
7070
BIP85Request bip85 = 28;
7171
BluetoothRequest bluetooth = 29;
72+
ChangePasswordRequest change_password = 30;
7273
}
7374
}
7475

sandbox/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sandbox/src/General.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,32 @@ function ShowMnemonic({ bb02 } : Props) {
8484
);
8585
}
8686

87+
function ChangePassword({ bb02 } : Props) {
88+
const [running, setRunning] = useState(false);
89+
const [err, setErr] = useState<bitbox.Error>();
90+
91+
const actionChangePassword = async (e: FormEvent) => {
92+
e.preventDefault();
93+
setRunning(true);
94+
setErr(undefined);
95+
try {
96+
await bb02.changePassword();
97+
} catch (err) {
98+
setErr(bitbox.ensureError(err));
99+
} finally {
100+
setRunning(false);
101+
}
102+
}
103+
104+
return (
105+
<>
106+
<h4>Change Password</h4>
107+
<button onClick={actionChangePassword} disabled={running}>Change password</button>
108+
<ShowError err={err} />
109+
</>
110+
);
111+
}
112+
87113
function Bip85AppBip39({ bb02 } : Props) {
88114
const [running, setRunning] = useState(false);
89115
const [err, setErr] = useState<bitbox.Error>();
@@ -125,6 +151,9 @@ export function General({ bb02 } : Props) {
125151
<div className="action">
126152
<Bip85AppBip39 bb02={bb02} />
127153
</div>
154+
<div className="action">
155+
<ChangePassword bb02={bb02} />
156+
</div>
128157
</>
129158
);
130159
}

src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,19 @@ impl<R: Runtime> PairedBitBox<R> {
402402
}
403403
}
404404

405+
/// Invokes the password change workflow on the device.
406+
/// Requires firmware version >=9.25.0.
407+
pub async fn change_password(&self) -> Result<(), Error> {
408+
self.validate_version(">=9.25.0")?;
409+
match self
410+
.query_proto(Request::ChangePassword(pb::ChangePasswordRequest {}))
411+
.await?
412+
{
413+
Response::Success(_) => Ok(()),
414+
_ => Err(Error::UnexpectedResponse),
415+
}
416+
}
417+
405418
/// Invokes the BIP85-BIP39 workflow on the device, letting the user select the number of words
406419
/// (12, 28, 24) and an index and display a derived BIP-39 mnemonic.
407420
pub async fn bip85_app_bip39(&self) -> Result<(), Error> {

0 commit comments

Comments
 (0)