commit 14c59a6c944c448b0c38a537cb1a20124df7d189
parent 09238baee093a19f6594c9480a0f048e53ffa973
Author: kernelkind <kernelkind@gmail.com>
Date: Mon, 1 Sep 2025 14:11:34 -0400
introduce `PayCache`
Signed-off-by: kernelkind <kernelkind@gmail.com>
Diffstat:
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/crates/notedeck/src/zaps/cache.rs b/crates/notedeck/src/zaps/cache.rs
@@ -1,12 +1,19 @@
+use std::collections::HashMap;
+
use enostr::{NoteId, Pubkey};
use nostrdb::{Ndb, Transaction};
use nwc::nostr::nips::nip47::PayInvoiceResponse;
use poll_promise::Promise;
use tokio::task::JoinError;
+use url::Url;
use crate::{
get_wallet_for,
- zaps::{get_users_zap_address, ZapAddress},
+ zaps::{
+ get_users_zap_address,
+ networking::{LNUrlPayResponse, PayEntry},
+ ZapAddress,
+ },
Accounts, GlobalWallet, ZapError,
};
@@ -29,6 +36,23 @@ pub struct Zaps {
events: Vec<EventResponse>,
}
+/// Cache to hold LNURL payRequest responses from the desired LNURL endpoint
+#[derive(Default)]
+pub struct PayCache {
+ // endpoint URL to response
+ pub pay_responses: HashMap<Url, LNUrlPayResponse>,
+}
+
+impl PayCache {
+ pub fn get_response(&self, url: &Url) -> Option<&LNUrlPayResponse> {
+ self.pay_responses.get(url)
+ }
+
+ pub fn insert(&mut self, entry: PayEntry) {
+ self.pay_responses.insert(entry.url, entry.response);
+ }
+}
+
fn process_event(
id: ZapId,
event: ZapEvent,