zcash_client_sqlite: Fix `WalletRead::get_address` return value

Previously it would return an error if the account identifier did not
correspond to a known account.
This commit is contained in:
Jack Grigg 2022-08-31 15:14:12 +00:00
parent a32714043b
commit 7d404d2747
3 changed files with 13 additions and 6 deletions

View File

@ -116,7 +116,6 @@ pub trait WalletRead {
///
/// This will return `Ok(None)` if the account identifier does not correspond
/// to a known account.
// TODO: This does not appear to be the case.
fn get_address(&self, account: AccountId) -> Result<Option<UnifiedAddress>, Self::Error>;
/// Returns all unified full viewing keys known to this wallet.

View File

@ -66,6 +66,11 @@ and this library adheres to Rust's notion of
`zcash_client_backend::data_api::WalletRead::get_unified_full_viewing_keys`
instead).
### Fixed
- The `zcash_client_backend::data_api::WalletRead::get_address` implementation
for `zcash_client_sqlite::WalletDb` now correctly returns `Ok(None)` if the
account identifier does not correspond to a known account.
### Deprecated
- A number of public API methods that are used internally to support the
`zcash_client_backend::data_api::{WalletRead, WalletWrite}` interfaces have

View File

@ -178,11 +178,14 @@ pub(crate) fn get_address_ua<P: consensus::Parameters>(
account: AccountId,
) -> Result<Option<UnifiedAddress>, SqliteClientError> {
// This returns the first diversified address, which will be the default one.
let addr: Option<String> = wdb.conn.query_row_named(
"SELECT address FROM accounts WHERE account = :account",
&[(":account", &u32::from(account))],
|row| row.get(0),
)?;
let addr: Option<String> = wdb
.conn
.query_row_named(
"SELECT address FROM accounts WHERE account = :account",
&[(":account", &u32::from(account))],
|row| row.get(0),
)
.optional()?;
addr.map(|addr_str| {
RecipientAddress::decode(&wdb.params, &addr_str)