This commit is contained in:
Hanh 2022-11-24 12:47:34 +08:00
parent 9d7141ae40
commit 6d56f8a9ef
5 changed files with 16 additions and 11 deletions

View File

@ -11,8 +11,8 @@ pub use utxo::fetch_utxos;
use crate::api::recipient::Recipient;
use thiserror::Error;
use zcash_primitives::consensus::Network;
use ua::decode;
use zcash_primitives::consensus::Network;
use zcash_primitives::memo::Memo;
#[derive(Error, Debug)]

View File

@ -26,7 +26,7 @@ use zcash_primitives::sapling::prover::TxProver;
use zcash_primitives::sapling::{Diversifier, Node, PaymentAddress, Rseed};
use zcash_primitives::transaction::builder::Builder;
use zcash_primitives::transaction::components::{Amount, OutPoint, TxOut};
use zcash_primitives::transaction::sighash::{SignableInput, signature_hash};
use zcash_primitives::transaction::sighash::{signature_hash, SignableInput};
use zcash_primitives::transaction::txid::TxIdDigester;
use zcash_primitives::transaction::{Transaction, TransactionData, TxVersion};
use zcash_primitives::zip32::{ExtendedFullViewingKey, ExtendedSpendingKey};
@ -56,8 +56,9 @@ impl TxBuilderContext {
let TreeCheckpoint { tree, .. } = db.get_tree_by_name(height, "orchard")?;
let hasher = OrchardHasher::new();
Some(tree.root(32, &ORCHARD_ROOTS, &hasher))
}
else { None };
} else {
None
};
let context = TxBuilderContext {
height,
sapling_anchor,

View File

@ -1,10 +1,10 @@
use zcash_primitives::consensus::Network;
use super::{types::*, Result};
use crate::note_selection::fee::FeeCalculator;
use crate::note_selection::ua::decode;
use crate::note_selection::TransactionBuilderError::TxTooComplex;
use crate::note_selection::{TransactionBuilderError, MAX_ATTEMPTS};
use crate::Hash;
use zcash_primitives::consensus::Network;
use zcash_primitives::memo::MemoBytes;
pub fn sum_utxos(utxos: &[UTXO]) -> Result<PoolAllocation> {

View File

@ -10,12 +10,15 @@ pub fn decode(network: &Network, address: &str) -> anyhow::Result<[Option<Destin
if let Ok(data) = decode_payment_address(network.hrp_sapling_payment_address(), address) {
let destination = Destination::Sapling(data.to_bytes());
destinations[Pool::Sapling as usize] = Some(destination);
}
else if let Ok(Some(TransparentAddress::PublicKey(data))) = decode_transparent_address(&network.b58_pubkey_address_prefix(), &network.b58_script_address_prefix(), address) {
} else if let Ok(Some(TransparentAddress::PublicKey(data))) = decode_transparent_address(
&network.b58_pubkey_address_prefix(),
&network.b58_script_address_prefix(),
address,
) {
let destination = Destination::Transparent(data);
destinations[Pool::Transparent as usize] = Some(destination);
}
else if let Ok(address) = ZcashAddress::try_from_encoded(address) { // ZcashAddress only supports Zcash
} else if let Ok(address) = ZcashAddress::try_from_encoded(address) {
// ZcashAddress only supports Zcash
match address.kind {
AddressKind::Sprout(_) => {}
AddressKind::Sapling(data) => {

View File

@ -1,5 +1,5 @@
use anyhow::anyhow;
use crate::DbAdapter;
use anyhow::anyhow;
use chrono::NaiveDateTime;
use zcash_params::coin::get_coin_chain;
@ -55,7 +55,8 @@ pub async fn fetch_historical_prices(
// rounded to daily
let date = NaiveDateTime::from_timestamp_opt(ts, 0)
.ok_or(anyhow!("Invalid Date"))?
.date().and_hms_opt(0, 0, 0)
.date()
.and_hms_opt(0, 0, 0)
.ok_or(anyhow!("Invalid Date"))?;
let timestamp = date.timestamp();
if timestamp != prev_timestamp {