Skip to content

Commit

Permalink
release zcash_client_sqlite version 0.11.1
Browse files Browse the repository at this point in the history
Update audits for zcash_client_sqlite

Support older `sqlite` versions.

The `FALSE` constant was introduced in sqlite version 3.23.0,
but Android does not support this version of sqlite until API
level 30; we support back to Android API 27 so we have to use
`0` as the constant for `FALSE` instead.

zcash_client_sqlite: Verify sqlite version compatibility on wallet init.

zcash_client_sqlite: Accept 2-part `major.minor` SQLite versions.

Release zcash_client_sqlite version 0.11.2

add Display for NoteId

set build server true

changes to 'calculate_proposed_transaction'

auto-generated build_server code

added hdwallet dep and finished create_proposed_transactions

updated rust version to 1.77.0

add .0 to rust version in Cargo.toml

add clone to zcash_address::encoding::ParseError

add clone to zcash_address::kind::unified::ParseError

add pub fn to return ua from ZcashAddress

add kind getter to ZcashAddress

change IVK decryption of build_result transaction to External

remove usk_to_tkey override

remove hdwallet dep
  • Loading branch information
nuttycom authored and zancas committed Nov 1, 2024
1 parent ddf5f1b commit 0f478e4
Show file tree
Hide file tree
Showing 16 changed files with 3,206 additions and 85 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ members = [

[workspace.package]
edition = "2021"
rust-version = "1.77"
rust-version = "1.77.0"
repository = "https://github.com/zcash/librustzcash"
license = "MIT OR Apache-2.0"
categories = ["cryptography::cryptocurrencies"]
Expand Down
2 changes: 1 addition & 1 deletion components/zcash_address/src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::kind::unified::Encoding;
use crate::{kind::*, AddressKind, ZcashAddress};

/// An error while attempting to parse a string as a Zcash address.
#[derive(Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ParseError {
/// The string is an invalid encoding.
InvalidEncoding,
Expand Down
2 changes: 1 addition & 1 deletion components/zcash_address/src/kind/unified.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl Typecode {
}

/// An error while attempting to parse a string as a Zcash address.
#[derive(Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ParseError {
/// The unified container contains both P2PKH and P2SH items.
BothP2phkAndP2sh,
Expand Down
16 changes: 15 additions & 1 deletion components/zcash_address/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ pub struct ZcashAddress {

/// Known kinds of Zcash addresses.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
enum AddressKind {
pub enum AddressKind {
Sprout([u8; 64]),
Sapling([u8; 43]),
Unified(unified::Address),
Expand All @@ -163,7 +163,21 @@ enum AddressKind {
Tex([u8; 20]),
}

impl AddressKind {
pub fn get_unified_address(&self) -> Option<unified::Address> {
if let AddressKind::Unified(ua) = self {
Some(ua.clone())
} else {
None
}
}
}

impl ZcashAddress {
pub fn kind(&self) -> &AddressKind {
&self.kind
}

/// Encodes this Zcash address in its canonical string representation.
///
/// This provides the encoded string representation of the address as defined by the
Expand Down
7 changes: 7 additions & 0 deletions supply-chain/imports.lock
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,13 @@ user-id = 6289
user-login = "str4d"
user-name = "Jack Grigg"

[[publisher.zcash_client_sqlite]]
version = "0.11.1"
when = "2024-08-21"
user-id = 169181
user-login = "nuttycom"
user-name = "Kris Nuttycombe"

[[publisher.zcash_encoding]]
version = "0.2.0"
when = "2022-10-19"
Expand Down
2 changes: 1 addition & 1 deletion zcash_client_backend/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn build() -> io::Result<()> {

// Build the gRPC types and client.
tonic_build::configure()
.build_server(false)
.build_server(true)
.client_mod_attribute(
"cash.z.wallet.sdk.rpc",
r#"#[cfg(feature = "lightwalletd-tonic")]"#,
Expand Down
73 changes: 47 additions & 26 deletions zcash_client_backend/src/data_api/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,19 @@ pub type ProposeShieldingErrT<DbT, CommitmentTreeErrT, InputsT, ChangeT> = Error
Infallible,
>;

/// Errors that may be generated in combined creation and execution of transaction proposals.
pub type CreateErrT<DbT, InputsErrT, FeeRuleT, ChangeErrT, N> = Error<
create_proposed_transactions(
wallet_db,
params,
spend_prover,
output_prover,
usk,
ovk_policy,
&proposal,
None,
)
}

type ErrorT<DbT, InputsErrT, FeeRuleT> = Error<
<DbT as WalletRead>::Error,
<DbT as WalletCommitmentTrees>::Error,
InputsErrT,
Expand All @@ -160,16 +171,26 @@ pub type TransferErrT<DbT, InputsT, ChangeT> = Error<
<<InputsT as InputSelector>::InputSource as InputSource>::NoteRef,
>;

/// Errors that may be generated in the execution of shielding proposals.
#[cfg(feature = "transparent-inputs")]
pub type ShieldErrT<DbT, InputsT, ChangeT> = Error<
<DbT as WalletRead>::Error,
<DbT as WalletCommitmentTrees>::Error,
<InputsT as ShieldingSelector>::Error,
<<ChangeT as ChangeStrategy>::FeeRule as FeeRule>::Error,
<ChangeT as ChangeStrategy>::Error,
Infallible,
>;
let proposal = propose_transfer(
wallet_db,
params,
account.id(),
input_selector,
request,
min_confirmations,
)?;

create_proposed_transactions(
wallet_db,
params,
spend_prover,
output_prover,
usk,
ovk_policy,
&proposal,
None,
)
}

/// Select transaction inputs, compute fees, and construct a proposal for a transaction or series
/// of transactions that can then be authorized and made ready for submission to the network with
Expand Down Expand Up @@ -373,7 +394,8 @@ pub fn create_proposed_transactions<DbT, ParamsT, InputsErrT, FeeRuleT, ChangeEr
usk: &UnifiedSpendingKey,
ovk_policy: OvkPolicy,
proposal: &Proposal<FeeRuleT, N>,
) -> Result<NonEmpty<TxId>, CreateErrT<DbT, InputsErrT, FeeRuleT, ChangeErrT, N>>
override_sapling_change_address: Option<sapling::PaymentAddress>,
) -> Result<NonEmpty<TxId>, ErrorT<DbT, InputsErrT, FeeRuleT>>
where
DbT: WalletWrite + WalletCommitmentTrees,
ParamsT: consensus::Parameters + Clone,
Expand Down Expand Up @@ -407,6 +429,7 @@ where
step,
#[cfg(feature = "transparent-inputs")]
&mut unused_transparent_outputs,
override_sapling_change_address,
)?;
step_results.push((step, step_result));
}
Expand Down Expand Up @@ -473,10 +496,8 @@ fn create_proposed_transaction<DbT, ParamsT, InputsErrT, FeeRuleT, ChangeErrT, N
StepOutput,
(TransparentAddress, OutPoint),
>,
) -> Result<
StepResult<<DbT as WalletRead>::AccountId>,
CreateErrT<DbT, InputsErrT, FeeRuleT, ChangeErrT, N>,
>
override_sapling_change_address: Option<sapling::PaymentAddress>,
) -> Result<StepResult<<DbT as WalletRead>::AccountId>, ErrorT<DbT, InputsErrT, FeeRuleT>>
where
DbT: WalletWrite + WalletCommitmentTrees,
ParamsT: consensus::Parameters + Clone,
Expand Down Expand Up @@ -683,9 +704,8 @@ where
utxos_spent.push(outpoint.clone());
builder.add_transparent_input(secret_key, outpoint, txout)?;

