@@ -793,7 +793,7 @@ impl<S: MutinyStorage> Node<S> {
793793 route_hints : Option < Vec < PhantomRouteHints > > ,
794794 ) -> Result < Bolt11Invoice , MutinyError > {
795795 // the amount to create for the invoice whether or not there is an lsp
796- let ( amount_sat, lsp_fee_msat ) = if let Some ( lsp) = self . lsp_client . as_ref ( ) {
796+ let ( amount_sat, lsp_fee ) = if let Some ( lsp) = self . lsp_client . as_ref ( ) {
797797 // LSP requires an amount:
798798 let amount_sat = amount_sat. ok_or ( MutinyError :: BadAmountError ) ?;
799799
@@ -815,15 +815,15 @@ impl<S: MutinyStorage> Node<S> {
815815 }
816816
817817 // check the fee from the LSP
818- let lsp_fee_msat = lsp
818+ let lsp_fee = lsp
819819 . get_lsp_fee_msat ( FeeRequest {
820820 pubkey : self . pubkey . to_hex ( ) ,
821821 amount_msat : amount_sat * 1000 ,
822822 } )
823823 . await ?;
824824
825825 // Convert the fee from msat to sat for comparison and subtraction
826- let lsp_fee_sat = lsp_fee_msat / 1000 ;
826+ let lsp_fee_sat = lsp_fee . fee_amount_msat / 1000 ;
827827
828828 // Ensure that the fee is less than the amount being requested.
829829 // If it isn't, we don't subtract it.
@@ -837,19 +837,27 @@ impl<S: MutinyStorage> Node<S> {
837837 amount_sat
838838 } ;
839839
840- ( Some ( amount_minus_fee) , Some ( lsp_fee_msat ) )
840+ ( Some ( amount_minus_fee) , Some ( lsp_fee ) )
841841 } else {
842842 ( amount_sat, None )
843843 } ;
844844
845+ let lsp_fee_msat = lsp_fee. as_ref ( ) . map ( |l| l. fee_amount_msat ) ;
846+
845847 let invoice = self
846848 . create_internal_invoice ( amount_sat, lsp_fee_msat, labels, route_hints)
847849 . await ?;
848850
849851 if let Some ( lsp) = self . lsp_client . as_ref ( ) {
850852 self . connect_peer ( PubkeyConnectionInfo :: new ( & lsp. connection_string ) ?, None )
851853 . await ?;
852- let lsp_invoice = match lsp. get_lsp_invoice ( invoice. to_string ( ) ) . await {
854+ let lsp_invoice = match lsp
855+ . get_lsp_invoice (
856+ invoice. to_string ( ) ,
857+ lsp_fee. expect ( "should have gotten a fee id" ) . id ,
858+ )
859+ . await
860+ {
853861 Ok ( lsp_invoice_str) => Bolt11Invoice :: from_str ( & lsp_invoice_str) ?,
854862 Err ( e) => {
855863 log_error ! ( self . logger, "Failed to get invoice from LSP: {e}" ) ;
0 commit comments