From 725a59c85396bf8d34dce78d9324b3dd7bd81edc Mon Sep 17 00:00:00 2001 From: dorianvp Date: Thu, 21 Nov 2024 23:31:42 -0300 Subject: [PATCH] fix: use json format for tx ids --- zingolib/src/lightclient.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/zingolib/src/lightclient.rs b/zingolib/src/lightclient.rs index 9ddab734a..19da13cc4 100644 --- a/zingolib/src/lightclient.rs +++ b/zingolib/src/lightclient.rs @@ -90,16 +90,30 @@ impl LightWalletSendProgress { /// TODO: Add Doc Comment Here! pub fn to_json(&self) -> JsonValue { let last_result = self.progress.last_result.clone(); - let txids: Option = last_result - .clone() - .and_then(|result| result.ok().map(|json_result| json_result.to_string())); + let tx_ids: Vec = match &last_result { + Some(r) => { + let mut binding = r.clone().unwrap(); + let binding = binding.as_array_mut(); + let tx_json_values: Vec = binding + .unwrap() + .iter() + .map(|x| { + return x.as_str().unwrap().to_string(); + }) + .collect(); + tx_json_values + } + None => vec![], + }; + let error: Option = last_result.and_then(|result| result.err()); + object! { "id" => self.progress.id, "sending" => self.progress.is_send_in_progress, "progress" => self.progress.progress, "total" => self.progress.total, - "txids" => txids, + "txids" => tx_ids, "error" => error, "sync_interrupt" => self.interrupt_sync }