Skip to content

Add z_importkey and z_exportkey test#76

Draft
oxarbitrage wants to merge 2 commits into
mainfrom
export-import-key-test
Draft

Add z_importkey and z_exportkey test#76
oxarbitrage wants to merge 2 commits into
mainfrom
export-import-key-test

Conversation

@oxarbitrage

Copy link
Copy Markdown
Contributor

A new test for zcash/zallet#400

oxarbitrage added a commit to oxarbitrage/zallet-hub that referenced this pull request Jun 16, 2026
Ran #400 (z_importkey/z_exportkey) through the interop CI (ZIT-Revision)
against zcash/integration-tests#76's wallet_import_export_key.py — passed
(True | 16s). Posted 'merging shortly' comment, stripped ZIT-Revision line.
Left un-merged to merge next session if no new comments. Noted zit-hub
handoffs: pre-existing IT-main RPC test breakage + landing IT #76.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@oxarbitrage

Copy link
Copy Markdown
Contributor Author

Handoff from zallet: extend this test for rescan-on-import (zallet #578 / #579)

Two zallet fixes need coverage here, both about importing into an already-running wallet (no restart) — which this test doesn't yet exercise:

This PR needs a rebase onto current integration-tests main anyway (idle since March; the harness / zallet RPC surface has moved). Proposed additions, all against a running zallet, asserting without a restart:

  1. Existing key, rescan="yes" → re-scan (zallet #581 / #578). Fund a Sapling address; import the key with a birthday at/after the funding height so the note is initially missed; then z_importkey the same key again with rescan="yes" and an earlier startHeight. Assert the previously-missed note now appears. ← core #578 case.
  2. New key, old birthday → historical note found (zallet #579 path). Fund an address, let the wallet scan past it, then z_importkey that key with an early startHeight. Assert the historical balance appears.

Determinism note: put birthdays well below the sync tip (>~100 blocks) so the re-queued range is serviced by the finalized-region scan loop — a birthday within ~100 blocks of the tip only re-scans once the chain advances past the steady-state window.

Once these land on export-import-key-test, PR #581 will carry ZIT-Revision: export-import-key-test so zallet CI runs them against the fix. (Branch name, not a SHA, so the reference survives the rebase.)

@oxarbitrage

Copy link
Copy Markdown
Contributor Author

Also confirm: can imported keys be spent? (suspected separate bug)

Alongside the rescan tests above, while z_importkey is set up please also attempt a spend from the imported account — a code read strongly suggests it currently fails. The imported account is stored as AccountPurpose::Spending { derivation: None }, and the spend path only rebuilds authority from seed + ZIP-32 derivation, so z_sendmany bails before signing (z_send_many.rs:281); the stored Sapling key is never wired into the spend path.

After importing a funded key:

z_sendmany "<imported-sapling-addr>" '[{"address":"<dest>","amount":0.0001}]'

Expected (please confirm): errors with Invalid from address, no payment source found for address.

This is not part of #578/#581 (that's rescan-on-import) — it's a separate suspected bug: an imported spending key whose funds can't be spent. We want to confirm it empirically here before filing a zcash/wallet issue. If it fails as predicted, it's a clean regression bracket (assert-fails-now → assert-succeeds once fixed). If it unexpectedly succeeds, even better — flag it.

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.

1 participant