mirror of
https://github.com/Qortal/piratewallet-light-cli.git
synced 2025-01-31 02:52:14 +00:00
Remove --dangerous option
This commit is contained in:
parent
4f56ba82a0
commit
7cf4d49599
@ -15,7 +15,7 @@ Run `zecwallet-cli help` to see a list of all commands.
|
|||||||
|
|
||||||
## Notes:
|
## Notes:
|
||||||
* The wallet connects to the mainnet by default. To connect to testnet, please pass `--server https://lightd-test.zecwallet.co:443`
|
* 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 [zecwallet lightwalletd](https://github.com/adityapk00/lightwalletd), and then run `./zecwallet-cli --server http://127.0.0.1:9067`.
|
||||||
|
|
||||||
* 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 `~/.zcash/zecwallet-light-wallet.debug.log`. Wallet is stored in `~/.zcash/zecwallet-light-wallet.dat`
|
||||||
|
|
||||||
|
@ -14,10 +14,6 @@ pub mod version;
|
|||||||
macro_rules! configure_clapapp {
|
macro_rules! configure_clapapp {
|
||||||
( $freshapp: expr ) => {
|
( $freshapp: expr ) => {
|
||||||
$freshapp.version(VERSION)
|
$freshapp.version(VERSION)
|
||||||
.arg(Arg::with_name("dangerous")
|
|
||||||
.long("dangerous")
|
|
||||||
.help("Disable server TLS certificate verification. Use this if you're running a local lightwalletd with a self-signed certificate. WARNING: This is dangerous, don't use it with a server that is not your own.")
|
|
||||||
.takes_value(false))
|
|
||||||
.arg(Arg::with_name("nosync")
|
.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, zecwallet-cli will sync the wallet at startup. Pass --nosync to prevent the automatic sync at startup.")
|
||||||
.long("nosync")
|
.long("nosync")
|
||||||
@ -81,10 +77,10 @@ pub fn report_permission_error() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn startup(server: http::Uri, dangerous: bool, seed: Option<String>, birthday: u64, first_sync: bool, print_updates: bool)
|
pub fn startup(server: http::Uri, seed: Option<String>, birthday: u64, first_sync: bool, print_updates: bool)
|
||||||
-> io::Result<(Sender<(String, Vec<String>)>, Receiver<String>)> {
|
-> io::Result<(Sender<(String, Vec<String>)>, Receiver<String>)> {
|
||||||
// Try to get the configuration
|
// Try to get the configuration
|
||||||
let (config, latest_block_height) = LightClientConfig::create(server.clone(), dangerous)?;
|
let (config, latest_block_height) = LightClientConfig::create(server.clone())?;
|
||||||
|
|
||||||
let lightclient = match seed {
|
let lightclient = match seed {
|
||||||
Some(phrase) => Arc::new(LightClient::new_from_phrase(phrase, &config, birthday, false)?),
|
Some(phrase) => Arc::new(LightClient::new_from_phrase(phrase, &config, birthday, false)?),
|
||||||
@ -246,7 +242,6 @@ pub fn attempt_recover_seed(password: Option<String>) {
|
|||||||
sapling_activation_height: 0,
|
sapling_activation_height: 0,
|
||||||
consensus_branch_id: "000000".to_string(),
|
consensus_branch_id: "000000".to_string(),
|
||||||
anchor_offset: 0,
|
anchor_offset: 0,
|
||||||
no_cert_verification: false,
|
|
||||||
data_dir: None,
|
data_dir: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -51,9 +51,8 @@ pub fn main() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let dangerous = matches.is_present("dangerous");
|
|
||||||
let nosync = matches.is_present("nosync");
|
let nosync = matches.is_present("nosync");
|
||||||
let (command_tx, resp_rx) = match startup(server, dangerous, seed, birthday, !nosync, command.is_none()) {
|
let (command_tx, resp_rx) = match startup(server, seed, birthday, !nosync, command.is_none()) {
|
||||||
Ok(c) => c,
|
Ok(c) => c,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let emsg = format!("Error during startup:{}\nIf you repeatedly run into this issue, you might have to restore your wallet from your seed phrase.", e);
|
let emsg = format!("Error during startup:{}\nIf you repeatedly run into this issue, you might have to restore your wallet from your seed phrase.", e);
|
||||||
|
@ -29,7 +29,7 @@ bytes = "0.4"
|
|||||||
prost = "0.6"
|
prost = "0.6"
|
||||||
prost-types = "0.6"
|
prost-types = "0.6"
|
||||||
tokio = { version = "0.2", features = ["rt-threaded", "time", "stream", "fs", "macros", "uds", "full"] }
|
tokio = { version = "0.2", features = ["rt-threaded", "time", "stream", "fs", "macros", "uds", "full"] }
|
||||||
tokio-rustls = { version = "0.13.0", features = ["dangerous_configuration"] }
|
tokio-rustls = { version = "0.13.0" }
|
||||||
webpki = "0.21.0"
|
webpki = "0.21.0"
|
||||||
webpki-roots = "0.18.0"
|
webpki-roots = "0.18.0"
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use log::{error};
|
use log::{error};
|
||||||
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,
|
||||||
@ -11,24 +10,7 @@ use tonic::{Request};
|
|||||||
use crate::PubCertificate;
|
use crate::PubCertificate;
|
||||||
use crate::grpc_client::compact_tx_streamer_client::CompactTxStreamerClient;
|
use crate::grpc_client::compact_tx_streamer_client::CompactTxStreamerClient;
|
||||||
|
|
||||||
mod danger {
|
async fn get_client(uri: &http::Uri) -> Result<CompactTxStreamerClient<Channel>, Box<dyn std::error::Error>> {
|
||||||
use tokio_rustls::rustls;
|
|
||||||
use webpki;
|
|
||||||
|
|
||||||
pub struct NoCertificateVerification {}
|
|
||||||
|
|
||||||
impl rustls::ServerCertVerifier for NoCertificateVerification {
|
|
||||||
fn verify_server_cert(&self,
|
|
||||||
_roots: &rustls::RootCertStore,
|
|
||||||
_presented_certs: &[rustls::Certificate],
|
|
||||||
_dns_name: webpki::DNSNameRef<'_>,
|
|
||||||
_ocsp: &[u8]) -> Result<rustls::ServerCertVerified, rustls::TLSError> {
|
|
||||||
Ok(rustls::ServerCertVerified::assertion())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_client(uri: &http::Uri, no_cert: bool) -> Result<CompactTxStreamerClient<Channel>, Box<dyn std::error::Error>> {
|
|
||||||
let channel = if uri.scheme_str() == Some("http") {
|
let channel = if uri.scheme_str() == Some("http") {
|
||||||
//println!("http");
|
//println!("http");
|
||||||
Channel::builder(uri.clone()).connect().await?
|
Channel::builder(uri.clone()).connect().await?
|
||||||
@ -41,11 +23,6 @@ async fn get_client(uri: &http::Uri, no_cert: bool) -> Result<CompactTxStreamerC
|
|||||||
config.root_store.add_pem_file(
|
config.root_store.add_pem_file(
|
||||||
&mut PubCertificate::get("lightwalletd-zecwallet-co-chain.pem").unwrap().as_ref()).unwrap();
|
&mut PubCertificate::get("lightwalletd-zecwallet-co-chain.pem").unwrap().as_ref()).unwrap();
|
||||||
|
|
||||||
if no_cert {
|
|
||||||
config.dangerous()
|
|
||||||
.set_certificate_verifier(Arc::new(danger::NoCertificateVerification {}));
|
|
||||||
}
|
|
||||||
|
|
||||||
let tls = ClientTlsConfig::new()
|
let tls = ClientTlsConfig::new()
|
||||||
.rustls_client_config(config)
|
.rustls_client_config(config)
|
||||||
.domain_name(uri.host().unwrap());
|
.domain_name(uri.host().unwrap());
|
||||||
@ -62,8 +39,8 @@ async fn get_client(uri: &http::Uri, no_cert: bool) -> Result<CompactTxStreamerC
|
|||||||
// ==============
|
// ==============
|
||||||
// GRPC code
|
// GRPC code
|
||||||
// ==============
|
// ==============
|
||||||
async fn get_lightd_info(uri: &http::Uri, no_cert: bool) -> Result<LightdInfo, Box<dyn std::error::Error>> {
|
async fn get_lightd_info(uri: &http::Uri) -> Result<LightdInfo, Box<dyn std::error::Error>> {
|
||||||
let mut client = get_client(uri, no_cert).await?;
|
let mut client = get_client(uri).await?;
|
||||||
|
|
||||||
let request = Request::new(Empty {});
|
let request = Request::new(Empty {});
|
||||||
|
|
||||||
@ -72,17 +49,17 @@ async fn get_lightd_info(uri: &http::Uri, no_cert: bool) -> Result<LightdInfo, B
|
|||||||
Ok(response.into_inner())
|
Ok(response.into_inner())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_info(uri: &http::Uri, no_cert: bool) -> Result<LightdInfo, String> {
|
pub fn get_info(uri: &http::Uri) -> Result<LightdInfo, String> {
|
||||||
let mut rt = tokio::runtime::Runtime::new().map_err(|e| e.to_string())?;
|
let mut rt = tokio::runtime::Runtime::new().map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
rt.block_on(get_lightd_info(uri, no_cert)).map_err( |e| e.to_string())
|
rt.block_on(get_lightd_info(uri)).map_err( |e| e.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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, 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) {
|
||||||
let mut client = get_client(uri, no_cert).await?;
|
let mut client = get_client(uri).await?;
|
||||||
|
|
||||||
let bs = BlockId{ height: start_height, hash: vec!()};
|
let bs = BlockId{ height: start_height, hash: vec!()};
|
||||||
let be = BlockId{ height: end_height, hash: vec!()};
|
let be = BlockId{ height: end_height, hash: vec!()};
|
||||||
@ -102,7 +79,7 @@ where F : FnMut(&[u8], u64) {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fetch_blocks<F : 'static + std::marker::Send>(uri: &http::Uri, start_height: u64, end_height: u64, no_cert: bool, c: F)
|
pub fn fetch_blocks<F : 'static + std::marker::Send>(uri: &http::Uri, start_height: u64, end_height: u64, c: F)
|
||||||
where F : FnMut(&[u8], u64) {
|
where F : FnMut(&[u8], u64) {
|
||||||
|
|
||||||
let mut rt = match tokio::runtime::Runtime::new() {
|
let mut rt = match tokio::runtime::Runtime::new() {
|
||||||
@ -114,16 +91,16 @@ pub fn fetch_blocks<F : 'static + std::marker::Send>(uri: &http::Uri, start_heig
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
rt.block_on(get_block_range(uri, start_height, end_height, no_cert, c)).unwrap();
|
rt.block_on(get_block_range(uri, start_height, end_height, c)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// get_address_txids GRPC call
|
// get_address_txids GRPC call
|
||||||
async fn get_address_txids<F : 'static + std::marker::Send>(uri: &http::Uri, address: String,
|
async fn get_address_txids<F : 'static + std::marker::Send>(uri: &http::Uri, address: String,
|
||||||
start_height: u64, end_height: u64, no_cert: bool, c: F) -> Result<(), Box<dyn std::error::Error>>
|
start_height: u64, end_height: u64, c: F) -> Result<(), Box<dyn std::error::Error>>
|
||||||
where F : Fn(&[u8], u64) {
|
where F : Fn(&[u8], u64) {
|
||||||
|
|
||||||
let mut client = get_client(uri, no_cert).await?;
|
let mut client = get_client(uri).await?;
|
||||||
let start = Some(BlockId{ height: start_height, hash: vec!()});
|
let start = Some(BlockId{ height: start_height, hash: vec!()});
|
||||||
let end = Some(BlockId{ height: end_height, hash: vec!()});
|
let end = Some(BlockId{ height: end_height, hash: vec!()});
|
||||||
|
|
||||||
@ -141,7 +118,7 @@ async fn get_address_txids<F : 'static + std::marker::Send>(uri: &http::Uri, add
|
|||||||
|
|
||||||
|
|
||||||
pub fn fetch_transparent_txids<F : 'static + std::marker::Send>(uri: &http::Uri, address: String,
|
pub fn fetch_transparent_txids<F : 'static + std::marker::Send>(uri: &http::Uri, address: String,
|
||||||
start_height: u64, end_height: u64, no_cert: bool, c: F)
|
start_height: u64, end_height: u64, c: F)
|
||||||
where F : Fn(&[u8], u64) {
|
where F : Fn(&[u8], u64) {
|
||||||
|
|
||||||
let mut rt = match tokio::runtime::Runtime::new() {
|
let mut rt = match tokio::runtime::Runtime::new() {
|
||||||
@ -153,14 +130,14 @@ pub fn fetch_transparent_txids<F : 'static + std::marker::Send>(uri: &http::Uri,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
rt.block_on(get_address_txids(uri, address, start_height, end_height, no_cert, c)).unwrap();
|
rt.block_on(get_address_txids(uri, address, start_height, end_height, c)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// get_transaction GRPC call
|
// get_transaction GRPC call
|
||||||
async fn get_transaction(uri: &http::Uri, txid: TxId, no_cert: bool)
|
async fn get_transaction(uri: &http::Uri, txid: TxId)
|
||||||
-> Result<RawTransaction, Box<dyn std::error::Error>> {
|
-> Result<RawTransaction, Box<dyn std::error::Error>> {
|
||||||
let mut client = get_client(uri, no_cert).await?;
|
let mut client = get_client(uri).await?;
|
||||||
let request = Request::new(TxFilter { block: None, index: 0, hash: txid.0.to_vec() });
|
let request = Request::new(TxFilter { block: None, index: 0, hash: txid.0.to_vec() });
|
||||||
|
|
||||||
let response = client.get_transaction(request).await?;
|
let response = client.get_transaction(request).await?;
|
||||||
@ -168,7 +145,7 @@ async fn get_transaction(uri: &http::Uri, txid: TxId, no_cert: bool)
|
|||||||
Ok(response.into_inner())
|
Ok(response.into_inner())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fetch_full_tx<F : 'static + std::marker::Send>(uri: &http::Uri, txid: TxId, no_cert: bool, c: F)
|
pub fn fetch_full_tx<F : 'static + std::marker::Send>(uri: &http::Uri, txid: TxId, c: F)
|
||||||
where F : Fn(&[u8]) {
|
where F : Fn(&[u8]) {
|
||||||
let mut rt = match tokio::runtime::Runtime::new() {
|
let mut rt = match tokio::runtime::Runtime::new() {
|
||||||
Ok(r) => r,
|
Ok(r) => r,
|
||||||
@ -179,7 +156,7 @@ pub fn fetch_full_tx<F : 'static + std::marker::Send>(uri: &http::Uri, txid: TxI
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
match rt.block_on(get_transaction(uri, txid, no_cert)) {
|
match rt.block_on(get_transaction(uri, txid)) {
|
||||||
Ok(rawtx) => c(&rawtx.data),
|
Ok(rawtx) => c(&rawtx.data),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Error in get_transaction runtime {}", e.to_string());
|
error!("Error in get_transaction runtime {}", e.to_string());
|
||||||
@ -191,8 +168,8 @@ pub fn fetch_full_tx<F : 'static + std::marker::Send>(uri: &http::Uri, txid: TxI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// send_transaction GRPC call
|
// send_transaction GRPC call
|
||||||
async fn send_transaction(uri: &http::Uri, no_cert: bool, tx_bytes: Box<[u8]>) -> Result<String, Box<dyn std::error::Error>> {
|
async fn send_transaction(uri: &http::Uri, tx_bytes: Box<[u8]>) -> Result<String, Box<dyn std::error::Error>> {
|
||||||
let mut client = get_client(uri, no_cert).await?;
|
let mut client = get_client(uri).await?;
|
||||||
|
|
||||||
let request = Request::new(RawTransaction {data: tx_bytes.to_vec(), height: 0});
|
let request = Request::new(RawTransaction {data: tx_bytes.to_vec(), height: 0});
|
||||||
|
|
||||||
@ -211,15 +188,15 @@ async fn send_transaction(uri: &http::Uri, no_cert: bool, tx_bytes: Box<[u8]>) -
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn broadcast_raw_tx(uri: &http::Uri, no_cert: bool, tx_bytes: Box<[u8]>) -> Result<String, String> {
|
pub fn broadcast_raw_tx(uri: &http::Uri, tx_bytes: Box<[u8]>) -> Result<String, String> {
|
||||||
let mut rt = tokio::runtime::Runtime::new().map_err(|e| e.to_string())?;
|
let mut rt = tokio::runtime::Runtime::new().map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
rt.block_on(send_transaction(uri, no_cert, tx_bytes)).map_err( |e| e.to_string())
|
rt.block_on(send_transaction(uri, tx_bytes)).map_err( |e| e.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
// get_latest_block GRPC call
|
// get_latest_block GRPC call
|
||||||
async fn get_latest_block(uri: &http::Uri, no_cert: bool) -> Result<BlockId, Box<dyn std::error::Error>> {
|
async fn get_latest_block(uri: &http::Uri) -> Result<BlockId, Box<dyn std::error::Error>> {
|
||||||
let mut client = get_client(uri, no_cert).await?;
|
let mut client = get_client(uri).await?;
|
||||||
|
|
||||||
let request = Request::new(ChainSpec {});
|
let request = Request::new(ChainSpec {});
|
||||||
|
|
||||||
@ -228,7 +205,7 @@ async fn get_latest_block(uri: &http::Uri, no_cert: bool) -> Result<BlockId, Box
|
|||||||
Ok(response.into_inner())
|
Ok(response.into_inner())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fetch_latest_block<F : 'static + std::marker::Send>(uri: &http::Uri, no_cert: bool, mut c : F)
|
pub fn fetch_latest_block<F : 'static + std::marker::Send>(uri: &http::Uri, mut c : F)
|
||||||
where F : FnMut(BlockId) {
|
where F : FnMut(BlockId) {
|
||||||
let mut rt = match tokio::runtime::Runtime::new() {
|
let mut rt = match tokio::runtime::Runtime::new() {
|
||||||
Ok(r) => r,
|
Ok(r) => r,
|
||||||
@ -239,7 +216,7 @@ pub fn fetch_latest_block<F : 'static + std::marker::Send>(uri: &http::Uri, no_c
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
match rt.block_on(get_latest_block(uri, no_cert)) {
|
match rt.block_on(get_latest_block(uri)) {
|
||||||
Ok(b) => c(b),
|
Ok(b) => c(b),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Error getting latest block {}", e.to_string());
|
error!("Error getting latest block {}", e.to_string());
|
||||||
|
@ -65,7 +65,6 @@ pub struct LightClientConfig {
|
|||||||
pub sapling_activation_height : u64,
|
pub sapling_activation_height : u64,
|
||||||
pub consensus_branch_id : String,
|
pub consensus_branch_id : String,
|
||||||
pub anchor_offset : u32,
|
pub anchor_offset : u32,
|
||||||
pub no_cert_verification : bool,
|
|
||||||
pub data_dir : Option<String>
|
pub data_dir : Option<String>
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,12 +78,11 @@ impl LightClientConfig {
|
|||||||
sapling_activation_height : 0,
|
sapling_activation_height : 0,
|
||||||
consensus_branch_id : "".to_string(),
|
consensus_branch_id : "".to_string(),
|
||||||
anchor_offset : ANCHOR_OFFSET,
|
anchor_offset : ANCHOR_OFFSET,
|
||||||
no_cert_verification : false,
|
|
||||||
data_dir : dir,
|
data_dir : dir,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create(server: http::Uri, dangerous: bool) -> io::Result<(LightClientConfig, u64)> {
|
pub fn create(server: http::Uri) -> io::Result<(LightClientConfig, u64)> {
|
||||||
use std::net::ToSocketAddrs;
|
use std::net::ToSocketAddrs;
|
||||||
// Test for a connection first
|
// Test for a connection first
|
||||||
format!("{}:{}", server.host().unwrap(), server.port().unwrap())
|
format!("{}:{}", server.host().unwrap(), server.port().unwrap())
|
||||||
@ -93,7 +91,7 @@ impl LightClientConfig {
|
|||||||
.ok_or(std::io::Error::new(ErrorKind::ConnectionRefused, "Couldn't resolve server!"))?;
|
.ok_or(std::io::Error::new(ErrorKind::ConnectionRefused, "Couldn't resolve server!"))?;
|
||||||
|
|
||||||
// Do a getinfo first, before opening the wallet
|
// Do a getinfo first, before opening the wallet
|
||||||
let info = grpcconnector::get_info(&server, dangerous)
|
let info = grpcconnector::get_info(&server)
|
||||||
.map_err(|e| std::io::Error::new(ErrorKind::ConnectionRefused, e))?;
|
.map_err(|e| std::io::Error::new(ErrorKind::ConnectionRefused, e))?;
|
||||||
|
|
||||||
// Create a Light Client Config
|
// Create a Light Client Config
|
||||||
@ -103,7 +101,6 @@ impl LightClientConfig {
|
|||||||
sapling_activation_height : info.sapling_activation_height,
|
sapling_activation_height : info.sapling_activation_height,
|
||||||
consensus_branch_id : info.consensus_branch_id,
|
consensus_branch_id : info.consensus_branch_id,
|
||||||
anchor_offset : ANCHOR_OFFSET,
|
anchor_offset : ANCHOR_OFFSET,
|
||||||
no_cert_verification : dangerous,
|
|
||||||
data_dir : None,
|
data_dir : None,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -681,7 +678,7 @@ impl LightClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn do_info(&self) -> String {
|
pub fn do_info(&self) -> String {
|
||||||
match get_info(&self.get_server_uri(), self.config.no_cert_verification) {
|
match get_info(&self.get_server_uri()) {
|
||||||
Ok(i) => {
|
Ok(i) => {
|
||||||
let o = object!{
|
let o = object!{
|
||||||
"version" => i.version,
|
"version" => i.version,
|
||||||
@ -993,7 +990,7 @@ impl LightClient {
|
|||||||
// This will hold the latest block fetched from the RPC
|
// This will hold the latest block fetched from the RPC
|
||||||
let latest_block_height = Arc::new(AtomicU64::new(0));
|
let latest_block_height = Arc::new(AtomicU64::new(0));
|
||||||
let lbh = latest_block_height.clone();
|
let lbh = latest_block_height.clone();
|
||||||
fetch_latest_block(&self.get_server_uri(), self.config.no_cert_verification,
|
fetch_latest_block(&self.get_server_uri(),
|
||||||
move |block: BlockId| {
|
move |block: BlockId| {
|
||||||
lbh.store(block.height, Ordering::SeqCst);
|
lbh.store(block.height, Ordering::SeqCst);
|
||||||
});
|
});
|
||||||
@ -1067,7 +1064,7 @@ impl LightClient {
|
|||||||
|
|
||||||
let last_invalid_height = Arc::new(AtomicI32::new(0));
|
let last_invalid_height = Arc::new(AtomicI32::new(0));
|
||||||
let last_invalid_height_inner = last_invalid_height.clone();
|
let last_invalid_height_inner = last_invalid_height.clone();
|
||||||
fetch_blocks(&self.get_server_uri(), start_height, end_height, self.config.no_cert_verification,
|
fetch_blocks(&self.get_server_uri(), start_height, end_height,
|
||||||
move |encoded_block: &[u8], height: u64| {
|
move |encoded_block: &[u8], height: u64| {
|
||||||
// Process the block only if there were no previous errors
|
// Process the block only if there were no previous errors
|
||||||
if last_invalid_height_inner.load(Ordering::SeqCst) > 0 {
|
if last_invalid_height_inner.load(Ordering::SeqCst) > 0 {
|
||||||
@ -1137,7 +1134,7 @@ impl LightClient {
|
|||||||
let wallet = self.wallet.clone();
|
let wallet = self.wallet.clone();
|
||||||
let block_times_inner = block_times.clone();
|
let block_times_inner = block_times.clone();
|
||||||
|
|
||||||
fetch_transparent_txids(&self.get_server_uri(), address, start_height, end_height, self.config.no_cert_verification,
|
fetch_transparent_txids(&self.get_server_uri(), address, start_height, end_height,
|
||||||
move |tx_bytes: &[u8], height: u64| {
|
move |tx_bytes: &[u8], height: u64| {
|
||||||
let tx = Transaction::read(tx_bytes).unwrap();
|
let tx = Transaction::read(tx_bytes).unwrap();
|
||||||
|
|
||||||
@ -1195,7 +1192,7 @@ impl LightClient {
|
|||||||
let light_wallet_clone = self.wallet.clone();
|
let light_wallet_clone = self.wallet.clone();
|
||||||
info!("Fetching full Tx: {}", txid);
|
info!("Fetching full Tx: {}", txid);
|
||||||
|
|
||||||
fetch_full_tx(&self.get_server_uri(), txid, self.config.no_cert_verification, move |tx_bytes: &[u8] | {
|
fetch_full_tx(&self.get_server_uri(), txid,move |tx_bytes: &[u8] | {
|
||||||
let tx = Transaction::read(tx_bytes).unwrap();
|
let tx = Transaction::read(tx_bytes).unwrap();
|
||||||
|
|
||||||
light_wallet_clone.read().unwrap().scan_full_tx(&tx, height, 0);
|
light_wallet_clone.read().unwrap().scan_full_tx(&tx, height, 0);
|
||||||
@ -1224,7 +1221,7 @@ impl LightClient {
|
|||||||
);
|
);
|
||||||
|
|
||||||
match rawtx {
|
match rawtx {
|
||||||
Ok(txbytes) => broadcast_raw_tx(&self.get_server_uri(), self.config.no_cert_verification, txbytes),
|
Ok(txbytes) => broadcast_raw_tx(&self.get_server_uri(), txbytes),
|
||||||
Err(e) => Err(format!("Error: No Tx to broadcast. Error was: {}", e))
|
Err(e) => Err(format!("Error: No Tx to broadcast. Error was: {}", e))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -656,7 +656,6 @@ fn get_test_config() -> LightClientConfig {
|
|||||||
sapling_activation_height: 0,
|
sapling_activation_height: 0,
|
||||||
consensus_branch_id: "000000".to_string(),
|
consensus_branch_id: "000000".to_string(),
|
||||||
anchor_offset: 0,
|
anchor_offset: 0,
|
||||||
no_cert_verification: false,
|
|
||||||
data_dir: None,
|
data_dir: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1763,7 +1762,6 @@ fn test_t_derivation() {
|
|||||||
sapling_activation_height: 0,
|
sapling_activation_height: 0,
|
||||||
consensus_branch_id: "000000".to_string(),
|
consensus_branch_id: "000000".to_string(),
|
||||||
anchor_offset: 1,
|
anchor_offset: 1,
|
||||||
no_cert_verification: false,
|
|
||||||
data_dir: None,
|
data_dir: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user