@@ -6,6 +6,7 @@ use crate::nostr::nwc::{
66    PendingNwcInvoice ,  Profile ,  SingleUseSpendingConditions ,  SpendingConditions , 
77    PENDING_NWC_EVENTS_KEY , 
88} ; 
9+ use  crate :: notifications:: MutinyNotificationClient ; 
910use  crate :: storage:: MutinyStorage ; 
1011use  crate :: { error:: MutinyError ,  utils:: get_random_bip32_child_index} ; 
1112use  crate :: { utils,  HTLCStatus } ; 
@@ -69,6 +70,8 @@ pub struct NostrManager<S: MutinyStorage> {
6970    pub  storage :  S , 
7071    /// Lock for pending nwc invoices 
7172pending_nwc_lock :  Arc < Mutex < ( ) > > , 
73+     /// Notification Client 
74+ pub  notifications :  Option < Arc < MutinyNotificationClient > > , 
7275    /// Logger 
7376pub  logger :  Arc < MutinyLogger > , 
7477} 
@@ -350,6 +353,17 @@ impl<S: MutinyStorage> NostrManager<S> {
350353            let  _ = client. disconnect ( ) . await ; 
351354        } 
352355
356+         // register for subscriptions 
357+         if  let  Some ( notifications)  = & self . notifications  { 
358+             // just created, unwrap is safe 
359+             let  uri = NostrWalletConnectURI :: from_str ( & profile. nwc_uri ) . expect ( "invalid uri" ) ; 
360+             let  author = uri. secret . x_only_public_key ( nostr:: SECP256K1 ) . 0 ; 
361+ 
362+             notifications
363+                 . register_nwc ( author,  uri. public_key ,  & profile. relay ,  & profile. name ) 
364+                 . await ?; 
365+         } 
366+ 
353367        Ok ( profile) 
354368    } 
355369
@@ -840,6 +854,7 @@ impl<S: MutinyStorage> NostrManager<S> {
840854pub  fn  from_mnemonic ( 
841855        xprivkey :  ExtendedPrivKey , 
842856        storage :  S , 
857+         notifications :  Option < Arc < MutinyNotificationClient > > , 
843858        logger :  Arc < MutinyLogger > , 
844859    )  -> Result < Self ,  MutinyError >  { 
845860        let  context = Secp256k1 :: new ( ) ; 
@@ -862,6 +877,7 @@ impl<S: MutinyStorage> NostrManager<S> {
862877            nwc :  Arc :: new ( RwLock :: new ( nwc) ) , 
863878            storage, 
864879            pending_nwc_lock :  Arc :: new ( Mutex :: new ( ( ) ) ) , 
880+             notifications, 
865881            logger, 
866882        } ) 
867883    } 
@@ -889,7 +905,7 @@ mod test {
889905
890906        let  logger = Arc :: new ( MutinyLogger :: default ( ) ) ; 
891907
892-         NostrManager :: from_mnemonic ( xprivkey,  storage,  logger) . unwrap ( ) 
908+         NostrManager :: from_mnemonic ( xprivkey,  storage,  None ,   logger) . unwrap ( ) 
893909    } 
894910
895911    #[ test]  
0 commit comments