@@ -108,6 +108,12 @@ pub struct Mnemonic {
108108 inner : bip39:: Mnemonic ,
109109}
110110
111+ impl std:: fmt:: Display for Mnemonic {
112+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
113+ write ! ( f, "{}" , self . inner)
114+ }
115+ }
116+
111117#[ uniffi:: export]
112118impl Mnemonic {
113119 #[ uniffi:: constructor]
@@ -120,7 +126,7 @@ impl Mnemonic {
120126 let secp = bitcoin:: secp256k1:: Secp256k1 :: new ( ) ;
121127
122128 let seed = self . inner . to_seed ( "" ) ;
123- let path = format ! ( "m/44'/1237'/0'/0/0" ) ;
129+ let path = "m/44'/1237'/0'/0/0" . to_string ( ) ;
124130 let xprv = bip32:: Xpriv :: new_master ( bitcoin:: Network :: Bitcoin , & seed)
125131 . map_err ( |_| MnemonicError :: InvalidMnemonic ) ?;
126132 let private_key = xprv
@@ -151,10 +157,6 @@ impl Mnemonic {
151157
152158 xpriv. private_key . secret_bytes ( ) . to_vec ( )
153159 }
154-
155- pub fn to_string ( & self ) -> String {
156- self . inner . to_string ( )
157- }
158160}
159161
160162#[ derive( Debug , PartialEq , thiserror:: Error , uniffi:: Error ) ]
@@ -214,7 +216,7 @@ impl Keypair {
214216 }
215217
216218 pub fn subkey_proof ( & self ) -> Option < SubkeyProof > {
217- self . inner . subkey_proof ( ) . map ( |p| p . clone ( ) )
219+ self . inner . subkey_proof ( ) . cloned ( )
218220 }
219221
220222 pub fn nsec ( & self ) -> Result < String , KeypairError > {
@@ -229,8 +231,8 @@ impl Keypair {
229231 expires_in_hours : i64 ,
230232 ) -> Result < String , KeypairError > {
231233 let token = portal:: protocol:: jwt:: encode (
232- & self . inner . secret_key ( ) ,
233- CustomClaims :: new ( target_key. into ( ) ) ,
234+ self . inner . secret_key ( ) ,
235+ CustomClaims :: new ( target_key) ,
234236 Duration :: hours ( expires_in_hours) ,
235237 )
236238 . map_err ( |e| KeypairError :: JwtError ( e. to_string ( ) ) ) ?;
@@ -570,12 +572,11 @@ impl PortalApp {
570572 let pool_relays = self . relay_pool . all_relays ( ) . await ;
571573 for relay in new_relays {
572574 let relay = pool_relays. iter ( ) . find ( |( url, _) | url. to_string ( ) == relay) ;
573- if let Some ( ( url, relay) ) = relay {
574- if !relay. flags ( ) . has_read ( ) {
575+ if let Some ( ( url, relay) ) = relay
576+ && !relay. flags ( ) . has_read ( ) {
575577 self . router . remove_relay ( url. to_string ( ) ) . await ?;
576578 self . relay_pool . disconnect_relay ( url) . await ?;
577579 }
578- }
579580 }
580581
581582 Ok ( ( ) )
@@ -599,7 +600,7 @@ impl PortalApp {
599600 event : AuthChallengeEvent ,
600601 status : AuthResponseStatus ,
601602 ) -> Result < ( ) , AppError > {
602- let recipient = event. recipient . clone ( ) ;
603+ let recipient = event. recipient ;
603604
604605 let conv = AuthResponseConversation :: new (
605606 event,
@@ -632,17 +633,17 @@ impl PortalApp {
632633 match & request. content {
633634 PaymentRequestContent :: Single ( content) => {
634635 Ok ( IncomingPaymentRequest :: Single ( SinglePaymentRequest {
635- service_key : request. service_key . clone ( ) ,
636- recipient : request. recipient . clone ( ) ,
636+ service_key : request. service_key ,
637+ recipient : request. recipient ,
637638 expires_at : request. expires_at ,
638639 content : content. clone ( ) ,
639640 event_id : request. event_id . clone ( ) ,
640641 } ) )
641642 }
642643 PaymentRequestContent :: Recurring ( content) => {
643644 Ok ( IncomingPaymentRequest :: Recurring ( RecurringPaymentRequest {
644- service_key : request. service_key . clone ( ) ,
645- recipient : request. recipient . clone ( ) ,
645+ service_key : request. service_key ,
646+ recipient : request. recipient ,
646647 expires_at : request. expires_at ,
647648 content : content. clone ( ) ,
648649 event_id : request. event_id . clone ( ) ,
@@ -657,8 +658,8 @@ impl PortalApp {
657658 status : PaymentResponseContent ,
658659 ) -> Result < ( ) , AppError > {
659660 let conv = PaymentStatusSenderConversation :: new (
660- request. service_key . clone ( ) . into ( ) ,
661- request. recipient . clone ( ) . into ( ) ,
661+ request. service_key . into ( ) ,
662+ request. recipient . into ( ) ,
662663 status,
663664 ) ;
664665 let recipient = request. recipient . into ( ) ;
@@ -679,8 +680,8 @@ impl PortalApp {
679680 status : RecurringPaymentResponseContent ,
680681 ) -> Result < ( ) , AppError > {
681682 let conv = RecurringPaymentStatusSenderConversation :: new (
682- request. service_key . clone ( ) . into ( ) ,
683- request. recipient . clone ( ) . into ( ) ,
683+ request. service_key . into ( ) ,
684+ request. recipient . into ( ) ,
684685 status,
685686 ) ;
686687 let recipient = request. recipient . into ( ) ;
@@ -735,7 +736,7 @@ impl PortalApp {
735736 let conv = SetProfileConversation :: new ( profile) ;
736737 let _ = self . router
737738 . add_conversation ( Box :: new ( OneShotSenderAdapter :: new_with_user (
738- self . router . keypair ( ) . public_key ( ) . into ( ) ,
739+ self . router . keypair ( ) . public_key ( ) ,
739740 vec ! [ ] ,
740741 conv,
741742 ) ) )
@@ -800,7 +801,7 @@ impl PortalApp {
800801 let nip46_request = nip46_request. map_err ( |e| AppError :: ParseError ( e. to_string ( ) ) ) ?;
801802 log:: debug!( "Received nip46 request: {:?}" , nip46_request) ;
802803
803- let nostr_client_pubkey = nip46_request. nostr_client_pubkey . clone ( ) ;
804+ let nostr_client_pubkey = nip46_request. nostr_client_pubkey ;
804805 let app_event = NostrConnectEvent {
805806 nostr_client_pubkey : PublicKey ( nostr_client_pubkey) ,
806807 message : nip46_request. message . into ( ) ,
@@ -857,7 +858,7 @@ impl PortalApp {
857858 . map_err ( |e| {
858859 AppError :: Nip46OperationError ( format ! (
859860 "Impossible to sign event: {}" ,
860- e. to_string ( )
861+ e
861862 ) )
862863 } ) ?;
863864 serde_json:: to_string ( & signed_event)
@@ -947,10 +948,10 @@ impl PortalApp {
947948
948949 pub async fn register_nip05 ( & self , local_part : String ) -> Result < ( ) , AppError > {
949950 let nip05 = format ! ( "{}@getportal.cc" , local_part. trim( ) . to_lowercase( ) ) ;
950- portal:: register_nip05 ( & self . router . keypair ( ) . get_keys ( ) , & nip05)
951+ portal:: register_nip05 ( self . router . keypair ( ) . get_keys ( ) , & nip05)
951952 . await
952953 . map ( |_| ( ) )
953- . map_err ( |e| AppError :: ProfileRegistrationError ( e ) )
954+ . map_err ( AppError :: ProfileRegistrationError )
954955 }
955956
956957 pub async fn next_invoice_request (
@@ -973,7 +974,7 @@ impl PortalApp {
973974 request : portal:: protocol:: model:: payment:: InvoiceRequestContentWithKey ,
974975 invoice : MakeInvoiceResponse ,
975976 ) -> Result < ( ) , AppError > {
976- let recipient = request. recipient . clone ( ) . into ( ) ;
977+ let recipient = request. recipient . into ( ) ;
977978 let invoice_response = InvoiceResponse {
978979 request,
979980 invoice : invoice. invoice ,
@@ -1045,7 +1046,7 @@ impl PortalApp {
10451046 request : CashuRequestContentWithKey ,
10461047 status : CashuResponseStatus ,
10471048 ) -> Result < ( ) , AppError > {
1048- let recipient = request. recipient . clone ( ) . into ( ) ;
1049+ let recipient = request. recipient . into ( ) ;
10491050 let response = CashuResponseContent { request, status } ;
10501051 let conv = CashuResponseSenderConversation :: new ( response) ;
10511052 let _ = self . router
@@ -1106,7 +1107,7 @@ impl PortalApp {
11061107 mut notifications : tokio:: sync:: broadcast:: Receiver < MonitorNotification > ,
11071108 relay_status_listener : Arc < dyn RelayStatusListener > ,
11081109 ) {
1109- let _ = runtime. add_task ( async move {
1110+ std :: mem :: drop ( runtime. add_task ( async move {
11101111 while let Ok ( notification) = notifications. recv ( ) . await {
11111112 match notification {
11121113 MonitorNotification :: StatusChanged { relay_url, status } => {
@@ -1124,12 +1125,12 @@ impl PortalApp {
11241125 }
11251126 }
11261127 Ok :: < ( ) , AppError > ( ( ) )
1127- } ) ;
1128+ } ) ) ;
11281129 }
11291130
11301131 async fn post_request_profile_service ( & self , content : EventContent ) -> Result < ( ) , AppError > {
11311132 let event = EventBuilder :: text_note ( serde_json:: to_string ( & content) . unwrap ( ) )
1132- . sign_with_keys ( & self . router . keypair ( ) . get_keys ( ) )
1133+ . sign_with_keys ( self . router . keypair ( ) . get_keys ( ) )
11331134 . map_err ( |_| AppError :: ProfileRegistrationError ( "Failed to sign event" . to_string ( ) ) ) ?;
11341135 let json_string = serde_json:: to_string_pretty ( & event) . map_err ( |_| {
11351136 AppError :: ProfileRegistrationError ( "Failed to serialize event" . to_string ( ) )
0 commit comments