mirror of
https://github.com/Qortal/piratewallet-light-cli.git
synced 2025-01-30 18:42:15 +00:00
Return results instead of JSON
This commit is contained in:
parent
0e529ba4cd
commit
19d9dfa18e
@ -265,7 +265,10 @@ impl Command for SendCommand {
|
||||
};
|
||||
|
||||
lightclient.do_sync(true);
|
||||
return lightclient.do_send(send_args);
|
||||
match lightclient.do_send(send_args) {
|
||||
Ok(txid) => { object!{ "txid" => txid } },
|
||||
Err(e) => { object!{ "error" => e } }
|
||||
}.pretty(2)
|
||||
} else if args.len() == 2 || args.len() == 3 {
|
||||
// Make sure we can parse the amount
|
||||
let value = match args[1].parse::<u64>() {
|
||||
@ -278,10 +281,13 @@ impl Command for SendCommand {
|
||||
let memo = if args.len() == 3 { Some(args[2].to_string()) } else {None};
|
||||
|
||||
lightclient.do_sync(true);
|
||||
return lightclient.do_send(vec!((args[0], value, memo)));
|
||||
match lightclient.do_send(vec!((args[0], value, memo))) {
|
||||
Ok(txid) => { object!{ "txid" => txid } },
|
||||
Err(e) => { object!{ "error" => e } }
|
||||
}.pretty(2)
|
||||
} else {
|
||||
self.help()
|
||||
}
|
||||
|
||||
self.help()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -789,7 +789,7 @@ impl LightClient {
|
||||
responses.join("\n")
|
||||
}
|
||||
|
||||
pub fn do_send(&self, addrs: Vec<(&str, u64, Option<String>)>) -> String {
|
||||
pub fn do_send(&self, addrs: Vec<(&str, u64, Option<String>)>) -> Result<String, String> {
|
||||
info!("Creating transaction");
|
||||
|
||||
let rawtx = self.wallet.write().unwrap().send_to_address(
|
||||
@ -799,11 +799,8 @@ impl LightClient {
|
||||
);
|
||||
|
||||
match rawtx {
|
||||
Ok(txbytes) => match broadcast_raw_tx(&self.get_server_uri(), self.config.no_cert_verification, txbytes) {
|
||||
Ok(k) => k,
|
||||
Err(e) => e,
|
||||
},
|
||||
Err(e) => format!("Error: No Tx to broadcast. Error was: {}", e)
|
||||
Ok(txbytes) => broadcast_raw_tx(&self.get_server_uri(), self.config.no_cert_verification, txbytes),
|
||||
Err(e) => Err(format!("Error: No Tx to broadcast. Error was: {}", e))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user