@@ -317,11 +317,12 @@ where
317317 F : std:: future:: Future < Output = Result < ( ) > > + Send ,
318318{
319319 let trade_keys = order_trade_keys. unwrap_or ( & ctx. trade_keys ) ;
320+ let trade_pubkey = trade_keys. public_key ( ) ;
320321 let mut notifications = ctx. client . notifications ( ) ;
321322 let opts =
322323 SubscribeAutoCloseOptions :: default ( ) . exit_policy ( ReqExitPolicy :: WaitForEventsAfterEOSE ( 1 ) ) ;
323324 let subscription = Filter :: new ( )
324- . pubkey ( trade_keys . public_key ( ) )
325+ . pubkey ( trade_pubkey )
325326 . kind ( nostr_sdk:: Kind :: GiftWrap )
326327 . limit ( 0 ) ;
327328 ctx. client . subscribe ( subscription, Some ( opts) ) . await ?;
@@ -340,11 +341,27 @@ where
340341 ctx. mostro_pubkey ,
341342 ) ) ;
342343
343- // Wait for the DM or gift wrap event
344+ // Wait for the DM or gift wrap event.
345+ //
346+ // `client.notifications()` is the **global** broadcast for every event
347+ // any active subscription / fetch sees — including the kind-38385 info
348+ // event coming back from the spawned PoW probe above. Without an
349+ // application-side filter, that info event would race ahead of the real
350+ // reply and short-circuit the wait, surfacing as "No response received
351+ // from Mostro" further downstream. So mirror the subscription filter
352+ // here and only accept GiftWraps tagged to our trade key.
344353 let waited = tokio:: time:: timeout ( super :: events:: FETCH_EVENTS_TIMEOUT , async move {
345354 loop {
346355 match notifications. recv ( ) . await {
347- Ok ( RelayPoolNotification :: Event { event, .. } ) => return Ok ( * event) ,
356+ Ok ( RelayPoolNotification :: Event { event, .. } ) => {
357+ if event. kind != nostr_sdk:: Kind :: GiftWrap {
358+ continue ;
359+ }
360+ if !event. tags . public_keys ( ) . any ( |pk| * pk == trade_pubkey) {
361+ continue ;
362+ }
363+ return Ok ( * event) ;
364+ }
348365 Ok ( _) => continue ,
349366 Err ( e) => {
350367 return Err ( anyhow:: anyhow!( "Error receiving notification: {:?}" , e) ) ;
0 commit comments