Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 20 additions & 24 deletions cktap-ffi/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,15 @@ impl From<rust_cktap::DumpError> for DumpError {
#[derive(Clone, Debug, PartialEq, Eq, thiserror::Error, uniffi::Error)]
pub enum SignPsbtError {
#[error("Invalid path at index: {index}")]
InvalidPath { index: u64 },
InvalidPath { index: u32 },
#[error("Invalid script at index: {index}")]
InvalidScript { index: u64 },
InvalidScript { index: u32 },
#[error("Missing pubkey at index: {index}")]
MissingPubkey { index: u64 },
MissingPubkey { index: u32 },
#[error("Missing UTXO at index: {index}")]
MissingUtxo { index: u64 },
MissingUtxo { index: u32 },
#[error("Pubkey mismatch at index: {index}")]
PubkeyMismatch { index: u64 },
PubkeyMismatch { index: u32 },
#[error("Sighash error: {msg}")]
SighashError { msg: String },
#[error("Signature error: {msg}")]
Expand All @@ -300,21 +300,17 @@ pub enum SignPsbtError {
impl From<rust_cktap::SignPsbtError> for SignPsbtError {
fn from(value: rust_cktap::SignPsbtError) -> SignPsbtError {
match value {
rust_cktap::SignPsbtError::InvalidPath(index) => SignPsbtError::InvalidPath {
index: index as u64,
},
rust_cktap::SignPsbtError::InvalidScript(index) => SignPsbtError::InvalidScript {
index: index as u64,
},
rust_cktap::SignPsbtError::MissingPubkey(index) => SignPsbtError::MissingPubkey {
index: index as u64,
},
rust_cktap::SignPsbtError::MissingUtxo(index) => SignPsbtError::MissingUtxo {
index: index as u64,
},
rust_cktap::SignPsbtError::PubkeyMismatch(index) => SignPsbtError::PubkeyMismatch {
index: index as u64,
},
rust_cktap::SignPsbtError::InvalidPath(index) => SignPsbtError::InvalidPath { index },
rust_cktap::SignPsbtError::InvalidScript(index) => {
SignPsbtError::InvalidScript { index }
}
rust_cktap::SignPsbtError::MissingPubkey(index) => {
SignPsbtError::MissingPubkey { index }
}
rust_cktap::SignPsbtError::MissingUtxo(index) => SignPsbtError::MissingUtxo { index },
rust_cktap::SignPsbtError::PubkeyMismatch(index) => {
SignPsbtError::PubkeyMismatch { index }
}
rust_cktap::SignPsbtError::SighashError(msg) => SignPsbtError::SighashError { msg },
rust_cktap::SignPsbtError::SignatureError(msg) => SignPsbtError::SignatureError { msg },
rust_cktap::SignPsbtError::SlotNotUnsealed(slot) => {
Expand Down Expand Up @@ -349,9 +345,9 @@ pub enum ChangeError {
err: CkTapError,
},
#[error("new cvc is too short, must be at least 6 bytes, was only {len} bytes")]
TooShort { len: u64 },
TooShort { len: u8 },
#[error("new cvc is too long, must be at most 32 bytes, was {len} bytes")]
TooLong { len: u64 },
TooLong { len: u8 },
#[error("new cvc is the same as the old one")]
SameAsOld,
}
Expand All @@ -360,8 +356,8 @@ impl From<rust_cktap::ChangeError> for ChangeError {
fn from(value: rust_cktap::ChangeError) -> Self {
match value {
rust_cktap::ChangeError::CkTap(err) => ChangeError::CkTap { err: err.into() },
rust_cktap::ChangeError::TooShort(len) => ChangeError::TooShort { len: len as u64 },
rust_cktap::ChangeError::TooLong(len) => ChangeError::TooLong { len: len as u64 },
rust_cktap::ChangeError::TooShort(len) => ChangeError::TooShort { len },
rust_cktap::ChangeError::TooLong(len) => ChangeError::TooLong { len },
rust_cktap::ChangeError::SameAsOld => ChangeError::SameAsOld,
}
}
Expand Down
8 changes: 4 additions & 4 deletions cktap-ffi/src/sats_card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ pub struct SatsCard(pub Mutex<rust_cktap::SatsCard>);

#[derive(uniffi::Record, Debug, Clone)]
pub struct SatsCardStatus {
pub proto: u64,
pub proto: u32,
pub ver: String,
pub birth: u64,
pub birth: u32,
pub active_slot: u8,
pub num_slots: u8,
pub addr: Option<String>,
Expand All @@ -40,9 +40,9 @@ impl SatsCard {
let card = self.0.lock().await;
let pubkey = card.pubkey().to_string();
SatsCardStatus {
proto: card.proto as u64,
proto: card.proto,
ver: card.ver().to_string(),
birth: card.birth as u64,
birth: card.birth,
active_slot: card.slots.0,
num_slots: card.slots.1,
addr: card.addr.clone(),
Expand Down
15 changes: 6 additions & 9 deletions cktap-ffi/src/sats_chip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ pub struct SatsChip(pub Mutex<rust_cktap::SatsChip>);

#[derive(uniffi::Record, Debug, Clone)]
pub struct SatsChipStatus {
pub proto: u64,
pub proto: u32,
pub ver: String,
pub birth: u64,
pub path: Option<Vec<u64>>,
pub birth: u32,
pub path: Option<Vec<u32>>,
pub pubkey: String,
pub card_ident: String,
pub auth_delay: Option<u8>,
Expand All @@ -29,13 +29,10 @@ impl SatsChip {
pub async fn status(&self) -> SatsChipStatus {
let card = self.0.lock().await;
SatsChipStatus {
proto: card.proto as u64,
proto: card.proto,
ver: card.ver().to_string(),
birth: card.birth as u64,
path: card
.path
.clone()
.map(|p| p.iter().map(|&p| p as u64).collect()),
birth: card.birth,
path: card.path.clone(),
pubkey: card.pubkey().to_string(),
card_ident: card.card_ident(),
auth_delay: card.auth_delay(),
Expand Down
19 changes: 8 additions & 11 deletions cktap-ffi/src/tap_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ pub struct TapSigner(pub Mutex<rust_cktap::TapSigner>);

#[derive(uniffi::Record, Debug, Clone)]
pub struct TapSignerStatus {
pub proto: u64,
pub proto: u32,
pub ver: String,
pub birth: u64,
pub path: Option<Vec<u64>>,
pub num_backups: u64,
pub birth: u32,
pub path: Option<Vec<u32>>,
pub num_backups: u32,
pub pubkey: String,
pub card_ident: String,
pub auth_delay: Option<u8>,
Expand All @@ -31,14 +31,11 @@ impl TapSigner {
pub async fn status(&self) -> TapSignerStatus {
let card = self.0.lock().await;
TapSignerStatus {
proto: card.proto as u64,
proto: card.proto,
ver: card.ver().to_string(),
birth: card.birth as u64,
path: card
.path
.clone()
.map(|p| p.iter().map(|&p| p as u64).collect()),
num_backups: card.num_backups.unwrap_or_default() as u64,
birth: card.birth,
path: card.path.clone(),
num_backups: card.num_backups.unwrap_or_default(),
pubkey: card.pubkey().to_string(),
card_ident: card.card_ident(),
auth_delay: card.auth_delay(),
Expand Down
Loading
Loading