2021-11-11 17:39:50 -08:00
|
|
|
// #![allow(dead_code)]
|
|
|
|
// #![allow(unused_imports)]
|
2022-10-19 23:24:36 -07:00
|
|
|
// #![warn(missing_docs)]
|
|
|
|
|
|
|
|
//! A library for fast synchronization of y/zcash blockchain
|
|
|
|
//!
|
|
|
|
//! - Implements the warp sync algorithm for sapling
|
|
|
|
//! - Multi Account management
|
|
|
|
|
|
|
|
//! # Example
|
|
|
|
//! ```rust
|
|
|
|
//! use warp_api_ffi::api::account::{get_backup, new_account};
|
|
|
|
//! use warp_api_ffi::api::sync::coin_sync;
|
|
|
|
//! use warp_api_ffi::{CoinConfig, init_coin, set_coin_lwd_url};
|
|
|
|
//! use lazy_static::lazy_static;
|
|
|
|
//! use std::sync::Mutex;
|
|
|
|
//!
|
|
|
|
//! lazy_static! {
|
|
|
|
//! static ref CANCEL: Mutex<bool> = Mutex::new(false);
|
|
|
|
//! }
|
|
|
|
//!
|
|
|
|
//! const FVK: &str = "zxviews1q0duytgcqqqqpqre26wkl45gvwwwd706xw608hucmvfalr759ejwf7qshjf5r9aa7323zulvz6plhttp5mltqcgs9t039cx2d09mgq05ts63n8u35hyv6h9nc9ctqqtue2u7cer2mqegunuulq2luhq3ywjcz35yyljewa4mgkgjzyfwh6fr6jd0dzd44ghk0nxdv2hnv4j5nxfwv24rwdmgllhe0p8568sgqt9ckt02v2kxf5ahtql6s0ltjpkckw8gtymxtxuu9gcr0swvz";
|
|
|
|
//!
|
|
|
|
//! #[tokio::main]
|
|
|
|
//! async fn main() {
|
|
|
|
//! env_logger::init();
|
|
|
|
//!
|
|
|
|
//! // Initialize the library for Zcash (coin = 0)
|
|
|
|
//! init_coin(0, "./zec.db").unwrap();
|
|
|
|
//! set_coin_lwd_url(0, "https://lwdv3.zecwallet.co:443"); // ZecWallet Lightwalletd URL
|
|
|
|
//!
|
|
|
|
//! // Create a new account with the ZEC pages viewing key
|
|
|
|
//! let id_account = new_account(0, "test_account", Some(FVK.to_string()),
|
|
|
|
//! None).unwrap();
|
|
|
|
//!
|
|
|
|
//! // Synchronize
|
|
|
|
//! coin_sync(0 /* zcash */,
|
|
|
|
//! true /* retrieve tx details */,
|
|
|
|
//! 0 /* sync to tip */,
|
|
|
|
//! 100 /* spam filter threshold */, |p| {
|
|
|
|
//! log::info!("Progress: {}", p.height);
|
|
|
|
//! }, &CANCEL).await.unwrap();
|
|
|
|
//!
|
|
|
|
//! // Grab the database accessor
|
|
|
|
//! let cc = &CoinConfig::get(0 /* zcash */);
|
|
|
|
//! let db = cc.db.as_ref().unwrap().clone();
|
|
|
|
//! let db = db.lock().unwrap();
|
|
|
|
//!
|
|
|
|
//! // Query the account balance
|
|
|
|
//! let balance = db.get_balance(id_account).unwrap();
|
|
|
|
//!
|
|
|
|
//! println!("Balance = {}", balance)
|
|
|
|
//! }
|
|
|
|
//! ```
|
|
|
|
|
2021-06-17 09:56:20 -07:00
|
|
|
#[path = "generated/cash.z.wallet.sdk.rpc.rs"]
|
|
|
|
pub mod lw_rpc;
|
|
|
|
|
2021-06-29 00:04:12 -07:00
|
|
|
// Mainnet
|
2022-11-17 01:13:51 -08:00
|
|
|
// const LWD_URL: &str = "https://mainnet.lightwalletd.com:9067";
|
2021-06-29 00:04:12 -07:00
|
|
|
// pub const LWD_URL: &str = "https://lwdv3.zecwallet.co";
|
2021-07-16 01:42:29 -07:00
|
|
|
// pub const LWD_URL: &str = "http://lwd.hanh.me:9067";
|
2022-06-07 09:58:24 -07:00
|
|
|
// pub const LWD_URL: &str = "http://127.0.0.1:9067";
|
2021-06-29 00:04:12 -07:00
|
|
|
|
|
|
|
// Testnet
|
2021-07-07 08:38:22 -07:00
|
|
|
// pub const LWD_URL: &str = "https://testnet.lightwalletd.com:9067";
|
2021-06-29 00:04:12 -07:00
|
|
|
// pub const LWD_URL: &str = "http://lwd.hanh.me:9067";
|
2021-09-12 19:53:54 -07:00
|
|
|
// pub const LWD_URL: &str = "http://127.0.0.1:9067";
|
|
|
|
|
|
|
|
// YCash
|
2021-11-11 17:39:50 -08:00
|
|
|
// pub const LWD_URL: &str = "https://lite.ycash.xyz:9067";
|
2021-06-17 09:56:20 -07:00
|
|
|
|
2022-10-19 23:32:11 -07:00
|
|
|
pub type Hash = [u8; 32];
|
|
|
|
|
2022-10-22 19:34:50 -07:00
|
|
|
// mod builder;
|
2021-06-17 09:56:20 -07:00
|
|
|
mod chain;
|
2022-06-08 05:48:16 -07:00
|
|
|
mod coinconfig;
|
2022-10-22 19:34:50 -07:00
|
|
|
// mod commitment;
|
2021-11-11 17:39:50 -08:00
|
|
|
mod contact;
|
2021-06-21 17:33:13 -07:00
|
|
|
mod db;
|
2022-06-20 02:05:11 -07:00
|
|
|
mod fountain;
|
2021-07-16 01:42:29 -07:00
|
|
|
mod hash;
|
2022-10-28 06:02:34 -07:00
|
|
|
mod orchard;
|
2022-11-06 04:50:51 -08:00
|
|
|
mod sapling;
|
|
|
|
mod sync;
|
2022-10-28 23:40:05 -07:00
|
|
|
// mod key;
|
2022-06-08 05:48:16 -07:00
|
|
|
mod key2;
|
2021-06-26 02:52:03 -07:00
|
|
|
mod mempool;
|
2022-07-17 19:55:57 -07:00
|
|
|
mod misc;
|
2021-08-16 06:07:04 -07:00
|
|
|
mod pay;
|
|
|
|
mod prices;
|
2022-10-22 19:34:50 -07:00
|
|
|
// mod print;
|
2022-11-06 04:50:51 -08:00
|
|
|
mod note_selection;
|
2021-06-26 02:52:03 -07:00
|
|
|
mod scan;
|
2021-07-09 06:33:05 -07:00
|
|
|
mod taddr;
|
2021-07-09 22:44:13 -07:00
|
|
|
mod transaction;
|
2022-10-30 03:03:38 -07:00
|
|
|
mod unified;
|
2022-10-21 21:01:29 -07:00
|
|
|
// mod ua;
|
2022-07-26 19:11:36 -07:00
|
|
|
mod zip32;
|
2022-06-08 05:48:16 -07:00
|
|
|
// mod wallet;
|
2022-10-19 23:24:36 -07:00
|
|
|
/// accounts, sync, payments, etc.
|
2022-06-09 10:05:58 -07:00
|
|
|
pub mod api;
|
2021-06-18 01:17:41 -07:00
|
|
|
|
2022-03-30 17:40:02 -07:00
|
|
|
#[cfg(feature = "ledger")]
|
|
|
|
mod ledger;
|
|
|
|
|
2022-11-06 04:50:51 -08:00
|
|
|
pub use crate::chain::{connect_lightwalletd, get_best_server, ChainError};
|
2022-06-10 03:09:37 -07:00
|
|
|
pub use crate::coinconfig::{
|
2022-11-06 04:50:51 -08:00
|
|
|
init_coin, set_active, set_active_account, set_coin_lwd_url, CoinConfig, COIN_CONFIG,
|
2022-06-10 03:09:37 -07:00
|
|
|
};
|
2022-11-22 19:18:54 -08:00
|
|
|
pub use crate::db::{AccountData, AccountRec, DbAdapter, DbAdapterBuilder, TxRec};
|
2022-10-19 23:32:11 -07:00
|
|
|
pub use crate::fountain::{FountainCodes, RaptorQDrops};
|
2022-10-28 23:40:05 -07:00
|
|
|
// pub use crate::key::KeyHelpers;
|
2021-06-18 01:17:41 -07:00
|
|
|
pub use crate::lw_rpc::compact_tx_streamer_client::CompactTxStreamerClient;
|
|
|
|
pub use crate::lw_rpc::*;
|
2022-10-19 23:24:36 -07:00
|
|
|
pub use crate::pay::{broadcast_tx, Tx, TxIn, TxOut};
|
2022-06-08 05:48:16 -07:00
|
|
|
// pub use crate::wallet::{decrypt_backup, encrypt_backup, RecipientMemo, Wallet, WalletBalance};
|
2022-06-06 18:27:50 -07:00
|
|
|
|
2022-11-06 04:50:51 -08:00
|
|
|
pub use note_selection::{
|
2023-04-14 06:00:42 -07:00
|
|
|
Source, Destination,
|
2022-11-12 17:39:12 -08:00
|
|
|
build_tx, build_tx_plan, fetch_utxos, get_secret_keys, TransactionBuilderConfig,
|
2022-11-15 19:51:52 -08:00
|
|
|
TransactionBuilderError, TransactionPlan, TxBuilderContext, MAX_ATTEMPTS,
|
2022-11-06 04:50:51 -08:00
|
|
|
};
|
|
|
|
pub use unified::{decode_unified_address, get_unified_address};
|
2022-10-30 03:03:38 -07:00
|
|
|
|
2022-07-21 04:22:41 -07:00
|
|
|
#[cfg(feature = "nodejs")]
|
|
|
|
pub mod nodejs;
|
2022-08-02 07:34:15 -07:00
|
|
|
|
2022-08-17 04:05:53 -07:00
|
|
|
mod gpu;
|
2022-08-13 19:56:42 -07:00
|
|
|
|
2022-11-05 18:49:17 -07:00
|
|
|
pub fn init_test() {
|
|
|
|
let _ = env_logger::try_init();
|
|
|
|
init_coin(0, "./zec.db").unwrap();
|
|
|
|
set_coin_lwd_url(0, "http://127.0.0.1:9067");
|
|
|
|
}
|
2023-04-14 06:00:42 -07:00
|
|
|
|
|
|
|
#[cfg(feature = "ledger")]
|
2023-04-15 01:53:16 -07:00
|
|
|
pub use ledger::{build_broadcast_tx, ledger_get_taddr};
|
|
|
|
|
|
|
|
pub use taddr::derive_from_secretkey;
|