diff --git a/zcash_client_backend/src/data_api.rs b/zcash_client_backend/src/data_api.rs index 361a95d32..4f2e2efa9 100644 --- a/zcash_client_backend/src/data_api.rs +++ b/zcash_client_backend/src/data_api.rs @@ -165,16 +165,16 @@ pub trait WalletRead { /// with which they are associated. fn get_nullifiers(&self) -> Result, Self::Error>; - /// Return all spendable notes. - fn get_spendable_sapling_notes( + /// Return all unspent notes. + fn get_unspent_sapling_notes( &self, account: AccountId, anchor_height: BlockHeight, ) -> Result, Self::Error>; - /// Returns a list of spendable notes sufficient to cover the specified + /// Returns a list of unspent notes sufficient to cover the specified /// target value, if possible. - fn select_spendable_sapling_notes( + fn select_unspent_sapling_notes( &self, account: AccountId, target_value: Amount, @@ -182,7 +182,7 @@ pub trait WalletRead { ) -> Result, Self::Error>; #[cfg(feature = "transparent-inputs")] - fn get_spendable_transparent_utxos( + fn get_unspent_transparent_utxos( &self, address: &TransparentAddress, anchor_height: BlockHeight, @@ -395,7 +395,7 @@ pub mod testing { Ok(Vec::new()) } - fn get_spendable_sapling_notes( + fn get_unspent_sapling_notes( &self, _account: AccountId, _anchor_height: BlockHeight, @@ -403,7 +403,7 @@ pub mod testing { Ok(Vec::new()) } - fn select_spendable_sapling_notes( + fn select_unspent_sapling_notes( &self, _account: AccountId, _target_value: Amount, @@ -413,7 +413,7 @@ pub mod testing { } #[cfg(feature = "transparent-inputs")] - fn get_spendable_transparent_utxos( + fn get_unspent_transparent_utxos( &self, _address: &TransparentAddress, _anchor_height: BlockHeight, diff --git a/zcash_client_backend/src/data_api/wallet.rs b/zcash_client_backend/src/data_api/wallet.rs index 3632f336c..226887cc0 100644 --- a/zcash_client_backend/src/data_api/wallet.rs +++ b/zcash_client_backend/src/data_api/wallet.rs @@ -191,7 +191,7 @@ where let target_value = value + DEFAULT_FEE; let spendable_notes = - wallet_db.select_spendable_sapling_notes(account, target_value, anchor_height)?; + wallet_db.select_unspent_sapling_notes(account, target_value, anchor_height)?; // Confirm we were able to select sufficient value let selected_value = spendable_notes.iter().map(|n| n.note_value).sum(); @@ -296,7 +296,7 @@ where let ovk = exfvk.fvk.ovk; // get UTXOs from DB - let utxos = wallet_db.get_spendable_transparent_utxos(&taddr, latest_anchor)?; + let utxos = wallet_db.get_unspent_transparent_utxos(&taddr, latest_anchor)?; let total_amount = utxos.iter().map(|utxo| utxo.value).sum::(); let fee = DEFAULT_FEE; diff --git a/zcash_client_backend/src/keys.rs b/zcash_client_backend/src/keys.rs index 502801945..d6def4070 100644 --- a/zcash_client_backend/src/keys.rs +++ b/zcash_client_backend/src/keys.rs @@ -75,6 +75,7 @@ pub fn derive_secret_key_from_seed( } #[cfg(feature = "transparent-inputs")] +#[derive(Clone, Debug, Eq, PartialEq)] pub struct Wif(pub String); #[cfg(feature = "transparent-inputs")] @@ -94,7 +95,7 @@ impl Wif { } #[cfg(feature = "transparent-inputs")] -impl TryInto for Wif { +impl<'a> TryInto for &'a Wif { type Error = Bs58Error; fn try_into(self) -> Result { @@ -153,7 +154,7 @@ mod tests { #[test] fn sk_wif_to_taddr() { let sk_wif = Wif("L4BvDC33yLjMRxipZvdiUmdYeRfZmR8viziwsVwe72zJdGbiJPv2".to_string()); - let sk: SecretKey = sk_wif.try_into().expect("invalid wif"); + let sk: SecretKey = (&sk_wif).try_into().expect("invalid wif"); let taddr = derive_transparent_address_from_secret_key(sk); assert_eq!( taddr.encode(&MAIN_NETWORK), diff --git a/zcash_client_sqlite/src/lib.rs b/zcash_client_sqlite/src/lib.rs index daddcba8e..961953a8f 100644 --- a/zcash_client_sqlite/src/lib.rs +++ b/zcash_client_sqlite/src/lib.rs @@ -263,35 +263,30 @@ impl WalletRead for WalletDb

{ wallet::get_nullifiers(&self) } - fn get_spendable_sapling_notes( + fn get_unspent_sapling_notes( &self, account: AccountId, anchor_height: BlockHeight, ) -> Result, Self::Error> { - wallet::transact::get_spendable_sapling_notes(&self, account, anchor_height) + wallet::transact::get_unspent_sapling_notes(&self, account, anchor_height) } - fn select_spendable_sapling_notes( + fn select_unspent_sapling_notes( &self, account: AccountId, target_value: Amount, anchor_height: BlockHeight, ) -> Result, Self::Error> { - wallet::transact::select_spendable_sapling_notes( - &self, - account, - target_value, - anchor_height, - ) + wallet::transact::select_unspent_sapling_notes(&self, account, target_value, anchor_height) } #[cfg(feature = "transparent-inputs")] - fn get_spendable_transparent_utxos( + fn get_unspent_transparent_utxos( &self, address: &TransparentAddress, anchor_height: BlockHeight, ) -> Result, Self::Error> { - wallet::get_spendable_transparent_utxos(&self, address, anchor_height) + wallet::get_unspent_transparent_utxos(&self, address, anchor_height) } } @@ -396,33 +391,33 @@ impl<'a, P: consensus::Parameters> WalletRead for DataConnStmtCache<'a, P> { self.wallet_db.get_nullifiers() } - fn get_spendable_sapling_notes( + fn get_unspent_sapling_notes( &self, account: AccountId, anchor_height: BlockHeight, ) -> Result, Self::Error> { self.wallet_db - .get_spendable_sapling_notes(account, anchor_height) + .get_unspent_sapling_notes(account, anchor_height) } - fn select_spendable_sapling_notes( + fn select_unspent_sapling_notes( &self, account: AccountId, target_value: Amount, anchor_height: BlockHeight, ) -> Result, Self::Error> { self.wallet_db - .select_spendable_sapling_notes(account, target_value, anchor_height) + .select_unspent_sapling_notes(account, target_value, anchor_height) } #[cfg(feature = "transparent-inputs")] - fn get_spendable_transparent_utxos( + fn get_unspent_transparent_utxos( &self, address: &TransparentAddress, anchor_height: BlockHeight, ) -> Result, Self::Error> { self.wallet_db - .get_spendable_transparent_utxos(address, anchor_height) + .get_unspent_transparent_utxos(address, anchor_height) } } diff --git a/zcash_client_sqlite/src/wallet.rs b/zcash_client_sqlite/src/wallet.rs index f95c6d426..0234f267f 100644 --- a/zcash_client_sqlite/src/wallet.rs +++ b/zcash_client_sqlite/src/wallet.rs @@ -599,7 +599,7 @@ pub fn get_nullifiers

( } #[cfg(feature = "transparent-inputs")] -pub fn get_spendable_transparent_utxos( +pub fn get_unspent_transparent_utxos( wdb: &WalletDb

, address: &TransparentAddress, anchor_height: BlockHeight, diff --git a/zcash_client_sqlite/src/wallet/transact.rs b/zcash_client_sqlite/src/wallet/transact.rs index 35ed92f0c..db313c73f 100644 --- a/zcash_client_sqlite/src/wallet/transact.rs +++ b/zcash_client_sqlite/src/wallet/transact.rs @@ -59,7 +59,7 @@ fn to_spendable_note(row: &Row) -> Result { }) } -pub fn get_spendable_sapling_notes

( +pub fn get_unspent_sapling_notes

( wdb: &WalletDb

, account: AccountId, anchor_height: BlockHeight, @@ -87,7 +87,7 @@ pub fn get_spendable_sapling_notes

( notes.collect::>() } -pub fn select_spendable_sapling_notes

( +pub fn select_unspent_sapling_notes

( wdb: &WalletDb

, account: AccountId, target_value: Amount,