Skip to content

Commit 847f45c

Browse files
committed
Merge branch 'data-warn'
2 parents e081ac1 + 8291e77 commit 847f45c

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- RestoreFrommnemonic: ported to Rust. Will now return UserAbortError on user abort instead of GenericError.
55
- Anti-klepto support for ETH transaction signing and for BTC and ETH message signing.
66
- Add Uniswap ERC-20 token.
7+
- Display warning before confirming raw ETH data.
78

89
## 9.4.0 [released 2021-01-20]
910
- ETHPubRequest api call now fails if a an invalid contract address is provided also if `display` is

src/rust/bitbox02-rust/src/hww/api/ethereum/sign.rs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,21 @@ async fn verify_standard_transaction(
138138
let recipient = parse_recipient(&request.recipient)?;
139139

140140
if !request.data.is_empty() {
141+
confirm::confirm(&confirm::Params {
142+
title: "Unknown\ncontract",
143+
body: "You will be shown\nthe raw\ntransaction data.",
144+
accept_is_nextarrow: true,
145+
..Default::default()
146+
})
147+
.await?;
148+
confirm::confirm(&confirm::Params {
149+
title: "Unknown\ncontract",
150+
body: "Only proceed if you\nunderstand exactly\nwhat the data means.",
151+
accept_is_nextarrow: true,
152+
..Default::default()
153+
})
154+
.await?;
155+
141156
confirm::confirm(&confirm::Params {
142157
title: "Transaction\ndata",
143158
body: &hex::encode(&request.data),
@@ -367,14 +382,21 @@ mod tests {
367382
let _guard = MUTEX.lock().unwrap();
368383

369384
const KEYPATH: &[u32] = &[44 + HARDENED, 60 + HARDENED, 0 + HARDENED, 0, 0];
370-
385+
static mut CONFIRM_COUNTER: u32 = 0;
371386
mock(Data {
372387
ui_confirm_create: Some(Box::new(|params| {
373-
assert_eq!(params.title, "Transaction\ndata");
374-
assert_eq!(params.body, "666f6f20626172"); // "foo bar" in hex.
375-
assert!(params.scrollable);
376-
assert_eq!(params.display_size, 7); // length of "foo bar"
377-
assert!(params.accept_is_nextarrow);
388+
match unsafe { CONFIRM_COUNTER } {
389+
0 | 1 => assert_eq!(params.title, "Unknown\ncontract"),
390+
2 => {
391+
assert_eq!(params.title, "Transaction\ndata");
392+
assert_eq!(params.body, "666f6f20626172"); // "foo bar" in hex.
393+
assert!(params.scrollable);
394+
assert_eq!(params.display_size, 7); // length of "foo bar"
395+
assert!(params.accept_is_nextarrow);
396+
}
397+
_ => panic!("too many user confirmations"),
398+
}
399+
unsafe { CONFIRM_COUNTER += 1 }
378400
true
379401
})),
380402
ui_transaction_address_create: Some(Box::new(|amount, address| {

0 commit comments

Comments
 (0)