Skip to content

Commit

Permalink
chore: update nostr sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
thesimplekid committed Oct 24, 2024
1 parent 253e49b commit 9e375bd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
8 changes: 7 additions & 1 deletion crates/cdk-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ tracing = { version = "0.1", default-features = false, features = ["attributes",
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
rand = "0.8.5"
home = "0.5.5"
nostr-sdk = { version = "0.33.0", default-features = false, features = [
nostr-sdk = { version = "0.35.0", default-features = false, features = [
"nip04",
"nip44"
]}
reqwest = { version = "0.12", default-features = false, features = [
"json",
"rustls-tls",
"rustls-tls-native-roots",
"socks",
]}
url = "2.3"
17 changes: 11 additions & 6 deletions crates/cdk-cli/src/sub_commands/receive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,20 +184,25 @@ async fn nostr_receive(

let client = nostr_sdk::Client::default();

client.add_relays(relays).await?;

client.connect().await;

let events = client.get_events_of(vec![filter], None).await?;
let events = client
.get_events_of(
vec![filter],
nostr_sdk::EventSource::Relays {
timeout: None,
specific_relays: Some(relays),
},
)
.await?;

let mut tokens: HashSet<String> = HashSet::new();

let keys = Keys::from_str(&(nostr_signing_key).to_secret_hex())?;

for event in events {
if event.kind() == Kind::EncryptedDirectMessage {
if let Ok(msg) = nip04::decrypt(keys.secret_key()?, event.author_ref(), event.content())
{
if event.kind == Kind::EncryptedDirectMessage {
if let Ok(msg) = nip04::decrypt(keys.secret_key(), &event.pubkey, event.content) {
if let Some(token) = cdk::wallet::util::token_from_text(&msg) {
tokens.insert(token.to_string());
}
Expand Down

0 comments on commit 9e375bd

Please sign in to comment.