diff --git a/crates/cdk-cli/src/sub_commands/receive.rs b/crates/cdk-cli/src/sub_commands/receive.rs index fcc13871..1deafcd5 100644 --- a/crates/cdk-cli/src/sub_commands/receive.rs +++ b/crates/cdk-cli/src/sub_commands/receive.rs @@ -10,15 +10,18 @@ use clap::Args; pub struct ReceiveSubCommand { /// Cashu Token token: Option, - /// Nostr key - #[arg(short, long)] - nostr_key: Option, /// Signing Key #[arg(short, long, action = clap::ArgAction::Append)] signing_key: Vec, + /// Nostr key + #[arg(short, long)] + nostr_key: Option, /// Nostr relay #[arg(short, long, action = clap::ArgAction::Append)] relay: Vec, + /// Unix time to to query nostr from + #[arg(short, long)] + since: Option, /// Preimage #[arg(short, long, action = clap::ArgAction::Append)] preimage: Vec, @@ -58,7 +61,7 @@ pub async fn receive(wallet: Wallet, sub_command_args: &ReceiveSubCommand) -> Re .add_nostr_relays(sub_command_args.relay.clone()) .await?; wallet - .nostr_receive(nostr_key, SplitTarget::default()) + .nostr_receive(nostr_key, sub_command_args.since, SplitTarget::default()) .await? } None => { diff --git a/crates/cdk/src/wallet/mod.rs b/crates/cdk/src/wallet/mod.rs index b89e38b8..e81620b9 100644 --- a/crates/cdk/src/wallet/mod.rs +++ b/crates/cdk/src/wallet/mod.rs @@ -1410,6 +1410,7 @@ impl Wallet { pub async fn nostr_receive( &self, nostr_signing_key: SecretKey, + since: Option, amount_split_target: SplitTarget, ) -> Result { use nostr_sdk::{Keys, Kind}; @@ -1423,15 +1424,20 @@ impl Wallet { let keys = Keys::from_str(&(nostr_signing_key).to_secret_hex())?; self.add_p2pk_signing_key(nostr_signing_key).await; - let filter = match self - .localstore - .get_nostr_last_checked(&verifying_key) - .await? - { + let since = match since { + Some(since) => Some(Timestamp::from(since)), + None => self + .localstore + .get_nostr_last_checked(&verifying_key) + .await? + .map(|s| Timestamp::from(s as u64)), + }; + + let filter = match since { Some(since) => Filter::new() .pubkey(nostr_pubkey) .kind(Kind::EncryptedDirectMessage) - .since(Timestamp::from(since as u64)), + .since(since), None => Filter::new() .pubkey(nostr_pubkey) .kind(Kind::EncryptedDirectMessage),