Skip to content

Commit 7d67897

Browse files
authored
Merge pull request #51 from Foundation-Devices/better-encoding
better encoding
2 parents f3f6405 + 582d9c4 commit 7d67897

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

api/src/api/backup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub struct BackupChunk {
7575
pub chunk_index: u32,
7676
#[n(1)]
7777
pub total_chunks: u32,
78-
#[n(2)]
78+
#[cbor(n(2), with = "minicbor::bytes")]
7979
pub data: Vec<u8>,
8080
}
8181

api/src/api/bitcoin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ pub struct SignPsbt {
1212
pub struct AccountUpdate {
1313
#[n(0)]
1414
pub account_id: String,
15-
#[n(1)]
15+
#[cbor(n(1), with = "minicbor::bytes")]
1616
pub update: Vec<u8>,
1717
}
1818

1919
#[quantum_link]
2020
pub struct BroadcastTransaction {
2121
#[n(0)]
2222
pub account_id: String,
23-
#[n(1)]
23+
#[cbor(n(1), with = "minicbor::bytes")]
2424
pub psbt: Vec<u8>,
2525
}
2626

api/src/api/firmware.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ pub enum FirmwareFetchEvent {
5252
// envoy is sending a chunk for an update patch
5353
#[n(3)]
5454
Chunk(#[n(0)] FirmwareChunk),
55-
// envoy has sent all the update patches
56-
#[n(4)]
57-
Complete,
5855
// envoy failed
5956
#[n(5)]
6057
Error(#[n(0)] String),
@@ -71,10 +68,16 @@ pub struct FirmwareChunk {
7168
pub chunk_index: u16,
7269
#[n(3)]
7370
pub total_chunks: u16,
74-
#[n(4)]
71+
#[cbor(n(4), with = "minicbor::bytes")]
7572
pub data: Vec<u8>,
7673
}
7774

75+
impl FirmwareChunk {
76+
pub fn is_last(&self) -> bool {
77+
self.patch_index == self.total_patches - 1 && self.chunk_index == self.total_chunks - 1
78+
}
79+
}
80+
7881
#[quantum_link]
7982
pub enum FirmwareUpdateResult {
8083
#[n(0)]

api/src/api/pairing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub struct PairingResponse {
2121

2222
#[quantum_link]
2323
pub struct PairingRequest {
24-
#[n(0)]
24+
#[cbor(n(0), with = "minicbor::bytes")]
2525
pub xid_document: Vec<u8>,
2626
#[n(1)]
2727
pub device_name: String,

api/src/api/scv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ pub enum SecurityCheck {
1818

1919
#[quantum_link]
2020
pub struct ChallengeRequest {
21-
#[n(0)]
21+
#[cbor(n(0), with = "minicbor::bytes")]
2222
pub data: Vec<u8>,
2323
}
2424

2525
#[quantum_link]
2626
pub enum ChallengeResponseResult {
2727
#[n(0)]
2828
Success {
29-
#[n(0)]
29+
#[cbor(n(0), with = "minicbor::bytes")]
3030
data: Vec<u8>,
3131
},
3232
#[n(1)]

0 commit comments

Comments
 (0)