leave zebra-utils untouched

This commit is contained in:
Alfredo Garcia 2024-05-24 15:31:18 -03:00
parent 25cca748b4
commit 63bf21cb12
4 changed files with 64 additions and 36 deletions

View File

@ -4265,6 +4265,18 @@ dependencies = [
"lazy_static",
]
[[package]]
name = "shardtree"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c19f96dde3a8693874f7e7c53d95616569b4009379a903789efbd448f4ea9cc7"
dependencies = [
"bitflags 2.5.0",
"either",
"incrementalmerkletree",
"tracing",
]
[[package]]
name = "shardtree"
version = "0.3.1"
@ -5776,6 +5788,39 @@ dependencies = [
"zcash_protocol",
]
[[package]]
name = "zcash_client_backend"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6a382af39be9ee5a3788157145c404b7cd19acc440903f6c34b09fb44f0e991"
dependencies = [
"base64 0.21.7",
"bech32",
"bls12_381",
"bs58",
"crossbeam-channel",
"group",
"hex",
"incrementalmerkletree",
"memuse",
"nom",
"orchard 0.6.0",
"percent-encoding",
"prost",
"rayon",
"secrecy",
"shardtree 0.1.0",
"subtle",
"time",
"tonic-build 0.10.2",
"tracing",
"which",
"zcash_address",
"zcash_encoding",
"zcash_note_encryption",
"zcash_primitives 0.13.0",
]
[[package]]
name = "zcash_client_backend"
version = "0.12.1"
@ -5802,7 +5847,7 @@ dependencies = [
"rayon",
"sapling-crypto",
"secrecy",
"shardtree",
"shardtree 0.3.1",
"subtle",
"time",
"tonic-build 0.10.2",
@ -6127,7 +6172,7 @@ dependencies = [
"uint",
"x25519-dalek",
"zcash_address",
"zcash_client_backend",
"zcash_client_backend 0.12.1",
"zcash_encoding",
"zcash_history",
"zcash_note_encryption",
@ -6314,7 +6359,7 @@ dependencies = [
"tokio",
"tower",
"tracing",
"zcash_client_backend",
"zcash_client_backend 0.12.1",
"zcash_keys",
"zcash_note_encryption",
"zcash_primitives 0.14.0",
@ -6432,9 +6477,8 @@ dependencies = [
"tokio",
"tracing-error",
"tracing-subscriber",
"zcash_client_backend",
"zcash_primitives 0.14.0",
"zcash_protocol",
"zcash_client_backend 0.10.0",
"zcash_primitives 0.13.0",
"zebra-chain",
"zebra-node-services",
"zebra-rpc",

View File

@ -416,20 +416,6 @@ pub fn scan_block(
)
}
/// Turns a [`SaplingScanningKey`] into [`ScanningKey`] .
///
/// Currently only accepts a string-encoded extended full viewing key.
///
// TODO: use `ViewingKey::parse` from zebra-chain instead
pub fn scanning_key(
key: &SaplingScanningKey,
network: &Network,
) -> Result<DiversifiableFullViewingKey, Report> {
let efvk =
decode_extended_full_viewing_key(network.sapling_efvk_hrp(), key).map_err(|e| eyre!(e))?;
Ok(efvk.to_diversifiable_full_viewing_key())
}
/// Converts a Zebra-format scanning key into some `scan_block()` keys.
///
/// Currently only accepts extended full viewing keys, and returns both their diversifiable full

View File

@ -120,9 +120,8 @@ tokio = { version = "1.37.0", features = ["full"], optional = true }
jsonrpc = { version = "0.18.0", optional = true }
zcash_primitives = { version = "0.14.0", optional = true }
zcash_client_backend = { version = "0.12.1", optional = true, features = ["test-dependencies"] }
zcash_protocol = { version = "0.1.1" }
zcash_primitives = { version = "0.13.0", optional = true }
zcash_client_backend = {version = "0.10.0-rc.1", optional = true}
# For the openapi generator
syn = { version = "2.0.65", features = ["full"], optional = true }

View File

@ -18,7 +18,7 @@ use zcash_primitives::consensus::{BlockHeight, BranchId};
use zcash_primitives::transaction::Transaction;
use zcash_primitives::zip32::AccountId;
use zebra_scan::scan::scanning_key;
use zebra_scan::scan::sapling_key_to_scan_block_keys;
use zebra_scan::{storage::Storage, Config};
/// Prints the memos of transactions from Zebra's scanning results storage.
@ -47,31 +47,30 @@ pub fn main() {
let mut prev_memo = "".to_owned();
for (key, _) in storage.sapling_keys_last_heights().iter() {
let dfvk =
scanning_key(key, &network).expect("Scanning key from the storage should be valid");
let dfvk = sapling_key_to_scan_block_keys(key, &network)
.expect("Scanning key from the storage should be valid")
.0
.into_iter()
.exactly_one()
.expect("There should be exactly one dfvk");
let ufvk_with_acc_id = HashMap::from([(
AccountId::default(),
UnifiedFullViewingKey::new(Some(dfvk)).expect("`dfvk` should be `Some`"),
AccountId::from(1),
UnifiedFullViewingKey::new(Some(dfvk), None).expect("`dfvk` should be `Some`"),
)]);
for (height, txids) in storage.sapling_results(key) {
let height2 = BlockHeight::from(height.0);
let height = BlockHeight::from(height);
for txid in txids.iter() {
let tx = Transaction::read(
&hex::decode(&fetch_tx_via_rpc(txid.encode_hex()))
.expect("RPC response should be decodable from hex string to bytes")[..],
BranchId::for_height(&network.into(), height2),
BranchId::for_height(&network, height),
)
.expect("TX fetched via RPC should be deserializable from raw bytes");
for output in decrypt_transaction(
&network,
zcash_protocol::consensus::BlockHeight::from_u32(height.0),
&tx,
&ufvk_with_acc_id,
) {
for output in decrypt_transaction(&network, height, &tx, &ufvk_with_acc_id) {
let memo = memo_bytes_to_string(output.memo.as_array());
if !memo.is_empty()