Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account APIs needed for the mobile SDKs #1267

Merged
merged 6 commits into from
Mar 13, 2024
Merged

Account APIs needed for the mobile SDKs #1267

merged 6 commits into from
Mar 13, 2024

Conversation

str4d
Copy link
Contributor

@str4d str4d commented Mar 13, 2024

This exposes the kind of account (derived or imported, from which the ZIP 32 account index can be obtained), and enables the WalletRead::Account type to be looked up via WalletRead::AccountId instead of solely via the derivation parameters or UFVK.

@str4d str4d added this to the Librustzcash Zashi 1.0 milestone Mar 13, 2024
@str4d
Copy link
Contributor Author

str4d commented Mar 13, 2024

The changes to zcash_client_sqlite/src/wallet.rs are best reviewed by-commit with whitespace hidden.

/// An incoming viewing key.
///
/// Accounts that have this kind of viewing key cannot be used in wallet contexts,
/// because they are unable to maintain an accurate balance.
Incoming(Uivk),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this will change in #1245

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep that's fine; this is still a private enum.

Comment on lines 336 to 327
kind: AccountType,
viewing_key: ViewingKey,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, doing it this way means that the (Derived, IVK) combination is supported, which doesn't make much sense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not an invalid combination: one could import a UIVK for which you know its derivation pathway, in order to make future identification of the corresponding UFVK and USK easier.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I decided that that would be a reasonable use case, hence "this is fine."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What this boils down to is that the thing that makes an account "usable as a wallet" is that it has a UFVK (and can track balance), not whether we know the derivation path; as long as the caller can provide the corresponding USK when needed, that's all that matters.

nuttycom
nuttycom previously approved these changes Mar 13, 2024
Copy link
Contributor

@nuttycom nuttycom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK #1245 modulo Clippy complaints. Doing the column rename in this PR would also be good.

SqliteClientError::CorruptedData("Unrecognized account_type".to_string())
})?;
let kind = parse_account_kind(
row.get("account_type")?,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realize, somehow, that named column access was supported.

Copy link
Contributor Author

@str4d str4d Mar 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was introduced in #1235 and I don't quite get how it is implemented (or when support was added to rusqlite). It might be nice to do a pass over the crate to use that instead of column indexing, if it is not inefficient, but for now I've stuck with whatever style the local code used in each place.

zcash_client_backend/src/data_api.rs Show resolved Hide resolved
Comment on lines 336 to 327
kind: AccountType,
viewing_key: ViewingKey,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is fine.

Copy link

codecov bot commented Mar 13, 2024

Codecov Report

Attention: Patch coverage is 61.11111% with 49 lines in your changes are missing coverage. Please review.

Project coverage is 63.54%. Comparing base (634ebf5) to head (1e13785).
Report is 1 commits behind head on main.

❗ Current head 1e13785 differs from pull request most recent head b161472. Consider uploading reports for the commit b161472 to get more accurate results

Files Patch % Lines
zcash_client_sqlite/src/wallet.rs 56.17% 39 Missing ⚠️
zcash_client_backend/src/data_api.rs 0.00% 7 Missing ⚠️
zcash_client_sqlite/src/lib.rs 86.95% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1267      +/-   ##
==========================================
- Coverage   63.55%   63.54%   -0.01%     
==========================================
  Files         121      121              
  Lines       13652    13661       +9     
==========================================
+ Hits         8676     8681       +5     
- Misses       4976     4980       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Base automatically changed from apis-for-mobile-sdks to main March 13, 2024 20:57
@str4d str4d dismissed nuttycom’s stale review March 13, 2024 20:57

The base branch was changed.

@str4d
Copy link
Contributor Author

str4d commented Mar 13, 2024

Force-pushed to address review comments.

Copy link
Contributor

@nuttycom nuttycom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK #1245

@str4d str4d merged commit 1c72b0b into main Mar 13, 2024
21 of 24 checks passed
@str4d str4d deleted the account-apis branch March 13, 2024 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants