mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-23 23:55:01 +01:00
feat: add since to nostr-receive
This commit is contained in:
@@ -10,15 +10,18 @@ use clap::Args;
|
|||||||
pub struct ReceiveSubCommand {
|
pub struct ReceiveSubCommand {
|
||||||
/// Cashu Token
|
/// Cashu Token
|
||||||
token: Option<String>,
|
token: Option<String>,
|
||||||
/// Nostr key
|
|
||||||
#[arg(short, long)]
|
|
||||||
nostr_key: Option<String>,
|
|
||||||
/// Signing Key
|
/// Signing Key
|
||||||
#[arg(short, long, action = clap::ArgAction::Append)]
|
#[arg(short, long, action = clap::ArgAction::Append)]
|
||||||
signing_key: Vec<String>,
|
signing_key: Vec<String>,
|
||||||
|
/// Nostr key
|
||||||
|
#[arg(short, long)]
|
||||||
|
nostr_key: Option<String>,
|
||||||
/// Nostr relay
|
/// Nostr relay
|
||||||
#[arg(short, long, action = clap::ArgAction::Append)]
|
#[arg(short, long, action = clap::ArgAction::Append)]
|
||||||
relay: Vec<String>,
|
relay: Vec<String>,
|
||||||
|
/// Unix time to to query nostr from
|
||||||
|
#[arg(short, long)]
|
||||||
|
since: Option<u64>,
|
||||||
/// Preimage
|
/// Preimage
|
||||||
#[arg(short, long, action = clap::ArgAction::Append)]
|
#[arg(short, long, action = clap::ArgAction::Append)]
|
||||||
preimage: Vec<String>,
|
preimage: Vec<String>,
|
||||||
@@ -58,7 +61,7 @@ pub async fn receive(wallet: Wallet, sub_command_args: &ReceiveSubCommand) -> Re
|
|||||||
.add_nostr_relays(sub_command_args.relay.clone())
|
.add_nostr_relays(sub_command_args.relay.clone())
|
||||||
.await?;
|
.await?;
|
||||||
wallet
|
wallet
|
||||||
.nostr_receive(nostr_key, SplitTarget::default())
|
.nostr_receive(nostr_key, sub_command_args.since, SplitTarget::default())
|
||||||
.await?
|
.await?
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
|
|||||||
@@ -1410,6 +1410,7 @@ impl Wallet {
|
|||||||
pub async fn nostr_receive(
|
pub async fn nostr_receive(
|
||||||
&self,
|
&self,
|
||||||
nostr_signing_key: SecretKey,
|
nostr_signing_key: SecretKey,
|
||||||
|
since: Option<u64>,
|
||||||
amount_split_target: SplitTarget,
|
amount_split_target: SplitTarget,
|
||||||
) -> Result<Amount, Error> {
|
) -> Result<Amount, Error> {
|
||||||
use nostr_sdk::{Keys, Kind};
|
use nostr_sdk::{Keys, Kind};
|
||||||
@@ -1423,15 +1424,20 @@ impl Wallet {
|
|||||||
let keys = Keys::from_str(&(nostr_signing_key).to_secret_hex())?;
|
let keys = Keys::from_str(&(nostr_signing_key).to_secret_hex())?;
|
||||||
self.add_p2pk_signing_key(nostr_signing_key).await;
|
self.add_p2pk_signing_key(nostr_signing_key).await;
|
||||||
|
|
||||||
let filter = match self
|
let since = match since {
|
||||||
.localstore
|
Some(since) => Some(Timestamp::from(since)),
|
||||||
.get_nostr_last_checked(&verifying_key)
|
None => self
|
||||||
.await?
|
.localstore
|
||||||
{
|
.get_nostr_last_checked(&verifying_key)
|
||||||
|
.await?
|
||||||
|
.map(|s| Timestamp::from(s as u64)),
|
||||||
|
};
|
||||||
|
|
||||||
|
let filter = match since {
|
||||||
Some(since) => Filter::new()
|
Some(since) => Filter::new()
|
||||||
.pubkey(nostr_pubkey)
|
.pubkey(nostr_pubkey)
|
||||||
.kind(Kind::EncryptedDirectMessage)
|
.kind(Kind::EncryptedDirectMessage)
|
||||||
.since(Timestamp::from(since as u64)),
|
.since(since),
|
||||||
None => Filter::new()
|
None => Filter::new()
|
||||||
.pubkey(nostr_pubkey)
|
.pubkey(nostr_pubkey)
|
||||||
.kind(Kind::EncryptedDirectMessage),
|
.kind(Kind::EncryptedDirectMessage),
|
||||||
|
|||||||
Reference in New Issue
Block a user