@@ -58,7 +58,7 @@ use hex::FromHex;
58
58
use lightning:: {
59
59
ln:: PaymentHash , log_debug, log_error, log_info, log_trace, log_warn, util:: logger:: Logger ,
60
60
} ;
61
- use lightning_invoice:: Bolt11Invoice ;
61
+ use lightning_invoice:: { Bolt11Invoice , RoutingFees } ;
62
62
use serde:: { de:: DeserializeOwned , Deserialize , Serialize } ;
63
63
use std:: { collections:: HashMap , fmt:: Debug , sync:: Arc } ;
64
64
use std:: {
@@ -143,6 +143,22 @@ pub struct FederationIdentity {
143
143
pub federation_name : Option < String > ,
144
144
pub federation_expiry_timestamp : Option < String > ,
145
145
pub welcome_message : Option < String > ,
146
+ pub gateway_fees : Option < GatewayFees > ,
147
+ }
148
+
149
+ #[ derive( Debug , Serialize , Deserialize , PartialEq , Eq , Clone ) ]
150
+ pub struct GatewayFees {
151
+ pub base_msat : u32 ,
152
+ pub proportional_millionths : u32 ,
153
+ }
154
+
155
+ impl From < RoutingFees > for GatewayFees {
156
+ fn from ( val : RoutingFees ) -> Self {
157
+ GatewayFees {
158
+ base_msat : val. base_msat ,
159
+ proportional_millionths : val. proportional_millionths ,
160
+ }
161
+ }
146
162
}
147
163
148
164
// This is the FederationIndex reference that is saved to the DB
@@ -274,6 +290,15 @@ impl<S: MutinyStorage> FederationClient<S> {
274
290
} )
275
291
}
276
292
293
+ pub ( crate ) async fn gateway_fee ( & self ) -> Result < GatewayFees , MutinyError > {
294
+ let lightning_module = self
295
+ . fedimint_client
296
+ . get_first_module :: < LightningClientModule > ( ) ;
297
+
298
+ let gw = lightning_module. select_active_gateway ( ) . await ?;
299
+ Ok ( gw. fees . into ( ) )
300
+ }
301
+
277
302
pub ( crate ) async fn get_invoice (
278
303
& self ,
279
304
amount : u64 ,
@@ -559,7 +584,9 @@ impl<S: MutinyStorage> FederationClient<S> {
559
584
}
560
585
}
561
586
562
- pub fn get_mutiny_federation_identity ( & self ) -> FederationIdentity {
587
+ pub async fn get_mutiny_federation_identity ( & self ) -> FederationIdentity {
588
+ let gateway_fees = self . gateway_fee ( ) . await . ok ( ) ;
589
+
563
590
FederationIdentity {
564
591
uuid : self . uuid . clone ( ) ,
565
592
federation_id : self . fedimint_client . federation_id ( ) ,
@@ -568,6 +595,7 @@ impl<S: MutinyStorage> FederationClient<S> {
568
595
. fedimint_client
569
596
. get_meta ( "federation_expiry_timestamp" ) ,
570
597
welcome_message : self . fedimint_client . get_meta ( "welcome_message" ) ,
598
+ gateway_fees,
571
599
}
572
600
}
573
601
@@ -1049,7 +1077,6 @@ fn fedimint_mnemonic_generation() {
1049
1077
fn gateway_preference ( ) {
1050
1078
use fedimint_core:: util:: SafeUrl ;
1051
1079
use fedimint_ln_common:: { LightningGateway , LightningGatewayAnnouncement } ;
1052
- use lightning_invoice:: RoutingFees ;
1053
1080
use std:: time:: Duration ;
1054
1081
1055
1082
use super :: * ;
0 commit comments