@@ -79,10 +79,13 @@ impl TrustedWalletInterface for Spark {
7979 "Spark does not support amount-less invoices" . to_owned ( ) ,
8080 ) ) ,
8181 Some ( a) => {
82- let res = self
83- . spark_wallet
84- . create_lightning_invoice ( a. sats_rounding_up ( ) , None , None )
85- . await ?;
82+ let sats = a. sats ( ) . map_err ( |_| {
83+ TrustedError :: UnsupportedOperation (
84+ "msat amounts not supported by spark" . to_owned ( ) ,
85+ )
86+ } ) ?;
87+
88+ let res = self . spark_wallet . create_lightning_invoice ( sats, None , None ) . await ?;
8689
8790 Bolt11Invoice :: from_str ( & res. invoice )
8891 . map_err ( |e| TrustedError :: Other ( format ! ( "Failed to parse invoice: {e}" ) ) )
@@ -151,12 +154,15 @@ impl TrustedWalletInterface for Spark {
151154 ) -> Pin < Box < dyn Future < Output = Result < Amount , TrustedError > > + Send + ' _ > > {
152155 Box :: pin ( async move {
153156 if let PaymentMethod :: LightningBolt11 ( invoice) = method {
157+ let sats = amount. sats ( ) . map_err ( |_| {
158+ TrustedError :: UnsupportedOperation (
159+ "msat amounts not supported by spark" . to_owned ( ) ,
160+ )
161+ } ) ?;
162+
154163 let fee_sats = self
155164 . spark_wallet
156- . fetch_lightning_send_fee_estimate (
157- & invoice. to_string ( ) ,
158- Some ( amount. sats_rounding_up ( ) ) , // fixme: why do they do sat amounts?
159- )
165+ . fetch_lightning_send_fee_estimate ( & invoice. to_string ( ) , Some ( sats) )
160166 . await ?;
161167
162168 Amount :: from_sats ( fee_sats) . map_err ( |_| TrustedError :: AmountError )
@@ -174,11 +180,17 @@ impl TrustedWalletInterface for Spark {
174180 ) -> Pin < Box < dyn Future < Output = Result < [ u8 ; 32 ] , TrustedError > > + Send + ' _ > > {
175181 Box :: pin ( async move {
176182 if let PaymentMethod :: LightningBolt11 ( invoice) = method {
183+ let sats = amount. sats ( ) . map_err ( |_| {
184+ TrustedError :: UnsupportedOperation (
185+ "msat amounts not supported by spark" . to_owned ( ) ,
186+ )
187+ } ) ?;
188+
177189 let res = self
178190 . spark_wallet
179191 . pay_lightning_invoice (
180192 & invoice. to_string ( ) ,
181- Some ( amount . sats_rounding_up ( ) ) , // fixme: why do they do sat amounts?
193+ Some ( sats ) ,
182194 None ,
183195 true , // prefer spark to make things cheaper
184196 )
0 commit comments