notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 2882b1c2d90e0a11bc8e0776e8be88dc6a8e2ea4
parent f4b8d235ebcbbd317ef143ded984a0ef5109029a
Author: kernelkind <kernelkind@gmail.com>
Date:   Mon,  1 Sep 2025 13:46:26 -0400

move `ZapAddress` to `zaps/mod.rs`

Signed-off-by: kernelkind <kernelkind@gmail.com>

Diffstat:
Mcrates/notedeck/src/zaps/cache.rs | 24+++++-------------------
Mcrates/notedeck/src/zaps/mod.rs | 24++++++++++++++++++++++++
2 files changed, 29 insertions(+), 19 deletions(-)

diff --git a/crates/notedeck/src/zaps/cache.rs b/crates/notedeck/src/zaps/cache.rs @@ -4,7 +4,11 @@ use nwc::nostr::nips::nip47::PayInvoiceResponse; use poll_promise::Promise; use tokio::task::JoinError; -use crate::{get_wallet_for, Accounts, GlobalWallet, ZapError}; +use crate::{ + get_wallet_for, + zaps::{get_users_zap_address, ZapAddress}, + Accounts, GlobalWallet, ZapError, +}; use super::{ networking::{fetch_invoice_lnurl, fetch_invoice_lud16, FetchedInvoice, FetchingInvoice}, @@ -139,24 +143,6 @@ fn send_note_zap( Some(promise) } -enum ZapAddress { - Lud16(String), - Lud06(String), -} - -fn get_users_zap_address(txn: &Transaction, ndb: &Ndb, receiver: &Pubkey) -> Option<ZapAddress> { - let profile = ndb - .get_profile_by_pubkey(txn, receiver.bytes()) - .ok()? - .record() - .profile()?; - - profile - .lud06() - .map(|l| ZapAddress::Lud06(l.to_string())) - .or(profile.lud16().map(|l| ZapAddress::Lud16(l.to_string()))) -} - fn try_get_promise_response( promises: &mut Vec<ZapPromise>, promise_index: usize, // this index must be guarenteed to exist diff --git a/crates/notedeck/src/zaps/mod.rs b/crates/notedeck/src/zaps/mod.rs @@ -11,3 +11,27 @@ pub use default_zap::{ get_current_default_msats, DefaultZapError, DefaultZapMsats, PendingDefaultZapState, UserZapMsats, }; +use enostr::Pubkey; +use nostrdb::{Ndb, Transaction}; + +pub enum ZapAddress { + Lud16(String), + Lud06(String), +} + +pub fn get_users_zap_address( + txn: &Transaction, + ndb: &Ndb, + receiver: &Pubkey, +) -> Option<ZapAddress> { + let profile = ndb + .get_profile_by_pubkey(txn, receiver.bytes()) + .ok()? + .record() + .profile()?; + + profile + .lud06() + .map(|l| ZapAddress::Lud06(l.to_string())) + .or(profile.lud16().map(|l| ZapAddress::Lud16(l.to_string()))) +}