@@ -1,12 +1,19 @@
|
|||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use enostr::{NoteId, Pubkey};
|
use enostr::{NoteId, Pubkey};
|
||||||
use nostrdb::{Ndb, Transaction};
|
use nostrdb::{Ndb, Transaction};
|
||||||
use nwc::nostr::nips::nip47::PayInvoiceResponse;
|
use nwc::nostr::nips::nip47::PayInvoiceResponse;
|
||||||
use poll_promise::Promise;
|
use poll_promise::Promise;
|
||||||
use tokio::task::JoinError;
|
use tokio::task::JoinError;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
get_wallet_for,
|
get_wallet_for,
|
||||||
zaps::{get_users_zap_address, ZapAddress},
|
zaps::{
|
||||||
|
get_users_zap_address,
|
||||||
|
networking::{LNUrlPayResponse, PayEntry},
|
||||||
|
ZapAddress,
|
||||||
|
},
|
||||||
Accounts, GlobalWallet, ZapError,
|
Accounts, GlobalWallet, ZapError,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -29,6 +36,23 @@ pub struct Zaps {
|
|||||||
events: Vec<EventResponse>,
|
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(
|
fn process_event(
|
||||||
id: ZapId,
|
id: ZapId,
|
||||||
event: ZapEvent,
|
event: ZapEvent,
|
||||||
|
|||||||
Reference in New Issue
Block a user