mirror of
https://github.com/Qortal/piratewallet-light-cli.git
synced 2025-02-01 03:12:15 +00:00
Address command
This commit is contained in:
parent
f93267507f
commit
165328abed
@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "rust-lightclient"
|
||||
name = "zeclite-cli"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
|
||||
|
@ -141,10 +141,33 @@ impl Command for BalanceCommand {
|
||||
fn exec(&self, _args: &[&str], lightclient: &LightClient) -> String {
|
||||
lightclient.do_sync(true);
|
||||
|
||||
format!("{}", lightclient.do_balance().pretty(2))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct AddressCommand {}
|
||||
impl Command for AddressCommand {
|
||||
fn help(&self) -> String {
|
||||
let mut h = vec![];
|
||||
h.push("List current addresses in the wallet");
|
||||
h.push("Usage:");
|
||||
h.push("address");
|
||||
h.push("");
|
||||
|
||||
h.join("\n")
|
||||
}
|
||||
|
||||
fn short_help(&self) -> String {
|
||||
"List all addresses in the wallet".to_string()
|
||||
}
|
||||
|
||||
fn exec(&self, _args: &[&str], lightclient: &LightClient) -> String {
|
||||
format!("{}", lightclient.do_address().pretty(2))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct SendCommand {}
|
||||
impl Command for SendCommand {
|
||||
fn help(&self) -> String {
|
||||
@ -327,6 +350,7 @@ pub fn get_commands() -> Box<HashMap<String, Box<dyn Command>>> {
|
||||
map.insert("rescan".to_string(), Box::new(RescanCommand{}));
|
||||
map.insert("help".to_string(), Box::new(HelpCommand{}));
|
||||
map.insert("balance".to_string(), Box::new(BalanceCommand{}));
|
||||
map.insert("address".to_string(), Box::new(AddressCommand{}));
|
||||
map.insert("info".to_string(), Box::new(InfoCommand{}));
|
||||
map.insert("send".to_string(), Box::new(SendCommand{}));
|
||||
map.insert("save".to_string(), Box::new(SaveCommand{}));
|
||||
|
@ -26,7 +26,7 @@ use tower_hyper::{client, util};
|
||||
use tower_util::MakeService;
|
||||
use futures::stream::Stream;
|
||||
|
||||
use crate::grpc_client::{ChainSpec, BlockId, BlockRange, RawTransaction, TransparentAddress,
|
||||
use crate::grpc_client::{ChainSpec, BlockId, BlockRange, RawTransaction,
|
||||
TransparentAddressBlockFilter, TxFilter, Empty};
|
||||
use crate::grpc_client::client::CompactTxStreamer;
|
||||
|
||||
@ -160,7 +160,24 @@ impl LightClient {
|
||||
self.wallet.last_scanned_height() as u64
|
||||
}
|
||||
|
||||
pub fn do_address(&self) -> json::JsonValue {
|
||||
pub fn do_address(&self) -> json::JsonValue {
|
||||
// Collect z addresses
|
||||
let z_addresses = self.wallet.address.iter().map( |ad| {
|
||||
encode_payment_address(HRP_SAPLING_PAYMENT_ADDRESS, &ad)
|
||||
}).collect::<Vec<String>>();
|
||||
|
||||
// Collect t addresses
|
||||
let t_addresses = self.wallet.tkeys.iter().map( |sk| {
|
||||
LightWallet::address_from_sk(&sk)
|
||||
}).collect::<Vec<String>>();
|
||||
|
||||
object!{
|
||||
"z_addresses" => z_addresses,
|
||||
"t_addresses" => t_addresses,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn do_balance(&self) -> json::JsonValue {
|
||||
// Collect z addresses
|
||||
let z_addresses = self.wallet.address.iter().map( |ad| {
|
||||
let address = encode_payment_address(HRP_SAPLING_PAYMENT_ADDRESS, &ad);
|
||||
|
@ -41,7 +41,7 @@ pub fn main() {
|
||||
|
||||
// Get command line arguments
|
||||
let matches = App::new("ZecLite CLI")
|
||||
.version("1.0")
|
||||
.version("0.1.0")
|
||||
.arg(Arg::with_name("seed")
|
||||
.short("s")
|
||||
.long("seed")
|
||||
|
Loading…
Reference in New Issue
Block a user