feat(cdk-cli): support nostr nsec secret keys

This commit is contained in:
thesimplekid
2024-07-15 15:43:47 +01:00
parent 6e22426c6a
commit 59ac008e50
2 changed files with 12 additions and 2 deletions

View File

@@ -33,6 +33,7 @@
- cdk(NUT-11): Add `Copy` on `SigFlag` ([thesimplekid]).
- cdk(wallet): Add `fn send_proofs` that marks proofs as `reserved` and creates token ([thesimplekid]).
- cdk(wallet): Add `fn melt_proofs` that uses specific proofs for `melt` instead of selecting ([thesimplekid]).
- cdk-cli(receive): Add support for signing keys to be nostr nsec encoded ([thesimplekid]).
### Fixed
- cdk(mint): `SIG_ALL` is not allowed in `melt` ([thesimplekid]).

View File

@@ -46,7 +46,15 @@ pub async fn receive(
let mut s_keys: Vec<SecretKey> = sub_command_args
.signing_key
.iter()
.map(|s| SecretKey::from_str(s).unwrap())
.flat_map(|s| {
if s.starts_with("nsec") {
let nostr_key = nostr_sdk::SecretKey::from_str(s).expect("Invalid secret key");
SecretKey::from_str(&nostr_key.to_secret_hex())
} else {
SecretKey::from_str(s)
}
})
.collect();
signing_keys.append(&mut s_keys);
}
@@ -67,7 +75,8 @@ pub async fn receive(
//wallet.add_p2pk_signing_key(nostr_signing_key).await;
let nostr_key = match sub_command_args.nostr_key.as_ref() {
Some(nostr_key) => {
let secret_key = SecretKey::from_str(nostr_key)?;
let secret_key = nostr_sdk::SecretKey::from_str(nostr_key)?;
let secret_key = SecretKey::from_str(&secret_key.to_secret_hex())?;
Some(secret_key)
}
None => None,