Skip to content
Draft
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
11 changes: 10 additions & 1 deletion cktap-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::sats_chip::SatsChip;
use crate::tap_signer::TapSigner;
use futures::lock::Mutex;
use rust_cktap::shared::FactoryRootKey;
use rust_cktap::shared::{Certificate, Read};
use rust_cktap::shared::{Certificate, Read, Wait};
use std::fmt::Debug;
use std::sync::Arc;

Expand Down Expand Up @@ -84,3 +84,12 @@ async fn check_cert(card: &mut (impl Certificate + Send + Sync)) -> Result<(), C
}),
}
}

async fn wait_step(card: &mut (impl Wait + Send + Sync)) -> Result<Option<u8>, CkTapError> {
if card.auth_delay().is_none() {
return Ok(None);
}

let remaining_delay = card.wait(None).await.map_err(CkTapError::from)?;
Ok(remaining_delay.map(|delay| delay as u8))
}
8 changes: 7 additions & 1 deletion cktap-ffi/src/sats_card.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) 2025 rust-cktap contributors
// SPDX-License-Identifier: MIT OR Apache-2.0

use crate::check_cert;
use crate::error::{
CertsError, CkTapError, DeriveError, DumpError, ReadError, SignPsbtError, UnsealError,
};
use crate::{check_cert, wait_step};
use futures::lock::Mutex;
use rust_cktap::descriptor::Wpkh;
use rust_cktap::shared::{Authentication, Nfc, Read, Wait};
Expand Down Expand Up @@ -77,6 +77,12 @@ impl SatsCard {
Ok(())
}

/// Wait one second of auth delay and return the remaining delay, if any.
pub async fn wait_step(&self) -> Result<Option<u8>, CkTapError> {
let mut card = self.0.lock().await;
wait_step(&mut *card).await
}

/// Verify the card has authentic Coinkite root certificate
pub async fn check_cert(&self) -> Result<(), CertsError> {
let mut card = self.0.lock().await;
Expand Down
Loading
Loading