Ok(())
};

Ok(())
};
for utxo in proposal_step.transparent_inputs() {
add_transparent_input(
&mut builder,
Expand Down Expand Up @@ -917,7 +937,7 @@ where
PoolType::Shielded(ShieldedProtocol::Sapling) => {
builder.add_sapling_output(
sapling_internal_ovk(),
sapling_dfvk.change_address().1,
override_sapling_change_address.unwrap_or(sapling_dfvk.change_address().1),
change_value.value(),
memo.clone(),
)?;
Expand All @@ -939,7 +959,7 @@ where
{
builder.add_orchard_output(
orchard_internal_ovk(),
orchard_fvk.address_at(0u32, orchard::keys::Scope::Internal),
orchard_fvk.address_at(0u32, orchard::keys::Scope::External),
change_value.value().into(),
memo.clone(),
)?;
Expand Down Expand Up @@ -1005,7 +1025,7 @@ where
let build_result = builder.build(OsRng, spend_prover, output_prover, fee_rule)?;

#[cfg(feature = "orchard")]
let orchard_internal_ivk = orchard_fvk.to_ivk(orchard::keys::Scope::Internal);
let orchard_internal_ivk = orchard_fvk.to_ivk(orchard::keys::Scope::External);
#[cfg(feature = "orchard")]
let orchard_outputs =
orchard_output_meta
Expand All @@ -1030,13 +1050,13 @@ where
})
})
.internal_account_note_transpose_option()
.expect("Wallet-internal outputs must be decryptable with the wallet's IVK");
.expect("Wallet-external outputs must be decryptable with the wallet's IVK");

SentTransactionOutput::from_parts(output_index, recipient, value, memo)
});

let sapling_internal_ivk =
PreparedIncomingViewingKey::new(&sapling_dfvk.to_ivk(Scope::Internal));
PreparedIncomingViewingKey::new(&sapling_dfvk.to_ivk(Scope::External));
let sapling_outputs =
sapling_output_meta
.into_iter()
Expand All @@ -1063,7 +1083,7 @@ where
})
})
.internal_account_note_transpose_option()
.expect("Wallet-internal outputs must be decryptable with the wallet's IVK");
.expect("Wallet-external outputs must be decryptable with the wallet's IVK");

SentTransactionOutput::from_parts(output_index, recipient, value, memo)
});
Expand Down Expand Up @@ -1185,5 +1205,6 @@ where
usk,
OvkPolicy::Sender,
&proposal,
None,
)
}
Loading

0 comments on commit 0f478e4

Please sign in to comment.