Fix dependencies

This commit is contained in:
Hanh 2022-09-11 09:33:04 +08:00
parent 93b768615c
commit 4838a6925d
4 changed files with 7 additions and 14 deletions

View File

@ -105,7 +105,7 @@ apple_metal = ["metal", "objc", "block"]
[dependencies.zcash_params]
git = "https://github.com/hhanh00/zcash-params.git"
rev = "2781e8514533ea9f31e00465ee984036e3fa493c"
rev = "0f1975b0d8799d852fe62e717dad8885eec1f106"
[dependencies.zcash_client_backend]
git = "https://github.com/hhanh00/librustzcash.git"

View File

@ -16,6 +16,8 @@ use zcash_primitives::transaction::builder::Progress;
static mut POST_COBJ: Option<ffi::DartPostCObjectFnType> = None;
static IS_ERROR: AtomicBool = AtomicBool::new(false);
const MAX_COINS: u8 = 3;
lazy_static! {
static ref LAST_ERROR: Mutex<RefCell<String>> = Mutex::new(RefCell::new(String::new()));
}
@ -550,7 +552,7 @@ pub unsafe extern "C" fn get_full_backup(key: *mut c_char) -> *mut c_char {
from_c_str!(key);
let res = || {
let mut accounts = vec![];
for coin in [0, 1] {
for coin in 0..MAX_COINS {
accounts.extend(crate::api::fullbackup::get_full_backup(coin)?);
}
@ -566,7 +568,7 @@ pub unsafe extern "C" fn restore_full_backup(key: *mut c_char, backup: *mut c_ch
from_c_str!(backup);
let res = || {
let accounts = crate::api::fullbackup::decrypt_backup(&key, &backup)?;
for coin in [0, 1] {
for coin in 0..MAX_COINS {
crate::api::fullbackup::restore_full_backup(coin, &accounts)?;
}
Ok(())

View File

@ -9,7 +9,7 @@ const NONCE: &[u8; 12] = b"unique nonce";
pub fn get_full_backup(coin: u8) -> anyhow::Result<Vec<AccountBackup>> {
let c = CoinConfig::get(coin);
let db = c.db()?;
db.get_full_backup()
db.get_full_backup(coin)
}
pub fn restore_full_backup(coin: u8, accounts: &[AccountBackup]) -> anyhow::Result<()> {

View File

@ -850,7 +850,7 @@ impl DbAdapter {
Ok(())
}
pub fn get_full_backup(&self) -> anyhow::Result<Vec<AccountBackup>> {
pub fn get_full_backup(&self, coin: u8) -> anyhow::Result<Vec<AccountBackup>> {
let _ = self.connection.execute(
"ALTER TABLE accounts ADD COLUMN aindex INT NOT NULL DEFAULT 0",
[],
@ -867,7 +867,6 @@ impl DbAdapter {
let z_addr: String = r.get(5)?;
let t_sk: Option<String> = r.get(6)?;
let t_addr: Option<String> = r.get(7)?;
let coin = get_coin_id_by_address(&z_addr);
Ok(AccountBackup {
coin,
name,
@ -1066,14 +1065,6 @@ impl DbAdapter {
}
}
fn get_coin_id_by_address(address: &str) -> u8 {
if address.starts_with("ys") {
1
} else {
0
}
}
pub struct ZMessage {
pub id_tx: u32,
pub sender: Option<String>,