Skip to content

rpc: Implement z_importviewingkey for Sapling#431

Open
mnm458 wants to merge 1 commit into
zcash:mainfrom
mnm458:z_importviewingkey
Open

rpc: Implement z_importviewingkey for Sapling#431
mnm458 wants to merge 1 commit into
zcash:mainfrom
mnm458:z_importviewingkey

Conversation

@mnm458
Copy link
Copy Markdown

@mnm458 mnm458 commented Apr 24, 2026

Summary

Implements z_importviewingkey RPC method for Sapling extended full viewing keys (issue #80).

  • Imports a Sapling extfvk (zxviews/zxviewtestsapling) so the wallet can track transactions without holding spending authority. Accounts are stored with AccountPurpose::ViewOnly.

    • Errors if the wallet already holds the spending key for the given viewing key (matching zcashd behavior).
    • Adds fetch_account_birthday to json_rpc::utils as a shared helper (also needed by Implement z_importkey and z_exportkey for Sapling #400 — whichever merges first provides it).
    • Includes unit tests for parameter validation, key decoding, address derivation, encoding roundtrips, and rejection of invalid/wrong-network/spending keys.

    Why implement this despite zero usage in the survey? Watch-only wallets are a fundamental capability for exchanges, auditors, and operators who need to monitor balances without holding spending keys. As zcashd is deprecated, this becomes the only path for users to import existing viewing keys into the new stack. It also supports the separation-of-concerns model where spending keys stay on cold storage while
    a hot node tracks balances.

    Test plan

    Close rpc: Implement z_importviewingkey #80

@mnm458 mnm458 marked this pull request as draft April 25, 2026 02:05
@mnm458 mnm458 changed the title rpc: Implement z_importviewingkey for Sapling [WIP] rpc: Implement z_importviewingkey for Sapling Apr 25, 2026
@mnm458 mnm458 marked this pull request as ready for review May 10, 2026 11:07
@mnm458 mnm458 changed the title [WIP] rpc: Implement z_importviewingkey for Sapling rpc: Implement z_importviewingkey for Sapling May 10, 2026
Add support for importing Sapling extended full viewing keys via the
z_importviewingkey JSON-RPC method. The wallet will track incoming
and outgoing transactions for addresses derived from imported keys
but will not have spending authority.

Supports the "whenkeyisnew", "yes", and "no" rescan options with
a configurable start height, matching zcashd's interface.

Closes zcash#80
@mnm458 mnm458 force-pushed the z_importviewingkey branch from 0cd39a8 to dca4cbe Compare May 10, 2026 12:08
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.

rpc: Implement z_importviewingkey

1 participant