Skip to content

Download the Sapling parameters for Zcash sends - #1566

Draft
sneurlax wants to merge 1 commit into
feat/zcash-uifrom
feat/zcash-params
Draft

sneurlax wants to merge 1 commit into
feat/zcash-uifrom
feat/zcash-params

Conversation

@sneurlax

@sneurlax sneurlax commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Download the Sapling proving parameters, which a Zcash transaction with a Sapling output is proven with, so that paying a Sapling address works.
  • The download starts in the background when a Zcash wallet is created or restored. A send that needs the parameters before they are on disk waits for the download, before it takes the wallet's send lock and before the heights of the transaction are chosen.
  • The two files (about 52 MB together) come from https://download.z.cash/downloads/, through Tor when Tor is enabled, and are used only after their lengths and SHA-256 digests match the ones the Zcash project publishes. The backend's cache does the verification and the atomic install; this PR adds the source and the calls.

Stacked on #1565.

Commits

  1. feat: download the Sapling parameters for Zcash sends.

Size

11 files, +503/-21: the service (137 lines) and its test (153), the wallet's default resolver and the fetch before the send lock (with a test), one call in each of the three views that open a new or restored Zcash wallet, and a Sapling payment in the end-to-end test with its SAPLING_PARAMS_DIR option.

How it works

  • lib/services/zcash_sapling_parameters.dart holds the one service: resolve() returns the verified parameters, downloading them first if they are missing, and callers that arrive during a download share it. ensureInBackground() starts that without waiting and logs a failure.
  • ZcashWallet's default parameter resolver is now that service. A failure surfaces as the existing ZcashSaplingParametersUnavailableException, which now says which kind it was: the download (with a Tor variant), files that are not the published ones, or storage.
  • prepareSend fetches the parameters first when a recipient is paid in the Sapling pool, so a download does not hold the send lock that closing or deleting the wallet waits for.
  • The new wallet view, the restore view and Stack Backup restore call ensureInBackground() after opening a Zcash wallet.
  • The files live under the app's data directory, in zcash/sapling_parameters, shared by all Zcash wallets.

Known limits

  • The download has no progress display. At wallet creation it is in the background. At send time the send view's usual loading dialog stays up until the download ends.
  • A download fails after 30 seconds without progress or after an hour in total, and a failed download starts over: the backend's cache has no resume.
  • The download address is the Zcash project's. Mirroring the files is a product decision; the digests make the source untrusted either way.
  • Sapling, Orchard and transparent funds still cannot be spent. That is the next PR.

Verification

At this PR's head (63702f4eb):

  • The service's tests (test/services/zcash_sapling_parameters_test.dart): 5 pass. They cover a download followed by use of the files with no second download, a file that is not the published one being refused and not installed, the message for each kind of failure, concurrent callers sharing one download, and a failed background download.
  • A wallet test shows that a payment to a Sapling address fetches the parameters without holding the send lock, and that a payment to a Unified Address fetches nothing.
  • One real download through the default source, on a clear connection: both files, verified, in 39 s.
  • The end-to-end suite, which now pays a Sapling address: 1/1, with SAPLING_PARAMS_DIR set to a local copy of the files.
  • The wallet creation suite for Zcash on Linux, which now also starts the download in the created wallet's app: 2/2.
  • flutter analyze on the changed Dart files: no errors. CI's format check on them: clean.
  • The full flutter test suite: 1570 passed, 8 skipped, and three of the Firo cache tests named in Add Zcash wallet core integration #1563, which time out in full runs on this machine and pass on their own (17/17).

Not run: the download through Tor.

@codecov

codecov Bot commented Dec 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 59.21053% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 22.11%. Comparing base (caed3d6) to head (63702f4).

Files with missing lines Patch % Lines
lib/services/zcash_sapling_parameters.dart 51.16% 21 Missing ⚠️
lib/wallets/wallet/impl/zcash_wallet.dart 63.15% 7 Missing ⚠️
..._view/new_wallet_recovery_phrase_warning_view.dart 0.00% 1 Missing ⚠️
...views/restore_wallet_view/restore_wallet_view.dart 0.00% 1 Missing ⚠️
...ck_backup_views/helpers/restore_create_backup.dart 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                @@
##           feat/zcash-ui    #1566      +/-   ##
=================================================
- Coverage          22.12%   22.11%   -0.01%     
=================================================
  Files               1157     1158       +1     
  Lines             116430   116497      +67     
=================================================
+ Hits               25755    25764       +9     
- Misses             90675    90733      +58     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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