Skip to content

Commit

Permalink
Merge pull request #1545 from dorianvp/sendprogress-out-format
Browse files Browse the repository at this point in the history
Fix output format for txids in `sendprogress` command
  • Loading branch information
zancas authored Nov 22, 2024
2 parents b7360d1 + cdc881e commit af35475
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions zingolib/src/lightclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = last_result
.clone()
.and_then(|result| result.ok().map(|json_result| json_result.to_string()));
let tx_ids: Vec<String> = match &last_result {
Some(r) => {
let mut binding = r.clone().unwrap();
let binding = binding.as_array_mut();
let tx_json_values: Vec<String> = binding
.unwrap()
.iter()
.map(|x| {
return x.as_str().unwrap().to_string();
})
.collect();
tx_json_values
}
None => vec![],
};

let error: Option<String> = 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
}
Expand Down

0 comments on commit af35475

Please sign in to comment.