Merge pull request #48 from DenioD/fixzdust
fix a problem with zdust creation
This commit is contained in:
@@ -66,10 +66,6 @@ message Coinsupply {
|
|||||||
int64 total = 6;
|
int64 total = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
message RawMempool {
|
|
||||||
string ID = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message TransparentAddress {
|
message TransparentAddress {
|
||||||
string address = 1;
|
string address = 1;
|
||||||
}
|
}
|
||||||
@@ -95,5 +91,4 @@ service CompactTxStreamer {
|
|||||||
// Misc
|
// Misc
|
||||||
rpc GetLightdInfo(Empty) returns (LightdInfo) {}
|
rpc GetLightdInfo(Empty) returns (LightdInfo) {}
|
||||||
rpc GetCoinsupply(Empty) returns (Coinsupply) {}
|
rpc GetCoinsupply(Empty) returns (Coinsupply) {}
|
||||||
rpc GetRawMempool(Empty) returns (RawMempool) {}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -223,27 +223,6 @@ impl Command for CoinsupplyCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RawMempoolCommand {}
|
|
||||||
impl Command for RawMempoolCommand {
|
|
||||||
fn help(&self) -> String {
|
|
||||||
let mut h = vec![];
|
|
||||||
h.push("Get info about the actual raw of Hush");
|
|
||||||
h.push("Usage:");
|
|
||||||
h.push("rawmempool");
|
|
||||||
h.push("");
|
|
||||||
|
|
||||||
h.join("\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn short_help(&self) -> String {
|
|
||||||
"Get the RawMemPool info".to_string()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn exec(&self, _args: &[&str], lightclient: &LightClient) -> String {
|
|
||||||
lightclient.do_rawmempool()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct BalanceCommand {}
|
struct BalanceCommand {}
|
||||||
impl Command for BalanceCommand {
|
impl Command for BalanceCommand {
|
||||||
fn help(&self) -> String {
|
fn help(&self) -> String {
|
||||||
@@ -877,7 +856,6 @@ pub fn get_commands() -> Box<HashMap<String, Box<dyn Command>>> {
|
|||||||
map.insert("export".to_string(), Box::new(ExportCommand{}));
|
map.insert("export".to_string(), Box::new(ExportCommand{}));
|
||||||
map.insert("info".to_string(), Box::new(InfoCommand{}));
|
map.insert("info".to_string(), Box::new(InfoCommand{}));
|
||||||
map.insert("coinsupply".to_string(), Box::new(CoinsupplyCommand{}));
|
map.insert("coinsupply".to_string(), Box::new(CoinsupplyCommand{}));
|
||||||
map.insert("rawmempool".to_string(), Box::new(RawMempoolCommand{}));
|
|
||||||
map.insert("send".to_string(), Box::new(SendCommand{}));
|
map.insert("send".to_string(), Box::new(SendCommand{}));
|
||||||
map.insert("save".to_string(), Box::new(SaveCommand{}));
|
map.insert("save".to_string(), Box::new(SaveCommand{}));
|
||||||
map.insert("quit".to_string(), Box::new(QuitCommand{}));
|
map.insert("quit".to_string(), Box::new(QuitCommand{}));
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use std::sync::Arc;
|
|||||||
use zcash_primitives::transaction::{TxId};
|
use zcash_primitives::transaction::{TxId};
|
||||||
|
|
||||||
use crate::grpc_client::{ChainSpec, BlockId, BlockRange, RawTransaction,
|
use crate::grpc_client::{ChainSpec, BlockId, BlockRange, RawTransaction,
|
||||||
TransparentAddressBlockFilter, TxFilter, Empty, LightdInfo, Coinsupply, RawMempool};
|
TransparentAddressBlockFilter, TxFilter, Empty, LightdInfo, Coinsupply};
|
||||||
use tonic::transport::{Channel, ClientTlsConfig};
|
use tonic::transport::{Channel, ClientTlsConfig};
|
||||||
use tokio_rustls::{rustls::ClientConfig};
|
use tokio_rustls::{rustls::ClientConfig};
|
||||||
use tonic::{Request};
|
use tonic::{Request};
|
||||||
@@ -95,23 +95,6 @@ pub fn get_coinsupply(uri: http::Uri, no_cert: bool) -> Result<Coinsupply, Strin
|
|||||||
// tokio::runtime::current_thread::Runtime::new().unwrap().block_on(runner)
|
// tokio::runtime::current_thread::Runtime::new().unwrap().block_on(runner)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_rawmempool_info(uri: &http::Uri, no_cert: bool) -> Result<RawMempool, Box<dyn std::error::Error>> {
|
|
||||||
let mut client = get_client(uri, no_cert).await?;
|
|
||||||
|
|
||||||
let request = Request::new(Empty {});
|
|
||||||
|
|
||||||
let response = client.get_raw_mempool(request).await?;
|
|
||||||
|
|
||||||
Ok(response.into_inner())
|
|
||||||
}
|
|
||||||
pub fn get_rawmempool(uri: http::Uri, no_cert: bool) -> Result<RawMempool, String> {
|
|
||||||
let mut rt = tokio::runtime::Runtime::new().map_err(|e| e.to_string())?;
|
|
||||||
|
|
||||||
rt.block_on(get_rawmempool_info(&uri, no_cert)).map_err( |e| e.to_string())
|
|
||||||
// tokio::runtime::current_thread::Runtime::new().unwrap().block_on(runner)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async fn get_block_range<F : 'static + std::marker::Send>(uri: &http::Uri, start_height: u64, end_height: u64, no_cert: bool, mut c: F)
|
async fn get_block_range<F : 'static + std::marker::Send>(uri: &http::Uri, start_height: u64, end_height: u64, no_cert: bool, mut c: F)
|
||||||
-> Result<(), Box<dyn std::error::Error>>
|
-> Result<(), Box<dyn std::error::Error>>
|
||||||
where F : FnMut(&[u8], u64) {
|
where F : FnMut(&[u8], u64) {
|
||||||
|
|||||||
@@ -652,19 +652,6 @@ impl LightClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn do_rawmempool(&self) -> String {
|
|
||||||
match get_rawmempool(self.get_server_uri(), self.config.no_cert_verification) {
|
|
||||||
Ok(i) => {
|
|
||||||
let o = object!{
|
|
||||||
"ID" => i.id
|
|
||||||
|
|
||||||
};
|
|
||||||
o.pretty(2)
|
|
||||||
},
|
|
||||||
Err(e) => e
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn do_seed_phrase(&self) -> Result<JsonValue, &str> {
|
pub fn do_seed_phrase(&self) -> Result<JsonValue, &str> {
|
||||||
if !self.wallet.read().unwrap().is_unlocked_for_spending() {
|
if !self.wallet.read().unwrap().is_unlocked_for_spending() {
|
||||||
error!("Wallet is locked");
|
error!("Wallet is locked");
|
||||||
@@ -914,10 +901,7 @@ impl LightClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn do_new_sietchaddress(&self, addr_type: &str) -> Result<JsonValue, String> {
|
pub fn do_new_sietchaddress(&self, addr_type: &str) -> Result<JsonValue, String> {
|
||||||
if !self.wallet.read().unwrap().is_unlocked_for_spending() {
|
|
||||||
error!("Wallet is locked");
|
|
||||||
return Err("Wallet is locked".to_string());
|
|
||||||
}
|
|
||||||
|
|
||||||
let new_address = {
|
let new_address = {
|
||||||
let wallet = self.wallet.write().unwrap();
|
let wallet = self.wallet.write().unwrap();
|
||||||
|
|||||||
@@ -469,11 +469,9 @@ impl LightWallet {
|
|||||||
|
|
||||||
zaddr
|
zaddr
|
||||||
}
|
}
|
||||||
// Add a new Sietch Addr. This will derive a new zdust address from the seed
|
// Add a new Sietch Addr. This will derive a new zdust address from manipluated seed
|
||||||
pub fn add_zaddrdust(&self) -> String {
|
pub fn add_zaddrdust(&self) -> String {
|
||||||
if !self.unlocked {
|
|
||||||
return "".to_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
let pos = self.extsks.read().unwrap().len() as u32;
|
let pos = self.extsks.read().unwrap().len() as u32;
|
||||||
|
|
||||||
@@ -482,25 +480,21 @@ impl LightWallet {
|
|||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
let letter: String = rng.gen_range(b'A', b'Z').to_string();
|
let letter: String = rng.gen_range(b'A', b'Z').to_string();
|
||||||
let number: String = rng.gen_range(0, 999999).to_string();
|
let number: String = rng.gen_range(0, 999999).to_string();
|
||||||
// let combi: String = letter.to_string() + number.to_string();
|
|
||||||
let s = format!("{}{:06}", letter, number);
|
let s = format!("{}{:06}", letter, number);
|
||||||
//println!("{}", s);
|
let my_string = String::from(s);
|
||||||
|
let dust: &str = &my_string;
|
||||||
let my_string = String::from(s);
|
|
||||||
// let my_immutable_string = &my_string; //This is a &String type
|
|
||||||
let dust: &str = &my_string; //This is an &str type
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let bip39_seed = bip39::Seed::new(&Mnemonic::from_entropy(&self.seed, Language::English).unwrap(), dust);
|
let bip39_seed = bip39::Seed::new(&Mnemonic::from_entropy(&self.seed, Language::English).unwrap(), dust);
|
||||||
|
|
||||||
let (_extsk, _extfvk, address) =
|
let (_extsk, _extfvk, address) =
|
||||||
LightWallet::get_zaddr_from_bip39seed(&self.config, &bip39_seed.as_bytes(), pos);
|
LightWallet::get_zaddr_from_bip39seed(&self.config, &bip39_seed.as_bytes(), pos);
|
||||||
|
|
||||||
let zaddr = encode_payment_address(self.config.hrp_sapling_address(), &address);
|
let zaddr = encode_payment_address(self.config.hrp_sapling_address(), &address);
|
||||||
|
|
||||||
|
|
||||||
zaddr
|
zaddr
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a new t address to the wallet. This will derive a new address from the seed
|
/// Add a new t address to the wallet. This will derive a new address from the seed
|
||||||
|
|||||||
Reference in New Issue
Block a user