@@ -6,21 +6,25 @@ use log::info;
6
6
7
7
async fn get_fee_info_before_receiving_payment ( sdk : Arc < BreezServices > ) -> Result < ( ) > {
8
8
// ANCHOR: get-fee-info-before-receiving-payment
9
- // Unless chosen otherwise by the app or the user, the SDK defaults to the cheapest fees
10
- let opening_fees = sdk
11
- . lsp_info ( )
12
- . await ?
13
- . opening_fee_params_list
14
- . get_cheapest_opening_fee_params ( ) ?;
15
-
16
- let fee_percentage = opening_fees. proportional * 100_f64 / 1_000_000_f64 ;
17
- let min_fee_sat = opening_fees. min_msat / 1_000 ;
18
- let inbound_liquidity_sat = sdk. node_info ( ) ?. inbound_liquidity_msats / 1000 ;
19
-
20
- if inbound_liquidity_sat == 0 {
21
- info ! ( "A setup fee of {fee_percentage}% with a minimum of {min_fee_sat} sats will be applied." ) ;
22
- } else {
23
- info ! ( "A setup fee of {fee_percentage}% with a minimum of {min_fee_sat} sats will be applied for receiving more than {inbound_liquidity_sat} sats." ) ;
9
+ let inbound_liquidity_msat = sdk. node_info ( ) ?. inbound_liquidity_msats ;
10
+ let inbound_liquidity_sat = inbound_liquidity_msat / 1000 ;
11
+
12
+ let opening_fee_response = sdk
13
+ . open_channel_fee ( OpenChannelFeeRequest {
14
+ amount_msat : inbound_liquidity_msat + 1 ,
15
+ expiry : None ,
16
+ } )
17
+ . await ?;
18
+
19
+ if let Some ( opening_fees) = opening_fee_response. used_fee_params {
20
+ let fee_percentage = opening_fees. proportional * 100_f64 / 1_000_000_f64 ;
21
+ let min_fee_sat = opening_fees. min_msat / 1_000 ;
22
+
23
+ if inbound_liquidity_sat == 0 {
24
+ info ! ( "A setup fee of {fee_percentage}% with a minimum of {min_fee_sat} sats will be applied." ) ;
25
+ } else {
26
+ info ! ( "A setup fee of {fee_percentage}% with a minimum of {min_fee_sat} sats will be applied for receiving more than {inbound_liquidity_sat} sats." ) ;
27
+ }
24
28
}
25
29
// ANCHOR_END: get-fee-info-before-receiving-payment
26
30
0 commit comments