Merge pull request #1 from DenioD/master

Port zecwalletlight-cli to Hush, rebrand and updated Readme
This commit is contained in:
Duke Leto
2019-10-18 09:17:55 -07:00
committed by GitHub
10 changed files with 86 additions and 86 deletions

View File

@@ -1,5 +1,5 @@
[package]
name = "zecwallet-cli"
name = "silentdragonlite-cli"
version = "1.0.0"
edition = "2018"
@@ -14,7 +14,7 @@ http = "0.1"
byteorder = "1"
tiny-bip39 = "0.6.2"
zecwalletlitelib = { path = "./lib/" }
silentdragonlitelib = { path = "./lib/" }
[profile.release]

View File

@@ -1,12 +1,12 @@
## SilentDragonLite CLI - A command line SilentDragon light client.
## SilentDragonLite CLI - A command line Hush light client.
`zecwallet-cli` is a command line ZecWallet light client. To use it, download the latest binary from the releases page and run `./zecwallet-cli`
`silentdragonlite-cli` is a command line SilentDragonLite light client. To use it, download the latest binary from the releases page and run `./silentdragonlite-cli`
This will launch the interactive prompt. Type `help` to get a list of commands
## Running in non-interactive mode:
You can also run `zecwallet-cli` in non-interactive mode by passing the command you want to run as an argument. For example, `zecwallet-cli addresses` will list all wallet addresses and exit.
Run `zecwallet-cli help` to see a list of all commands.
You can also run `silentdragonlite-cli` in non-interactive mode by passing the command you want to run as an argument. For example, `silentdragonlite-cli addresses` will list all wallet addresses and exit.
Run `silentdragonlite-cli help` to see a list of all commands.
## Privacy
* While all the keys and transaction detection happens on the client, the server can learn what blocks contain your shielded transactions.
@@ -14,18 +14,17 @@ Run `zecwallet-cli help` to see a list of all commands.
* Also remember that t-addresses don't provide any privacy protection.
## Notes:
* The wallet connects to the mainnet by default. To connect to testnet, please pass `--server https://lightd-test.zecwallet.co:443`
* If you want to run your own server, please see [zecwallet lightwalletd](https://github.com/adityapk00/lightwalletd), and then run `./zecwallet-cli --server http://127.0.0.1:9067`. You might also need to pass `--dangerous` if you are using a self-signed TLS certificate.
* If you want to run your own server, please see [SilentDragonLite-cli lightwalletd](https://github.com/MyHush/lightwalletd), and then run `./silentdragonlite-cli --server http://127.0.0.1:9069`. You might also need to pass `--dangerous` if you are using a self-signed TLS certificate.
* The log file is in `~/.zcash/zecwallet-light-wallet.debug.log`. Wallet is stored in `~/.zcash/zecwallet-light-wallet.dat`
* The log file is in `~/.komodo/HUSH3/silentdragonlite-cli.debug.log`. Wallet is stored in `~/.komodo/HUSH3/silentdragonlite-cli.dat`
### Note Management
Zecwallet-CLI does automatic note and utxo management, which means it doesn't allow you to manually select which address to send outgoing transactions from. It follows these principles:
silentdragonlite does automatic note and utxo management, which means it doesn't allow you to manually select which address to send outgoing transactions from. It follows these principles:
* Defaults to sending shielded transactions, even if you're sending to a transparent address
* Sapling funds need at least 4 confirmations before they can be spent
* Can select funds from multiple shielded addresses in the same transaction
* Will automatically shield your transparent funds at the first opportunity
* When sending an outgoing transaction to a shielded address, Zecwallet-CLI can decide to use the transaction to additionally shield your transparent funds (i.e., send your transparent funds to your own shielded address in the same transaction)
* When sending an outgoing transaction to a shielded address, silentdragonlite can decide to use the transaction to additionally shield your transparent funds (i.e., send your transparent funds to your own shielded address in the same transaction)
## Compiling from source
@@ -34,17 +33,17 @@ Zecwallet-CLI does automatic note and utxo management, which means it doesn't al
* Run `rustup update` to get the latest version of Rust if you already have it installed
```
git clone https://github.com/adityapk00/zecwallet-light-cli.git
git clone https://github.com/MyHush/silentdragonlite-cli.git
cargo build --release
./target/release/zecwallet-cli
./target/release/silentdragonlite-cli
```
## Options
Here are some CLI arguments you can pass to `zecwallet-cli`. Please run `zecwallet-cli --help` for the full list.
Here are some CLI arguments you can pass to `silentdragonlite-cli`. Please run `silentdragonlite-cli --help` for the full list.
* `--server`: Connect to a custom zecwallet lightwalletd server.
* Example: `./zecwallet-cli --server 127.0.0.1:9067`
* `--server`: Connect to a custom SilentDragonLite lightwalletd server.
* Example: `./silentdragonlite-cli --server 127.0.0.1:9069`
* `--seed`: Restore a wallet from a seed phrase. Note that this will fail if there is an existing wallet. Delete (or move) any existing wallet to restore from the 24-word seed phrase
* Example: `./zecwallet-cli --seed "twenty four words seed phrase"`
* Example: `./silentdragonlite-cli --seed "twenty four words seed phrase"`
* `--recover`: Attempt to recover the seed phrase from a corrupted wallet

View File

@@ -1,5 +1,5 @@
[package]
name = "zecwalletlitelib"
name = "silentdragonlitelib"
version = "0.1.0"
edition = "2018"
@@ -36,38 +36,39 @@ rust-embed = { version = "5.1.0", features = ["debug-embed"] }
rand = "0.7.2"
[dependencies.bellman]
git = "https://github.com/adityapk00/librustzcash.git"
rev = "188537ea025fcb7fbdfc11266f307a084a5451e4"
git = "https://github.com/DenioD/librustzcash.git"
rev= "af5f25e87347e9ac42f29c37d43250e9de5c21de"
default-features = false
features = ["groth16"]
[dependencies.pairing]
git = "https://github.com/adityapk00/librustzcash.git"
rev = "188537ea025fcb7fbdfc11266f307a084a5451e4"
git = "https://github.com/DenioD/librustzcash.git"
rev= "af5f25e87347e9ac42f29c37d43250e9de5c21de"
[dependencies.zcash_client_backend]
git = "https://github.com/adityapk00/librustzcash.git"
rev = "188537ea025fcb7fbdfc11266f307a084a5451e4"
git = "https://github.com/DenioD/librustzcash.git"
rev= "af5f25e87347e9ac42f29c37d43250e9de5c21de"
default-features = false
[dependencies.zcash_primitives]
git = "https://github.com/adityapk00/librustzcash.git"
rev = "188537ea025fcb7fbdfc11266f307a084a5451e4"
git = "https://github.com/DenioD/librustzcash.git"
rev= "af5f25e87347e9ac42f29c37d43250e9de5c21de"
default-features = false
features = ["transparent-inputs"]
[dependencies.zcash_proofs]
git = "https://github.com/adityapk00/librustzcash.git"
rev = "188537ea025fcb7fbdfc11266f307a084a5451e4"
git = "https://github.com/DenioD/librustzcash.git"
rev= "af5f25e87347e9ac42f29c37d43250e9de5c21de"
default-features = false
[dependencies.ff]
git = "https://github.com/adityapk00/librustzcash.git"
rev = "188537ea025fcb7fbdfc11266f307a084a5451e4"
git = "https://github.com/DenioD/librustzcash.git"
rev= "af5f25e87347e9ac42f29c37d43250e9de5c21de"
features = ["ff_derive"]
[build-dependencies]
tower-grpc-build = { git = "https://github.com/tower-rs/tower-grpc", features = ["tower-hyper"] }
[profile.release]
debug = false
debug = true

View File

@@ -127,7 +127,7 @@ struct BalanceCommand {}
impl Command for BalanceCommand {
fn help(&self) -> String {
let mut h = vec![];
h.push("Show the current ZEC balance in the wallet");
h.push("Show the current HUSH balance in the wallet");
h.push("Usage:");
h.push("balance");
h.push("");
@@ -137,7 +137,7 @@ impl Command for BalanceCommand {
}
fn short_help(&self) -> String {
"Show the current ZEC balance in the wallet".to_string()
"Show the current HUSH balance in the wallet".to_string()
}
fn exec(&self, _args: &[&str], lightclient: &LightClient) -> String {
@@ -206,7 +206,7 @@ struct SendCommand {}
impl Command for SendCommand {
fn help(&self) -> String {
let mut h = vec![];
h.push("Send ZEC to a given address");
h.push("Send HUSH to a given address");
h.push("Usage:");
h.push("send <address> <amount in zatoshis> \"optional_memo\"");
h.push("");
@@ -218,7 +218,7 @@ impl Command for SendCommand {
}
fn short_help(&self) -> String {
"Send ZEC to the given address".to_string()
"Send HUSH to the given address".to_string()
}
fn exec(&self, args: &[&str], lightclient: &LightClient) -> String {
@@ -232,7 +232,7 @@ impl Command for SendCommand {
let value = match args[1].parse::<u64>() {
Ok(amt) => amt,
Err(e) => {
return format!("Couldn't parse amount: {}", e);
return format!("Couldn't parse amount: {}", e);;
}
};

View File

@@ -22,9 +22,9 @@ use crate::grpcconnector::{self, *};
use crate::SaplingParams;
use crate::ANCHOR_OFFSET;
pub const DEFAULT_SERVER: &str = "https://lightd-main.zecwallet.co:443";
pub const WALLET_NAME: &str = "zecwallet-light-wallet.dat";
pub const LOGFILE_NAME: &str = "zecwallet-light-wallet.debug.log";
pub const DEFAULT_SERVER: &str = "https://";
pub const WALLET_NAME: &str = "silentdragonlite-cli.dat";
pub const LOGFILE_NAME: &str = "silentdragonlite-cli.debug.log";
#[derive(Clone, Debug)]
@@ -61,10 +61,10 @@ impl LightClientConfig {
let mut zcash_data_location;
if cfg!(target_os="macos") || cfg!(target_os="windows") {
zcash_data_location = dirs::data_dir().expect("Couldn't determine app data directory!");
zcash_data_location.push("Zcash");
zcash_data_location.push("HUSH3");
} else {
zcash_data_location = dirs::home_dir().expect("Couldn't determine home directory!");
zcash_data_location.push(".zcash");
zcash_data_location.push(".komodo/HUSH3/SilentDragonLite/");
};
match &self.chain_name[..] {
@@ -93,13 +93,13 @@ impl LightClientConfig {
pub fn get_initial_state(&self) -> Option<(u64, &str, &str)> {
match &self.chain_name[..] {
"test" => Some((600000,
"0107385846c7451480912c294b6ce1ee1feba6c2619079fd9104f6e71e4d8fe7",
"01690698411e3f8badea7da885e556d7aba365a797e9b20b44ac0946dced14b23c001001ab2a18a5a86aa5d77e43b69071b21770b6fe6b3c26304dcaf7f96c0bb3fed74d000186482712fa0f2e5aa2f2700c4ed49ef360820f323d34e2b447b78df5ec4dfa0401a332e89a21afb073cb1db7d6f07396b56a95e97454b9bca5a63d0ebc575d3a33000000000001c9d3564eff54ebc328eab2e4f1150c3637f4f47516f879a0cfebdf49fe7b1d5201c104705fac60a85596010e41260d07f3a64f38f37a112eaef41cd9d736edc5270145e3d4899fcd7f0f1236ae31eafb3f4b65ad6b11a17eae1729cec09bd3afa01a000000011f8322ef806eb2430dc4a7a41c1b344bea5be946efc7b4349c1c9edb14ff9d39"
"test" => Some((105942,
"00000001c0199f329ee03379bf1387856dbab23765da508bf9b9d8d544f212c0",
""
)),
"main" => Some((610000,
"000000000218882f481e3b49ca3df819734b8d74aac91f69e848d7499b34b472",
"0192943f1eca6525cea7ea8e26b37c792593ed50cfe2be7a1ff551a08dc64b812f001000000001deef7ae5162a9942b4b9aa797137c5bdf60750e9548664127df99d1981dda66901747ad24d5daf294ce2a27aba923e16e52e7348eea3048c5b5654b99ab0a371200149d8aff830305beb3887529f6deb150ab012916c3ce88a6b47b78228f8bfeb3f01ff84a89890cfae65e0852bc44d9aa82be2c5d204f5aebf681c9e966aa46f540e000001d58f1dfaa9db0996996129f8c474acb813bfed452d347fb17ebac2e775e209120000000001319312241b0031e3a255b0d708750b4cb3f3fe79e3503fe488cc8db1dd00753801754bb593ea42d231a7ddf367640f09bbf59dc00f2c1d2003cc340e0c016b5b13"
"main" => Some((105944,
"0000000313b0ec7c5a1e9b997ce44a7763b56c5505526c36634a004ed52d7787",
""
)),
_ => None
}
@@ -146,21 +146,21 @@ impl LightClientConfig {
}
}
pub fn base58_pubkey_address(&self) -> [u8; 2] {
pub fn base58_pubkey_address(&self) -> [u8; 1] {
match &self.chain_name[..] {
"main" => mainnet::B58_PUBKEY_ADDRESS_PREFIX,
"test" => testnet::B58_PUBKEY_ADDRESS_PREFIX,
"regtest" => regtest::B58_PUBKEY_ADDRESS_PREFIX,
c => panic!("Unknown chain {}", c)
}
}
pub fn base58_script_address(&self) -> [u8; 2] {
pub fn base58_script_address(&self) -> [u8; 1] {
match &self.chain_name[..] {
"main" => mainnet::B58_SCRIPT_ADDRESS_PREFIX,
"test" => testnet::B58_SCRIPT_ADDRESS_PREFIX,
"regtest" => regtest::B58_SCRIPT_ADDRESS_PREFIX,
c => panic!("Unknown chain {}", c)
}
}
@@ -435,7 +435,7 @@ impl LightClient {
"unconfirmed_spent" => utxo.unconfirmed_spent.map(|spent_txid| format!("{}", spent_txid)),
}
)
.collect::<Vec<JsonValue>>();
.collect::<Vec<JsonValue>>();;
let mut res = object!{
"unspent_notes" => unspent_notes,

View File

@@ -2868,7 +2868,7 @@ pub mod tests {
// Test the addresses against https://iancoleman.io/bip39/
let (taddr, pk) = &wallet.get_t_secret_keys()[0];
assert_eq!(taddr, "t1eQ63fwkQ4n4Eo5uCrPGaAV8FWB2tmx7ui");
assert_eq!(taddr, "RVog7rQu2Zo2iAQCjbZGXsiQm7SYr9bcaq");
assert_eq!(pk, "Kz9ybX4giKag4NtnP1pi8WQF2B2hZDkFU85S7Dciz3UUhM59AnhE");
let (zaddr, sk) = &wallet.get_z_private_keys()[0];
@@ -2880,7 +2880,7 @@ pub mod tests {
#[test]
fn test_invalid_scan_blocks() {
const AMOUNT: u64 = 500000;
const AMOUNT: u64 = 50000;
let (wallet, _txid1, block_hash) = get_test_wallet(AMOUNT);
let prev_hash = add_blocks(&wallet, 2, 1, block_hash).unwrap();

View File

@@ -24,7 +24,7 @@ impl From<TransparentAddress> for RecipientAddress {
}
impl RecipientAddress {
pub fn from_str(s: &str, hrp_sapling_address: &str, b58_pubkey_address: [u8; 2], b58_script_address: [u8; 2]) -> Option<Self> {
pub fn from_str(s: &str, hrp_sapling_address: &str, b58_pubkey_address: [u8; 1], b58_script_address: [u8; 1]) -> Option<Self> {
// Try to match a sapling z address
if let Some(pa) = match decode_payment_address(hrp_sapling_address, s) {
Ok(ret) => ret,

View File

@@ -267,7 +267,7 @@ impl Utxo {
let mut address_bytes = vec![0; address_len as usize];
reader.read_exact(&mut address_bytes)?;
let address = String::from_utf8(address_bytes).unwrap();
assert_eq!(address.chars().take(1).collect::<Vec<char>>()[0], 't');
assert_eq!(address.chars().take(1).collect::<Vec<char>>()[0], 'R');
let mut txid_bytes = [0; 32];
reader.read_exact(&mut txid_bytes)?;

View File

@@ -32,45 +32,45 @@ if [ -z $APP_VERSION ]; then echo "APP_VERSION is not set"; exit 1; fi
#cargo build --release
# For Windows and Linux, build via docker
docker run --rm -v $(pwd)/:/opt/zecwallet-light-cli rustbuild:latest bash -c "cd /opt/zecwallet-light-cli && cargo build --release && cargo build --release --target x86_64-pc-windows-gnu"
docker run --rm -v $(pwd)/:/opt/silentdragonlite-cli rustbuild:latest bash -c "cd /opt/silentdragonlite-cli && cargo build --release && cargo build --release --target x86_64-pc-windows-gnu"
# Now sign and zip the binaries
#macOS
rm -rf target/macOS-zecwallet-cli-v$APP_VERSION
mkdir -p target/macOS-zecwallet-cli-v$APP_VERSION
cp target/release/zecwallet-cli target/macOS-zecwallet-cli-v$APP_VERSION/
gpg --batch --output target/macOS-zecwallet-cli-v$APP_VERSION/zecwallet-cli.sig --detach-sig target/macOS-zecwallet-cli-v$APP_VERSION/zecwallet-cli
rm -rf target/macOS-silentdragonlite-cli-v$APP_VERSION
mkdir -p target/macOS-silentdragonlite-cli-v$APP_VERSION
cp target/release/silentdragonlite-cli target/macOS-silentdragonlite-cli-v$APP_VERSION/
gpg --batch --output target/macOS-silentdragonlite-cli-v$APP_VERSION/silentdragonlite-cli.sig --detach-sig target/macOS-silentdragonlite-cli-v$APP_VERSION/silentdragonlite-cli
cd target
cd macOS-zecwallet-cli-v$APP_VERSION
gsha256sum zecwallet-cli > sha256sum.txt
cd macOS-silentdragonlite-cli-v$APP_VERSION
gsha256sum silentdragonlite-cli > sha256sum.txt
cd ..
zip -r macOS-zecwallet-cli-v$APP_VERSION.zip macOS-zecwallet-cli-v$APP_VERSION
zip -r macOS-silentdragonlite-cli-v$APP_VERSION.zip macOS-silentdragonlite-cli-v$APP_VERSION
cd ..
#Linux
rm -rf target/linux-zecwallet-cli-v$APP_VERSION
mkdir -p target/linux-zecwallet-cli-v$APP_VERSION
cp target/release/zecwallet-cli target/linux-zecwallet-cli-v$APP_VERSION/
gpg --batch --output target/linux-zecwallet-cli-v$APP_VERSION/zecwallet-cli.sig --detach-sig target/linux-zecwallet-cli-v$APP_VERSION/zecwallet-cli
rm -rf target/linux-silentdragonlite-cli-v$APP_VERSION
mkdir -p target/linux-silentdragonlite-cli-v$APP_VERSION
cp target/release/silentdragonlite-cli target/linux-silentdragonlite-cli-v$APP_VERSION/
gpg --batch --output target/linux-silentdragonlite-cli-v$APP_VERSION/silentdragonlite-cli.sig --detach-sig target/linux-silentdragonlite-cli-v$APP_VERSION/silentdragonlite-cli
cd target
cd linux-zecwallet-cli-v$APP_VERSION
gsha256sum zecwallet-cli > sha256sum.txt
cd linux-silentdragonlite-cli-v$APP_VERSION
gsha256sum silentdragonlite-cli > sha256sum.txt
cd ..
zip -r linux-zecwallet-cli-v$APP_VERSION.zip linux-zecwallet-cli-v$APP_VERSION
zip -r linux-silentdragonlite-cli-v$APP_VERSION.zip linux-silentdragonlite-cli-v$APP_VERSION
cd ..
#Windows
rm -rf target/Windows-zecwallet-cli-v$APP_VERSION
mkdir -p target/Windows-zecwallet-cli-v$APP_VERSION
cp target/x86_64-pc-windows-gnu/release/zecwallet-cli.exe target/Windows-zecwallet-cli-v$APP_VERSION/
gpg --batch --output target/Windows-zecwallet-cli-v$APP_VERSION/zecwallet-cli.sig --detach-sig target/Windows-zecwallet-cli-v$APP_VERSION/zecwallet-cli.exe
rm -rf target/Windows-silentdragonlite-cli-v$APP_VERSION
mkdir -p target/Windows-silentdragonlite-cli-v$APP_VERSION
cp target/x86_64-pc-windows-gnu/release/silentdragonlite-cli.exe target/Windows-silentdragonlite-cli-v$APP_VERSION/
gpg --batch --output target/Windows-silentdragonlite-cli-v$APP_VERSION/silentdragonlite-cli.sig --detach-sig target/Windows-silentdragonlite-cli-v$APP_VERSION/silentdragonlite-cli.exe
cd target
cd Windows-zecwallet-cli-v$APP_VERSION
gsha256sum zecwallet-cli.exe > sha256sum.txt
cd Windows-silentdragonlite-cli-v$APP_VERSION
gsha256sum silentdragonlite-cli.exe > sha256sum.txt
cd ..
zip -r Windows-zecwallet-cli-v$APP_VERSION.zip Windows-zecwallet-cli-v$APP_VERSION
zip -r Windows-silentdragonlite-cli-v$APP_VERSION.zip Windows-silentdragonlite-cli-v$APP_VERSION
cd ..

View File

@@ -2,7 +2,7 @@ use std::io::{Result, Error, ErrorKind};
use std::sync::Arc;
use std::sync::mpsc::{channel, Sender, Receiver};
use zecwalletlitelib::{commands,
use silentdragonlitelib::{commands,
lightclient::{self, LightClient, LightClientConfig},
};
@@ -23,7 +23,7 @@ use log4rs::append::rolling_file::policy::compound::{
fn get_log_config(config: &LightClientConfig) -> Result<Config> {
let window_size = 3; // log0, log1, log2
let fixed_window_roller =
FixedWindowRoller::builder().build("zecwallet-light-wallet-log{}",window_size).unwrap();
FixedWindowRoller::builder().build("SilentDragonLite-light-wallet-log{}",window_size).unwrap();
let size_limit = 5 * 1024 * 1024; // 5MB as max log file size to roll
let size_trigger = SizeTrigger::new(size_limit);
let compound_policy = CompoundPolicy::new(Box::new(size_trigger),Box::new(fixed_window_roller));
@@ -53,7 +53,7 @@ fn get_log_config(config: &LightClientConfig) -> Result<Config> {
pub fn main() {
// Get command line arguments
use clap::{Arg, App};
let matches = App::new("Zecwallet CLI")
let matches = App::new("SilentDragon CLI")
.version("1.0.0")
.arg(Arg::with_name("seed")
.short("s")
@@ -76,12 +76,12 @@ pub fn main() {
.help("Attempt to recover the seed from the wallet")
.takes_value(false))
.arg(Arg::with_name("nosync")
.help("By default, zecwallet-cli will sync the wallet at startup. Pass --nosync to prevent the automatic sync at startup.")
.help("By default, silentdragonlite-cli will sync the wallet at startup. Pass --nosync to prevent the automatic sync at startup.")
.long("nosync")
.short("n")
.takes_value(false))
.arg(Arg::with_name("COMMAND")
.help("Command to execute. If a command is not specified, zecwallet-cli will start in interactive mode.")
.help("Command to execute. If a command is not specified, silentdragonlite-cli will start in interactive mode.")
.required(false)
.index(1))
.arg(Arg::with_name("PARAMS")
@@ -155,7 +155,7 @@ fn startup(server: http::Uri, dangerous: bool, seed: Option<String>, first_sync:
// Print startup Messages
info!(""); // Blank line
info!("Starting Zecwallet-CLI");
info!("Starting SilentDragonLite CLI");
info!("Light Client config {:?}", config);
if print_updates {