fixed load for non continuous run

This commit is contained in:
jonesmarvin8 2026-04-23 09:47:09 -04:00
parent 096522ebb9
commit 9f1c8bdf29
3 changed files with 23 additions and 31 deletions

View File

@ -71,15 +71,10 @@ class KeycardWallet:
mnemo = Mnemonic("english")
seed = mnemo.to_seed(mnemonic, passphrase)
print(f"PIN verified: {self.card.is_pin_verified}")
print(f"Secure channel open: {self.card.is_secure_channel_open}")
print(f"Card initialized: {self.card.status.get('initialized', False)}")
print(f"Seed length: {len(seed)}")
# Load the LEE seed onto the card
result = self.card.load_key(
key_type = constants.LoadKeyType.BIP39_SEED,
bip39_seed = seed
lee_seed = seed
)
return True
@ -125,7 +120,8 @@ class KeycardWallet:
signature = self.card.sign_with_path(
digest = message,
path= path,
path = path,
algorithm = constants.SigningAlgorithm.SCHNORR_BIP340,
make_current = False
)

View File

@ -11,19 +11,17 @@ use crate::{
#[derive(Subcommand, Debug, Clone)]
pub enum KeycardSubcommand {
Available,
Connect {
#[arg(
short,
long,
)]
pin: Option<String>,
},
Load {
#[arg(
short,
long,
)]
mnemonic: Option<String>,
#[arg(
short,
long,
)]
pin: Option<String>
},
}
@ -49,7 +47,7 @@ impl WalletSubcommand for KeycardSubcommand {
});
Ok(SubcommandReturnValue::Empty)
},
},/*
Self::Connect { pin } => {
// TODO This should be persistent.
Python::with_gil(|py| {
@ -67,27 +65,24 @@ impl WalletSubcommand for KeycardSubcommand {
});
Ok(SubcommandReturnValue::Empty)
},
Self::Load { mnemonic } => {
// TODO This should be persistent.
},*/
Self::Load { mnemonic, pin } => {
Python::with_gil(|py| {
python_path::add_python_path(py).expect("keycard_wallet.py not found");
let wallet = KeycardWallet::new(py).expect("Expect keycard wallet");
let _ = wallet.load_account_keys(py, &mnemonic.expect("TODO"));
});
let is_connected = wallet.setup_communication(py, pin.expect("TODO")).expect("Expect a Boolean.");
Ok(SubcommandReturnValue::Empty)
},
Self::Remove => {
// TODO This should be persistent.
Python::with_gil(|py| {
python_path::add_python_path(py).expect("keycard_wallet.py not found");
if is_connected {
println!("\u{2705} Keycard is now connected to wallet.");
} else {
println!("\u{274c} Keycard is not connected to wallet.");
}
let wallet = KeycardWallet::new(py).expect("Expect keycard wallet");
let _ = wallet.load_mnemonic(py, &mnemonic.expect("TODO"));
let _ = wallet.remove_account_keys(py);
let _ = wallet.disconnect(py);
});
Ok(SubcommandReturnValue::Empty)

View File

@ -57,15 +57,16 @@ impl KeycardWallet {
pub fn get_public_key_for_path(
&self,
py: Python,
path: &str,
path: Vec<u32>,
) -> PyResult<Option<[u8;32]>> {
let py_path = Self::convert_path_to_string(path);
let public_key: Vec<u8> = self.instance
.bind(py)
.call_method1("get_public_key_for_path", (py_message, path))?
.call_method1("get_public_key_for_path", (py_path,))?
.getattr("public_key")?
.extract()?;
Ok(Some(public_key.bytes()))
Ok(Some(public_key.try_into().expect("TODO")))
}
pub fn sign_message_with_path(&self, py: Python, path: Vec<u32>, message: &[u8; 32]) -> PyResult<[u8; 64]> {