File tree Expand file tree Collapse file tree 1 file changed +23
-11
lines changed
orange-sdk/src/trusted_wallet/spark Expand file tree Collapse file tree 1 file changed +23
-11
lines changed Original file line number Diff line number Diff line change @@ -218,17 +218,29 @@ impl TrustedWalletInterface for Spark {
218218 } ;
219219 let prepare = self . spark_wallet . prepare_send_payment ( params) . await ?;
220220
221- let res = self
222- . spark_wallet
223- . send_payment ( SendPaymentRequest {
224- prepare_response : prepare,
225- options : None ,
226- idempotency_key : None ,
227- } )
228- . await ?;
229-
230- let id = parse_payment_id ( & res. payment . id ) ?;
231- Ok ( id)
221+ let uuid = Uuid :: now_v7 ( ) ;
222+ // spawn payment send in background since it can take a while and we don't want to block the caller
223+ let w = Arc :: clone ( & self . spark_wallet ) ;
224+ let logger = Arc :: clone ( & self . logger ) ;
225+ tokio:: spawn ( async move {
226+ match w
227+ . send_payment ( SendPaymentRequest {
228+ prepare_response : prepare,
229+ options : None ,
230+ idempotency_key : Some ( uuid. to_string ( ) ) ,
231+ } )
232+ . await
233+ {
234+ Ok ( res) => {
235+ log_info ! ( logger, "Payment sent successfully: {res:?}" ) ;
236+ } ,
237+ Err ( e) => {
238+ log_error ! ( logger, "Failed to send payment: {e:?}" ) ;
239+ } ,
240+ }
241+ } ) ;
242+
243+ Ok ( parse_payment_id ( & uuid. to_string ( ) ) ?)
232244 } else {
233245 Err ( TrustedError :: UnsupportedOperation (
234246 "Only BOLT 11 is currently supported" . to_owned ( ) ,
You can’t perform that action at this time.
0 commit comments