@@ -103,33 +103,29 @@ impl TrustedWalletInterface for Spark {
103103 & self , amount : Option < Amount > ,
104104 ) -> Pin < Box < dyn Future < Output = Result < Bolt11Invoice , TrustedError > > + Send + ' _ > > {
105105 Box :: pin ( async move {
106- match amount {
107- None => Err ( TrustedError :: UnsupportedOperation (
108- "Spark does not support amount-less invoices" . to_owned ( ) ,
109- ) ) ,
110- Some ( a) if a == Amount :: ZERO => Err ( TrustedError :: UnsupportedOperation (
111- "Spark does not support amount-less invoices" . to_owned ( ) ,
112- ) ) ,
106+ // check amount is not msat value
107+ let amount_sats = match amount {
113108 Some ( a) => {
114109 let sats = a. sats ( ) . map_err ( |_| {
115110 TrustedError :: UnsupportedOperation (
116111 "msat amounts not supported by spark" . to_owned ( ) ,
117112 )
118113 } ) ?;
114+ Some ( sats)
115+ } ,
116+ None => None ,
117+ } ;
119118
120- let params = ReceivePaymentRequest {
121- payment_method : ReceivePaymentMethod :: Bolt11Invoice {
122- description : "" . to_string ( ) ,
123- // TODO: can we do amountless now?
124- amount_sats : Some ( sats) ,
125- } ,
126- } ;
127- let res = self . spark_wallet . receive_payment ( params) . await ?;
128-
129- Bolt11Invoice :: from_str ( & res. payment_request )
130- . map_err ( |e| TrustedError :: Other ( format ! ( "Failed to parse invoice: {e}" ) ) )
119+ let params = ReceivePaymentRequest {
120+ payment_method : ReceivePaymentMethod :: Bolt11Invoice {
121+ description : "" . to_string ( ) , // empty description for smaller QRs and better privacy
122+ amount_sats,
131123 } ,
132- }
124+ } ;
125+ let res = self . spark_wallet . receive_payment ( params) . await ?;
126+
127+ Bolt11Invoice :: from_str ( & res. payment_request )
128+ . map_err ( |e| TrustedError :: Other ( format ! ( "Failed to parse invoice: {e}" ) ) )
133129 } )
134130 }
135131
0 commit comments