Bug fix: transactiond details
This commit is contained in:
parent
4d3f8e8574
commit
e836eb5485
12
Cargo.toml
12
Cargo.toml
|
@ -69,31 +69,31 @@ base64 = "^0.13"
|
|||
|
||||
[dependencies.zcash_client_backend]
|
||||
git = "https://github.com/hhanh00/librustzcash.git"
|
||||
rev = "a25bb7aaa9bf35669280a2c1b7d6fb8b52f30b2d"
|
||||
rev = "67689473e4edbfbd6d2ff33f6ddd5dd2a402bb20"
|
||||
|
||||
[dependencies.zcash_primitives]
|
||||
git = "https://github.com/hhanh00/librustzcash.git"
|
||||
rev = "a25bb7aaa9bf35669280a2c1b7d6fb8b52f30b2d"
|
||||
rev = "67689473e4edbfbd6d2ff33f6ddd5dd2a402bb20"
|
||||
features = [ "transparent-inputs" ]
|
||||
|
||||
[dependencies.zcash_proofs]
|
||||
git = "https://github.com/hhanh00/librustzcash.git"
|
||||
rev = "a25bb7aaa9bf35669280a2c1b7d6fb8b52f30b2d"
|
||||
rev = "67689473e4edbfbd6d2ff33f6ddd5dd2a402bb20"
|
||||
|
||||
[dependencies.zcash_params]
|
||||
path = "../zcash-params"
|
||||
|
||||
[dependencies.zcash_address]
|
||||
git = "https://github.com/hhanh00/librustzcash.git"
|
||||
rev = "a25bb7aaa9bf35669280a2c1b7d6fb8b52f30b2d"
|
||||
rev = "67689473e4edbfbd6d2ff33f6ddd5dd2a402bb20"
|
||||
|
||||
[dependencies.zcash_encoding]
|
||||
git = "https://github.com/hhanh00/librustzcash.git"
|
||||
rev = "a25bb7aaa9bf35669280a2c1b7d6fb8b52f30b2d"
|
||||
rev = "67689473e4edbfbd6d2ff33f6ddd5dd2a402bb20"
|
||||
|
||||
[dependencies.zcash_note_encryption]
|
||||
git = "https://github.com/hhanh00/librustzcash.git"
|
||||
rev = "a25bb7aaa9bf35669280a2c1b7d6fb8b52f30b2d"
|
||||
rev = "67689473e4edbfbd6d2ff33f6ddd5dd2a402bb20"
|
||||
|
||||
[build-dependencies]
|
||||
tonic-build = "0.4.2"
|
||||
|
|
10
src/chain.rs
10
src/chain.rs
|
@ -15,7 +15,7 @@ use tonic::Request;
|
|||
use zcash_note_encryption::batch::try_compact_note_decryption;
|
||||
use zcash_primitives::consensus::{BlockHeight, Network, NetworkUpgrade, Parameters};
|
||||
use zcash_primitives::merkle_tree::{CommitmentTree, IncrementalWitness};
|
||||
use zcash_primitives::sapling::note_encryption::{SaplingDomain, try_sapling_compact_note_decryption};
|
||||
use zcash_primitives::sapling::note_encryption::SaplingDomain;
|
||||
use zcash_primitives::sapling::{Node, Note, PaymentAddress};
|
||||
use zcash_primitives::transaction::components::sapling::CompactOutputDescription;
|
||||
use zcash_primitives::zip32::ExtendedFullViewingKey;
|
||||
|
@ -137,6 +137,7 @@ struct AccountOutput<'a, N: Parameters> {
|
|||
epk: EphemeralKeyBytes,
|
||||
cmu: <SaplingDomain<N> as Domain>::ExtractedCommitmentBytes,
|
||||
ciphertext: [u8; COMPACT_NOTE_SIZE],
|
||||
tx_index: usize,
|
||||
output_index: usize,
|
||||
block_output_index: usize,
|
||||
vtx: &'a CompactTx,
|
||||
|
@ -144,7 +145,7 @@ struct AccountOutput<'a, N: Parameters> {
|
|||
}
|
||||
|
||||
impl <'a, N: Parameters> AccountOutput<'a, N> {
|
||||
fn new(output_index: usize, block_output_index: usize, vtx: &'a CompactTx, co: &CompactOutput) -> Self {
|
||||
fn new(tx_index: usize, output_index: usize, block_output_index: usize, vtx: &'a CompactTx, co: &CompactOutput) -> Self {
|
||||
let mut epk_bytes = [0u8; 32];
|
||||
epk_bytes.copy_from_slice(&co.epk);
|
||||
let epk = EphemeralKeyBytes::from(epk_bytes);
|
||||
|
@ -155,6 +156,7 @@ impl <'a, N: Parameters> AccountOutput<'a, N> {
|
|||
ciphertext_bytes.copy_from_slice(&co.ciphertext);
|
||||
|
||||
AccountOutput {
|
||||
tx_index,
|
||||
output_index,
|
||||
block_output_index,
|
||||
vtx,
|
||||
|
@ -200,7 +202,7 @@ fn decrypt_notes<'a, N: Parameters>(
|
|||
|
||||
for (output_index, co) in vtx.outputs.iter().enumerate() {
|
||||
let domain = SaplingDomain::<N>::for_height(network.clone(), height);
|
||||
let output = AccountOutput::<N>::new(output_index, count_outputs as usize, vtx, co);
|
||||
let output = AccountOutput::<N>::new(tx_index, output_index, count_outputs as usize, vtx, co);
|
||||
outputs.push((domain, output));
|
||||
|
||||
// let od = to_output_description(co);
|
||||
|
@ -245,7 +247,7 @@ fn decrypt_notes<'a, N: Parameters>(
|
|||
viewonly: vk.1.viewonly,
|
||||
position_in_block: output.1.block_output_index,
|
||||
height: block.height as u32,
|
||||
tx_index: output.1.vtx.index as usize,
|
||||
tx_index: output.1.tx_index,
|
||||
txid: output.1.vtx.hash.clone(),
|
||||
output_index: output.1.output_index,
|
||||
});
|
||||
|
|
|
@ -311,7 +311,7 @@ pub async fn sync_async(
|
|||
return c;
|
||||
});
|
||||
let ids: Vec<_> = ids.into_iter().map(|e| e.id_tx).collect();
|
||||
retrieve_tx_info(coin_type, &mut client, &db_path2, &ids).await?;
|
||||
retrieve_tx_info(coin_type, &mut client, &db_path2, &ids).await.unwrap();
|
||||
}
|
||||
log::info!("Transaction Details : {}", start.elapsed().as_millis());
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@ pub async fn decode_transaction(
|
|||
let mut zaddress = String::new();
|
||||
|
||||
let tx = tx.into_data();
|
||||
// log::info!("{:?}", tx);
|
||||
let sapling_bundle = tx.sapling_bundle().ok_or(anyhow!("No sapling bundle"))?;
|
||||
for spend in sapling_bundle.shielded_spends.iter() {
|
||||
let nf = spend.nullifier.to_vec();
|
||||
|
@ -80,11 +81,12 @@ pub async fn decode_transaction(
|
|||
}
|
||||
}
|
||||
|
||||
let mut contact_decoder = ContactDecoder::new(tx.sapling_bundle().unwrap().shielded_outputs.len());
|
||||
let mut contact_decoder = ContactDecoder::new(sapling_bundle.shielded_outputs.len());
|
||||
|
||||
let mut tx_memo: Memo = Memo::Empty;
|
||||
|
||||
for output in tx.transparent_bundle().ok_or(anyhow!("No transparent bundle"))?.vout.iter() {
|
||||
if let Some(transparent_bundle) = tx.transparent_bundle() {
|
||||
for output in transparent_bundle.vout.iter() {
|
||||
if let Some(taddr) = output.script_pubkey.address() {
|
||||
taddress = encode_transparent_address(
|
||||
&network.b58_pubkey_address_prefix(),
|
||||
|
@ -93,6 +95,7 @@ pub async fn decode_transaction(
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for output in sapling_bundle.shielded_outputs.iter() {
|
||||
if let Some((note, pa, memo)) = try_sapling_note_decryption(network, height, &ivk, output)
|
||||
|
|
Loading…
Reference in New Issue