diff --git a/Cargo.lock b/Cargo.lock index 54c714b71..3152f5a74 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -839,7 +839,7 @@ dependencies = [ [[package]] name = "equihash" version = "0.2.0" -source = "git+https://github.com/zingolabs/librustzcash.git?tag=zingo_backend.0.11.1#91bd418c5cb1aac3cf608cb54cc81b0ac0ae2a50" +source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_address-0.3.2-128-g11bcb838#11bcb838d5f11812ee14d21c68b7c5e571176cf4" dependencies = [ "blake2b_simd", "byteorder", @@ -874,7 +874,7 @@ dependencies = [ [[package]] name = "f4jumble" version = "0.1.0" -source = "git+https://github.com/zingolabs/librustzcash.git?tag=zingo_backend.0.11.1#91bd418c5cb1aac3cf608cb54cc81b0ac0ae2a50" +source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_address-0.3.2-128-g11bcb838#11bcb838d5f11812ee14d21c68b7c5e571176cf4" dependencies = [ "blake2b_simd", ] @@ -3931,19 +3931,20 @@ checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546" [[package]] name = "zcash_address" -version = "0.3.1" -source = "git+https://github.com/zingolabs/librustzcash.git?tag=zingo_backend.0.11.1#91bd418c5cb1aac3cf608cb54cc81b0ac0ae2a50" +version = "0.3.2" +source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_address-0.3.2-128-g11bcb838#11bcb838d5f11812ee14d21c68b7c5e571176cf4" dependencies = [ "bech32", "bs58", "f4jumble", "zcash_encoding", + "zcash_protocol", ] [[package]] name = "zcash_client_backend" version = "0.11.1" -source = "git+https://github.com/zingolabs/librustzcash.git?tag=zingo_backend.0.11.1#91bd418c5cb1aac3cf608cb54cc81b0ac0ae2a50" +source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_address-0.3.2-128-g11bcb838#11bcb838d5f11812ee14d21c68b7c5e571176cf4" dependencies = [ "base64 0.21.7", "bech32", @@ -3977,13 +3978,14 @@ dependencies = [ "zcash_keys", "zcash_note_encryption", "zcash_primitives", + "zcash_protocol", "zip32", ] [[package]] name = "zcash_encoding" version = "0.2.0" -source = "git+https://github.com/zingolabs/librustzcash.git?tag=zingo_backend.0.11.1#91bd418c5cb1aac3cf608cb54cc81b0ac0ae2a50" +source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_address-0.3.2-128-g11bcb838#11bcb838d5f11812ee14d21c68b7c5e571176cf4" dependencies = [ "byteorder", "nonempty", @@ -3991,10 +3993,11 @@ dependencies = [ [[package]] name = "zcash_keys" -version = "0.1.0" -source = "git+https://github.com/zingolabs/librustzcash.git?tag=zingo_backend.0.11.1#91bd418c5cb1aac3cf608cb54cc81b0ac0ae2a50" +version = "0.1.1" +source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_address-0.3.2-128-g11bcb838#11bcb838d5f11812ee14d21c68b7c5e571176cf4" dependencies = [ "bech32", + "blake2b_simd", "bls12_381", "bs58", "byteorder", @@ -4006,11 +4009,13 @@ dependencies = [ "orchard", "rand_core 0.6.4", "sapling-crypto", + "secrecy", "subtle", "tracing", "zcash_address", "zcash_encoding", "zcash_primitives", + "zcash_protocol", "zip32", ] @@ -4030,7 +4035,7 @@ dependencies = [ [[package]] name = "zcash_primitives" version = "0.14.0" -source = "git+https://github.com/zingolabs/librustzcash.git?tag=zingo_backend.0.11.1#91bd418c5cb1aac3cf608cb54cc81b0ac0ae2a50" +source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_address-0.3.2-128-g11bcb838#11bcb838d5f11812ee14d21c68b7c5e571176cf4" dependencies = [ "aes", "bip0039", @@ -4060,6 +4065,7 @@ dependencies = [ "zcash_address", "zcash_encoding", "zcash_note_encryption", + "zcash_protocol", "zcash_spec", "zip32", ] @@ -4067,7 +4073,7 @@ dependencies = [ [[package]] name = "zcash_proofs" version = "0.14.0" -source = "git+https://github.com/zingolabs/librustzcash.git?tag=zingo_backend.0.11.1#91bd418c5cb1aac3cf608cb54cc81b0ac0ae2a50" +source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_address-0.3.2-128-g11bcb838#11bcb838d5f11812ee14d21c68b7c5e571176cf4" dependencies = [ "bellman", "blake2b_simd", @@ -4086,6 +4092,15 @@ dependencies = [ "zcash_primitives", ] +[[package]] +name = "zcash_protocol" +version = "0.1.0" +source = "git+https://github.com/zingolabs/librustzcash.git?tag=zcash_address-0.3.2-128-g11bcb838#11bcb838d5f11812ee14d21c68b7c5e571176cf4" +dependencies = [ + "document-features", + "memuse", +] + [[package]] name = "zcash_spec" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 77a574f93..988dfeb0b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,15 +18,16 @@ resolver = "2" [workspace.dependencies] clap = "4.4" -sapling-crypto = "0.1.0" -zcash_address = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zingo_backend.0.11.1" } -zcash_client_backend = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zingo_backend.0.11.1", features = ["lightwalletd-tonic"] } -zcash_encoding = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zingo_backend.0.11.1" } -zcash_keys = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zingo_backend.0.11.1", features = ["orchard"] } +sapling-crypto = "0.1.2" +zcash_address = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_address-0.3.2-128-g11bcb838" } # git tag -s $(git describe --dirty) +zcash_client_backend = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_address-0.3.2-128-g11bcb838", features = ["lightwalletd-tonic"] } +zcash_encoding = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_address-0.3.2-128-g11bcb838" } +zcash_keys = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_address-0.3.2-128-g11bcb838", features = ["orchard"] } zcash_note_encryption = "0.4" -zcash_primitives = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zingo_backend.0.11.1" } -zcash_proofs = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zingo_backend.0.11.1" } -orchard = "0.7" +zcash_primitives = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_address-0.3.2-128-g11bcb838" } +zcash_proofs = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_address-0.3.2-128-g11bcb838" } +zcash_protocol = { git = "https://github.com/zingolabs/librustzcash.git", tag = "zcash_address-0.3.2-128-g11bcb838" } +orchard = "0.7.1" tonic-build = "0.10" tempdir = "0.3" portpicker = "0.1" diff --git a/integration-tests/tests/integrations.rs b/integration-tests/tests/integrations.rs index 0ab6a6a06..476233357 100644 --- a/integration-tests/tests/integrations.rs +++ b/integration-tests/tests/integrations.rs @@ -553,13 +553,13 @@ mod fast { } let ufvk = wc.ufvk().unwrap(); - let ufvk_string = ufvk.encode(&config.chain.to_zcash_address_network()); + let ufvk_string = ufvk.encode(&config.chain.network_type()); let ufvk_base = WalletBase::Ufvk(ufvk_string.clone()); let view_wallet = LightWallet::new(config.clone(), ufvk_base, wallet.get_birthday().await).unwrap(); let v_wc = view_wallet.wallet_capability(); let vv = v_wc.ufvk().unwrap(); - let vv_string = vv.encode(&config.chain.to_zcash_address_network()); + let vv_string = vv.encode(&config.chain.network_type()); assert_eq!(ufvk_string, vv_string); let client = LightClient::create_from_wallet_async(wallet, config) @@ -642,6 +642,8 @@ mod fast { } } mod slow { + use zcash_primitives::consensus::NetworkConstants; + use super::*; #[tokio::test] diff --git a/zingoconfig/src/lib.rs b/zingoconfig/src/lib.rs index f85820eeb..b7b82abbc 100644 --- a/zingoconfig/src/lib.rs +++ b/zingoconfig/src/lib.rs @@ -18,9 +18,9 @@ use log4rs::{ filter::threshold::ThresholdFilter, Config, }; -use zcash_primitives::{ - consensus::{BlockHeight, NetworkUpgrade, Parameters, MAIN_NETWORK, TEST_NETWORK}, - constants, +use zcash_primitives::consensus::{ + BlockHeight, NetworkConstants, NetworkType, NetworkUpgrade, Parameters, MAIN_NETWORK, + TEST_NETWORK, }; pub const DEFAULT_LIGHTWALLETD_SERVER: &str = "https://mainnet.lightwalletd.com:9067"; @@ -397,30 +397,37 @@ impl ZingoConfig { /// so that HD wallets can manage multiple currencies. /// /// ZEC is registered as 133 (0x80000085) for MainNet and 1 (0x80000001) for TestNet (all coins) + #[deprecated(since = "0.1.0", note = "obsolete due to `Parameter` trait methods")] pub fn get_coin_type(&self) -> u32 { self.chain.coin_type() } + #[deprecated(since = "0.1.0", note = "obsolete due to `Parameter` trait methods")] pub fn hrp_sapling_address(&self) -> &str { self.chain.hrp_sapling_payment_address() } + #[deprecated(since = "0.1.0", note = "obsolete due to `Parameter` trait methods")] pub fn hrp_sapling_private_key(&self) -> &str { self.chain.hrp_sapling_extended_spending_key() } + #[deprecated(since = "0.1.0", note = "obsolete due to `Parameter` trait methods")] pub fn hrp_sapling_viewing_key(&self) -> &str { self.chain.hrp_sapling_extended_full_viewing_key() } + #[deprecated(since = "0.1.0", note = "obsolete due to `Parameter` trait methods")] pub fn base58_pubkey_address(&self) -> [u8; 2] { self.chain.b58_pubkey_address_prefix() } + #[deprecated(since = "0.1.0", note = "obsolete due to `Parameter` trait methods")] pub fn base58_script_address(&self) -> [u8; 2] { self.chain.b58_script_address_prefix() } + #[deprecated(since = "0.1.0", note = "prefix not known to be used")] pub fn base58_secretkey_prefix(&self) -> [u8; 1] { match self.chain { ChainType::Testnet | ChainType::Regtest(_) | ChainType::FakeMainnet => [0xEF], @@ -453,13 +460,6 @@ impl ChainType { ChainType::FakeMainnet => "uview", } } - pub fn to_zcash_address_network(&self) -> zcash_address::Network { - match self { - Mainnet | FakeMainnet => zcash_address::Network::Main, - Testnet => zcash_address::Network::Test, - Regtest(_) => RegtestNetwork::address_network().unwrap(), - } - } } impl std::fmt::Display for ChainType { @@ -475,9 +475,18 @@ impl std::fmt::Display for ChainType { } } -use ChainType::*; impl Parameters for ChainType { + fn network_type(&self) -> NetworkType { + use ChainType::*; + match self { + Mainnet | FakeMainnet => NetworkType::Main, + Testnet => NetworkType::Test, + Regtest(_) => NetworkType::Regtest, + } + } + fn activation_height(&self, nu: NetworkUpgrade) -> Option { + use ChainType::*; match self { Mainnet => MAIN_NETWORK.activation_height(nu), Testnet => TEST_NETWORK.activation_height(nu), @@ -485,58 +494,6 @@ impl Parameters for ChainType { FakeMainnet => Some(BlockHeight::from_u32(1)), } } - - fn coin_type(&self) -> u32 { - match self { - Mainnet | FakeMainnet => constants::mainnet::COIN_TYPE, - Testnet => constants::testnet::COIN_TYPE, - Regtest(_) => RegtestNetwork::coin_type(), - } - } - - fn hrp_sapling_extended_spending_key(&self) -> &str { - match self { - Mainnet | FakeMainnet => constants::mainnet::HRP_SAPLING_EXTENDED_SPENDING_KEY, - Testnet => constants::testnet::HRP_SAPLING_EXTENDED_SPENDING_KEY, - Regtest(_) => RegtestNetwork::hrp_sapling_extended_spending_key(), - } - } - - fn hrp_sapling_extended_full_viewing_key(&self) -> &str { - match self { - Mainnet | FakeMainnet => constants::mainnet::HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY, - Testnet => constants::testnet::HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY, - Regtest(_) => RegtestNetwork::hrp_sapling_extended_full_viewing_key(), - } - } - - fn hrp_sapling_payment_address(&self) -> &str { - match self { - Mainnet | FakeMainnet => constants::mainnet::HRP_SAPLING_PAYMENT_ADDRESS, - Testnet => constants::testnet::HRP_SAPLING_PAYMENT_ADDRESS, - Regtest(_) => RegtestNetwork::hrp_sapling_payment_address(), - } - } - - fn b58_pubkey_address_prefix(&self) -> [u8; 2] { - match self { - Mainnet | FakeMainnet => constants::mainnet::B58_PUBKEY_ADDRESS_PREFIX, - Testnet => constants::testnet::B58_PUBKEY_ADDRESS_PREFIX, - Regtest(_) => RegtestNetwork::b58_pubkey_address_prefix(), - } - } - - fn b58_script_address_prefix(&self) -> [u8; 2] { - match self { - Mainnet | FakeMainnet => constants::mainnet::B58_SCRIPT_ADDRESS_PREFIX, - Testnet => constants::testnet::B58_SCRIPT_ADDRESS_PREFIX, - Regtest(_) => RegtestNetwork::b58_script_address_prefix(), - } - } - - fn address_network(&self) -> Option { - Some(self.to_zcash_address_network()) - } } #[derive(Clone, Copy, Debug, PartialEq)] @@ -603,34 +560,6 @@ impl RegtestNetwork { ), } } - - fn coin_type() -> u32 { - constants::regtest::COIN_TYPE - } - - fn address_network() -> Option { - Some(zcash_address::Network::Regtest) - } - - fn hrp_sapling_extended_spending_key() -> &'static str { - constants::regtest::HRP_SAPLING_EXTENDED_SPENDING_KEY - } - - fn hrp_sapling_extended_full_viewing_key() -> &'static str { - constants::regtest::HRP_SAPLING_EXTENDED_FULL_VIEWING_KEY - } - - fn hrp_sapling_payment_address() -> &'static str { - constants::regtest::HRP_SAPLING_PAYMENT_ADDRESS - } - - fn b58_pubkey_address_prefix() -> [u8; 2] { - constants::regtest::B58_PUBKEY_ADDRESS_PREFIX - } - - fn b58_script_address_prefix() -> [u8; 2] { - constants::regtest::B58_SCRIPT_ADDRESS_PREFIX - } } #[derive(Clone, Copy, Debug, PartialEq)] diff --git a/zingolib/src/commands.rs b/zingolib/src/commands.rs index 37a34bc07..35982cf75 100644 --- a/zingolib/src/commands.rs +++ b/zingolib/src/commands.rs @@ -10,6 +10,7 @@ use std::str::FromStr; use tokio::runtime::Runtime; use zcash_address::unified::{Container, Encoding, Ufvk}; use zcash_client_backend::address::Address; +use zcash_primitives::consensus::Parameters; use zcash_primitives::transaction::fees::zip317::MINIMUM_FEE; lazy_static! { @@ -620,7 +621,7 @@ impl Command for ExportUfvkCommand { Ok(ufvk) => { use zcash_address::unified::Encoding as _; object! { - "ufvk" => ufvk.encode(&lightclient.config().chain.to_zcash_address_network()), + "ufvk" => ufvk.encode(&lightclient.config().chain.network_type()), "birthday" => RT.block_on(lightclient.wallet.get_birthday()) } .pretty(2) diff --git a/zingolib/src/lightclient.rs b/zingolib/src/lightclient.rs index a662e8535..f183ab0ef 100644 --- a/zingolib/src/lightclient.rs +++ b/zingolib/src/lightclient.rs @@ -49,7 +49,7 @@ use zcash_client_backend::{ proto::service::RawTransaction, }; use zcash_primitives::{ - consensus::{BlockHeight, BranchId, Parameters}, + consensus::{BlockHeight, BranchId, NetworkConstants}, memo::{Memo, MemoBytes}, transaction::{ components::amount::NonNegativeAmount, fees::zip317::MINIMUM_FEE, Transaction, TxId, @@ -703,7 +703,7 @@ impl LightClient { Ok(m) => { let memo_bytes: MemoBytes = m.memo.clone().into(); object! { - "to" => encode_payment_address(self.config.hrp_sapling_address(), &m.to), + "to" => encode_payment_address(self.config.chain.hrp_sapling_payment_address(), &m.to), "memo" => LightWallet::memo_str(Some(m.memo)), "memohex" => hex::encode(memo_bytes.as_slice()) } @@ -713,7 +713,10 @@ impl LightClient { } pub fn do_encrypt_message(&self, to_address_str: String, memo: Memo) -> JsonValue { - let to = match decode_payment_address(self.config.hrp_sapling_address(), &to_address_str) { + let to = match decode_payment_address( + self.config.chain.hrp_sapling_payment_address(), + &to_address_str, + ) { Ok(to) => to, _ => { return object! {"error" => format!("Couldn't parse {} as a z-address", to_address_str) }; diff --git a/zingolib/src/wallet.rs b/zingolib/src/wallet.rs index ba3c74779..4561ee20c 100644 --- a/zingolib/src/wallet.rs +++ b/zingolib/src/wallet.rs @@ -21,6 +21,7 @@ use shardtree::error::ShardTreeError; use shardtree::store::memory::MemoryShardStore; use shardtree::ShardTree; use std::convert::Infallible; +use std::ops::Add; use std::{ cmp, io::{self, Error, ErrorKind, Read, Write}, @@ -267,8 +268,12 @@ impl LightWallet { if running_total >= target_amount { break; } - running_total += Amount::from_u64(D::WalletNote::value_from_note(note.note())) - .expect("Note value overflow error"); + running_total = running_total + .add( + Amount::from_u64(D::WalletNote::value_from_note(note.note())) + .expect("should be within the valid monetary range of zatoshis"), + ) + .expect("should be within the valid monetary range of zatoshis"); notes.push(note); } diff --git a/zingolib/src/wallet/keys.rs b/zingolib/src/wallet/keys.rs index 8d2c37fd1..cba797071 100644 --- a/zingolib/src/wallet/keys.rs +++ b/zingolib/src/wallet/keys.rs @@ -8,7 +8,9 @@ use sapling_crypto::{ }; use sha2::Sha256; use zcash_client_backend::address; -use zcash_primitives::{legacy::TransparentAddress, zip32::ChildIndex}; +use zcash_primitives::{ + consensus::NetworkConstants, legacy::TransparentAddress, zip32::ChildIndex, +}; use zingoconfig::ZingoConfig; pub mod extended_transparent; @@ -58,7 +60,7 @@ pub fn get_zaddr_from_bip39seed( &ExtendedSpendingKey::master(bip39_seed), &[ ChildIndex::hardened(32), - ChildIndex::hardened(config.get_coin_type()), + ChildIndex::hardened(config.chain.coin_type()), ChildIndex::hardened(pos), ], ); @@ -90,10 +92,10 @@ pub fn is_shielded_address(addr: &str, config: &ZingoConfig) -> bool { pub fn address_from_pubkeyhash(config: &ZingoConfig, taddr: TransparentAddress) -> String { match taddr { TransparentAddress::PublicKeyHash(hash) => { - hash.to_base58check(&config.base58_pubkey_address(), &[]) + hash.to_base58check(&config.chain.b58_pubkey_address_prefix(), &[]) } TransparentAddress::ScriptHash(hash) => { - hash.to_base58check(&config.base58_script_address(), &[]) + hash.to_base58check(&config.chain.b58_script_address_prefix(), &[]) } } } diff --git a/zingolib/src/wallet/keys/extended_transparent.rs b/zingolib/src/wallet/keys/extended_transparent.rs index 0154ead1b..4f011bc4a 100644 --- a/zingolib/src/wallet/keys/extended_transparent.rs +++ b/zingolib/src/wallet/keys/extended_transparent.rs @@ -5,6 +5,7 @@ use lazy_static::lazy_static; use ring::hmac::{self, Context, Key}; use secp256k1::{Error, PublicKey, Secp256k1, SecretKey, SignOnly}; use zcash_encoding::Vector; +use zcash_primitives::consensus::NetworkConstants; use zingoconfig::ZingoConfig; use crate::wallet::traits::ReadableWriteable; @@ -99,7 +100,7 @@ impl ExtendedPrivKey { .derive_private_key(KeyIndex::hardened_from_normalize_index(44).unwrap()) .unwrap() .derive_private_key( - KeyIndex::hardened_from_normalize_index(config.get_coin_type()).unwrap(), + KeyIndex::hardened_from_normalize_index(config.chain.coin_type()).unwrap(), ) .unwrap() .derive_private_key(KeyIndex::hardened_from_normalize_index(position).unwrap()) diff --git a/zingolib/src/wallet/keys/unified.rs b/zingolib/src/wallet/keys/unified.rs index dd10064d5..328c76f3b 100644 --- a/zingolib/src/wallet/keys/unified.rs +++ b/zingolib/src/wallet/keys/unified.rs @@ -8,6 +8,7 @@ use std::{ use append_only_vec::AppendOnlyVec; use byteorder::{ReadBytesExt, WriteBytesExt}; use orchard::keys::Scope; +use zcash_primitives::consensus::{NetworkConstants, Parameters}; use zcash_primitives::zip339::Mnemonic; use secp256k1::SecretKey; @@ -319,7 +320,7 @@ impl WalletCapability { TransparentAddress::ScriptHash(hash) => hash, }; ( - hash.to_base58check(&config.base58_pubkey_address(), &[]), + hash.to_base58check(&config.chain.b58_pubkey_address_prefix(), &[]), key.1, ) }) @@ -338,7 +339,7 @@ impl WalletCapability { let orchard_key = orchard::keys::SpendingKey::from_zip32_seed( seed, - config.get_coin_type(), + config.chain.coin_type(), AccountId::try_from(position).unwrap(), ) .unwrap(); @@ -382,12 +383,12 @@ impl WalletCapability { pub fn new_from_ufvk(config: &ZingoConfig, ufvk_encoded: String) -> Result { // Decode UFVK - if ufvk_encoded.starts_with(config.hrp_sapling_viewing_key()) { + if ufvk_encoded.starts_with(config.chain.hrp_sapling_extended_full_viewing_key()) { return Err("Viewing keys must be imported in the unified format".to_string()); } let (network, ufvk) = Ufvk::decode(&ufvk_encoded) .map_err(|e| format!("Error decoding unified full viewing key: {}", e))?; - if network != config.chain.to_zcash_address_network() { + if network != config.chain.network_type() { return Err("Given UFVK is not valid for current chain".to_string()); } @@ -438,7 +439,7 @@ impl WalletCapability { { Some(super::ToBase58Check::to_base58check( hash.as_slice(), - &config.base58_pubkey_address(), + &config.chain.b58_pubkey_address_prefix(), &[], )) } else { diff --git a/zingolib/src/wallet/message.rs b/zingolib/src/wallet/message.rs index f05369a3b..80eb07a61 100644 --- a/zingolib/src/wallet/message.rs +++ b/zingolib/src/wallet/message.rs @@ -14,7 +14,7 @@ use zcash_note_encryption::{ Domain, EphemeralKeyBytes, NoteEncryption, ShieldedOutput, ENC_CIPHERTEXT_SIZE, }; use zcash_primitives::{ - consensus::{sapling_zip212_enforcement, BlockHeight}, + consensus::BlockHeight, memo::{Memo, MemoBytes}, }; use zingoconfig::ChainType; @@ -188,7 +188,10 @@ impl Message { epk_bytes, enc_bytes, }, - sapling_zip212_enforcement(&ChainType::Mainnet, BlockHeight::from_u32(1_100_000)), + zcash_primitives::transaction::components::sapling::zip212_enforcement( + &ChainType::Mainnet, + BlockHeight::from_u32(1_100_000), + ), ) { Some((_note, address, memo)) => Ok(Self::new( address, diff --git a/zingolib/src/wallet/traits.rs b/zingolib/src/wallet/traits.rs index b9e11bb75..1cc23b68a 100644 --- a/zingolib/src/wallet/traits.rs +++ b/zingolib/src/wallet/traits.rs @@ -39,7 +39,7 @@ use zcash_note_encryption::{ BatchDomain, Domain, EphemeralKeyBytes, ShieldedOutput, COMPACT_NOTE_SIZE, ENC_CIPHERTEXT_SIZE, }; use zcash_primitives::{ - consensus::{sapling_zip212_enforcement, BlockHeight, NetworkUpgrade, Parameters}, + consensus::{BlockHeight, NetworkConstants, NetworkUpgrade, Parameters}, memo::{Memo, MemoBytes}, merkle_tree::read_incremental_witness, transaction::{ @@ -122,7 +122,12 @@ impl ShieldedOutputExt for Action { impl ShieldedOutputExt for OutputDescription { fn domain(&self, height: BlockHeight, parameters: ChainType) -> SaplingDomain { - SaplingDomain::new(sapling_zip212_enforcement(¶meters, height)) + SaplingDomain::new( + zcash_primitives::transaction::components::sapling::zip212_enforcement( + ¶meters, + height, + ), + ) } fn out_ciphertext(&self) -> [u8; 80] { @@ -241,7 +246,7 @@ impl Recipient for orchard::Address { self.to_raw_address_bytes(), )]) .expect("Could not create UA from orchard address"), - &chain.address_network().unwrap(), + &chain.network_type(), ) } } @@ -286,7 +291,12 @@ impl CompactOutput for CompactSaplingOutput { } fn domain(&self, parameters: ChainType, height: BlockHeight) -> SaplingDomain { - SaplingDomain::new(sapling_zip212_enforcement(¶meters, height)) + SaplingDomain::new( + zcash_primitives::transaction::components::sapling::zip212_enforcement( + ¶meters, + height, + ), + ) } fn to_compact_output_impl(&self) -> Self::CompactAction {