mirror of
https://github.com/Qortal/piratewallet-light-cli.git
synced 2025-11-01 20:57:02 +00:00
Return results instead of JSON
This commit is contained in:
@@ -265,7 +265,10 @@ impl Command for SendCommand {
|
|||||||
};
|
};
|
||||||
|
|
||||||
lightclient.do_sync(true);
|
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 {
|
} else if args.len() == 2 || args.len() == 3 {
|
||||||
// Make sure we can parse the amount
|
// Make sure we can parse the amount
|
||||||
let value = match args[1].parse::<u64>() {
|
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};
|
let memo = if args.len() == 3 { Some(args[2].to_string()) } else {None};
|
||||||
|
|
||||||
lightclient.do_sync(true);
|
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")
|
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");
|
info!("Creating transaction");
|
||||||
|
|
||||||
let rawtx = self.wallet.write().unwrap().send_to_address(
|
let rawtx = self.wallet.write().unwrap().send_to_address(
|
||||||
@@ -799,11 +799,8 @@ impl LightClient {
|
|||||||
);
|
);
|
||||||
|
|
||||||
match rawtx {
|
match rawtx {
|
||||||
Ok(txbytes) => match broadcast_raw_tx(&self.get_server_uri(), self.config.no_cert_verification, txbytes) {
|
Ok(txbytes) => broadcast_raw_tx(&self.get_server_uri(), self.config.no_cert_verification, txbytes),
|
||||||
Ok(k) => k,
|
Err(e) => Err(format!("Error: No Tx to broadcast. Error was: {}", e))
|
||||||
Err(e) => e,
|
|
||||||
},
|
|
||||||
Err(e) => format!("Error: No Tx to broadcast. Error was: {}", e)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user