Skip to content

Commit 5ba2a9f

Browse files
committedFeb 25, 2025·
bumps ECC dep versions and replaces Zebra's usage of the now-deprecated API.
1 parent 4959f61 commit 5ba2a9f

File tree

4 files changed

+29
-27
lines changed

4 files changed

+29
-27
lines changed
 

‎zebra-chain/src/parameters/network/tests/vectors.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Fixed test vectors for the network consensus parameters.
22
3-
use zcash_primitives::consensus::{self as zp_consensus, Parameters};
4-
use zcash_protocol::consensus::NetworkConstants as _;
3+
use zcash_protocol::consensus::{self as zp_consensus, NetworkConstants as _, Parameters};
54

65
use crate::{
76
block::Height,

‎zebra-chain/src/primitives/address.rs

+15-14
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//! Usage: <https://docs.rs/zcash_address/0.2.0/zcash_address/trait.TryFromAddress.html#examples>
44
55
use zcash_address::unified::{self, Container};
6+
use zcash_protocol::consensus::NetworkType;
67

78
use crate::{parameters::NetworkKind, transparent, BoxError};
89

@@ -44,7 +45,7 @@ impl zcash_address::TryFromAddress for Address {
4445
type Error = BoxError;
4546

4647
fn try_from_transparent_p2pkh(
47-
network: zcash_address::Network,
48+
network: NetworkType,
4849
data: [u8; 20],
4950
) -> Result<Self, zcash_address::ConversionError<Self::Error>> {
5051
Ok(Self::Transparent(transparent::Address::from_pub_key_hash(
@@ -54,7 +55,7 @@ impl zcash_address::TryFromAddress for Address {
5455
}
5556

5657
fn try_from_transparent_p2sh(
57-
network: zcash_address::Network,
58+
network: NetworkType,
5859
data: [u8; 20],
5960
) -> Result<Self, zcash_address::ConversionError<Self::Error>> {
6061
Ok(Self::Transparent(transparent::Address::from_script_hash(
@@ -64,7 +65,7 @@ impl zcash_address::TryFromAddress for Address {
6465
}
6566

6667
fn try_from_sapling(
67-
network: zcash_address::Network,
68+
network: NetworkType,
6869
data: [u8; 43],
6970
) -> Result<Self, zcash_address::ConversionError<Self::Error>> {
7071
let network = network.into();
@@ -74,7 +75,7 @@ impl zcash_address::TryFromAddress for Address {
7475
}
7576

7677
fn try_from_unified(
77-
network: zcash_address::Network,
78+
network: NetworkType,
7879
unified_address: zcash_address::unified::Address,
7980
) -> Result<Self, zcash_address::ConversionError<Self::Error>> {
8081
let network = network.into();
@@ -170,27 +171,27 @@ impl Address {
170171
}
171172
}
172173

173-
impl From<zcash_address::Network> for NetworkKind {
174-
fn from(network: zcash_address::Network) -> Self {
174+
impl From<NetworkType> for NetworkKind {
175+
fn from(network: NetworkType) -> Self {
175176
match network {
176-
zcash_address::Network::Main => NetworkKind::Mainnet,
177-
zcash_address::Network::Test => NetworkKind::Testnet,
178-
zcash_address::Network::Regtest => NetworkKind::Regtest,
177+
NetworkType::Main => NetworkKind::Mainnet,
178+
NetworkType::Test => NetworkKind::Testnet,
179+
NetworkType::Regtest => NetworkKind::Regtest,
179180
}
180181
}
181182
}
182183

183-
impl From<NetworkKind> for zcash_address::Network {
184+
impl From<NetworkKind> for NetworkType {
184185
fn from(network: NetworkKind) -> Self {
185186
match network {
186-
NetworkKind::Mainnet => zcash_address::Network::Main,
187-
NetworkKind::Testnet => zcash_address::Network::Test,
188-
NetworkKind::Regtest => zcash_address::Network::Regtest,
187+
NetworkKind::Mainnet => NetworkType::Main,
188+
NetworkKind::Testnet => NetworkType::Test,
189+
NetworkKind::Regtest => NetworkType::Regtest,
189190
}
190191
}
191192
}
192193

193-
impl From<&NetworkKind> for zcash_address::Network {
194+
impl From<&NetworkKind> for NetworkType {
194195
fn from(network: &NetworkKind) -> Self {
195196
(*network).into()
196197
}

‎zebra-chain/src/primitives/viewing_key/sapling.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use zcash_client_backend::{
55
encoding::decode_extended_full_viewing_key,
66
keys::sapling::DiversifiableFullViewingKey as SaplingDfvk,
77
};
8-
use zcash_primitives::constants::*;
8+
use zcash_protocol::constants::*;
99

1010
use crate::parameters::Network;
1111

‎zebra-chain/src/primitives/zcash_primitives.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -293,16 +293,18 @@ pub(crate) fn sighash(
293293
let output = &precomputed_tx_data.all_previous_outputs[input_index];
294294
lock_script = output.lock_script.clone().into();
295295
unlock_script = zcash_primitives::legacy::Script(script_code);
296-
zp_tx::sighash::SignableInput::Transparent(zcash_transparent::sighash::SignableInput {
297-
hash_type: hash_type.bits() as _,
298-
index: input_index,
299-
script_code: &unlock_script,
300-
script_pubkey: &lock_script,
301-
value: output
302-
.value
303-
.try_into()
304-
.expect("amount was previously validated"),
305-
})
296+
zp_tx::sighash::SignableInput::Transparent(
297+
zcash_transparent::sighash::SignableInput::from_parts(
298+
hash_type.bits() as _,
299+
input_index,
300+
&unlock_script,
301+
&lock_script,
302+
output
303+
.value
304+
.try_into()
305+
.expect("amount was previously validated"),
306+
),
307+
)
306308
}
307309
None => zp_tx::sighash::SignableInput::Shielded,
308310
};

0 commit comments

Comments
 (0)