@@ -602,28 +602,38 @@ impl NostrWalletConnect {
602602 . label
603603 . clone ( )
604604 . unwrap_or ( self . profile . name . clone ( ) ) ;
605- let invoice = node. create_invoice ( amount_sats, vec ! [ label] ) . await ?;
606- let bolt11 = invoice. bolt11 . expect ( "just made" ) ;
607605
608- let content = Response {
609- result_type : Method :: MakeInvoice ,
610- error : None ,
611- result : Some ( ResponseResult :: MakeInvoice ( MakeInvoiceResponseResult {
612- invoice : bolt11. to_string ( ) ,
613- payment_hash : bolt11. payment_hash ( ) . to_string ( ) ,
614- } ) ) ,
615- } ;
606+ let response = match node. create_invoice ( amount_sats, vec ! [ label] ) . await {
607+ Err ( e) => self . get_skipped_error_event (
608+ & event,
609+ Method :: MakeInvoice ,
610+ ErrorCode :: Other ,
611+ format ! ( "Failed to create invoice: {:?}" , e) ,
612+ ) ?,
613+ Ok ( invoice) => {
614+ let bolt11 = invoice. bolt11 . expect ( "just made" ) ;
615+
616+ let content = Response {
617+ result_type : Method :: MakeInvoice ,
618+ error : None ,
619+ result : Some ( ResponseResult :: MakeInvoice ( MakeInvoiceResponseResult {
620+ invoice : bolt11. to_string ( ) ,
621+ payment_hash : bolt11. payment_hash ( ) . to_string ( ) ,
622+ } ) ) ,
623+ } ;
616624
617- let encrypted = encrypt (
618- self . server_key . secret_key ( ) ?,
619- & self . client_key . public_key ( ) ,
620- content. as_json ( ) ,
621- ) ?;
625+ let encrypted = encrypt (
626+ self . server_key . secret_key ( ) ?,
627+ & self . client_key . public_key ( ) ,
628+ content. as_json ( ) ,
629+ ) ?;
622630
623- let p_tag = Tag :: public_key ( event. pubkey ) ;
624- let e_tag = Tag :: event ( event. id ) ;
625- let response = EventBuilder :: new ( Kind :: WalletConnectResponse , encrypted, [ p_tag, e_tag] )
626- . to_event ( & self . server_key ) ?;
631+ let p_tag = Tag :: public_key ( event. pubkey ) ;
632+ let e_tag = Tag :: event ( event. id ) ;
633+ EventBuilder :: new ( Kind :: WalletConnectResponse , encrypted, [ p_tag, e_tag] )
634+ . to_event ( & self . server_key ) ?
635+ }
636+ } ;
627637
628638 Ok ( Some ( response) )
629639 }
0 commit comments