Skip to content

Add regtest network support#1

Open
emersonian wants to merge 7 commits into
mainfrom
claude/sleepy-faraday-T6HUy
Open

Add regtest network support#1
emersonian wants to merge 7 commits into
mainfrom
claude/sleepy-faraday-T6HUy

Conversation

@emersonian

Copy link
Copy Markdown

Summary

Adds Regtest network support so zcash-devtool can drive a wallet against a local regtest chain (zebra in Regtest mode behind lightwalletd).

librustzcash's zcash_protocol::consensus::Network models only main/test, but the whole wallet stack (WalletDb, key derivation, address encoding, transaction building) is generic over Parameters. This threads devtool's own data::Network — now implementing Parameters with a Regtest(LocalNetwork) arm — through that stack in place of consensus::Network.

  • --network regtest parses, persists by name in keys.toml, and reconstructs as a LocalNetwork with every upgrade active from height 1 (NU5/Orchard included) — the zebra/zcashd regtest convention.
  • import-ufvk and init-fvk now support regtest instead of rejecting it (via From<NetworkType> for Network).
  • Server presets in remote.rs gain a regtest arm (regtest always uses a custom --server).
  • Builds clean (no new warnings); cargo fmt applied; adds unit tests for regtest parsing + Orchard-active-from-genesis.

Why

This is the enabling half of zecd's regtest end-to-end funding: zcash-devtool acts as the funding wallet — shield a mined transparent coinbase into Orchard, then send to zecd's unified address — so zecd's e2e suite can exercise funded receive/spend on regtest (where mining a shielded coinbase directly to Orchard isn't available).

https://claude.ai/code/session_011z9B9k8AMzQNHwFcaoLzVo


Generated by Claude Code

claude added 7 commits June 7, 2026 19:13
Thread a `Parameters`-implementing `data::Network` (with a `Regtest(LocalNetwork)`
arm) through the wallet stack instead of `zcash_protocol::consensus::Network`,
which models only main/test. The wallet DB, key derivation, address encoding and
transaction building are all generic over `Parameters`, so this lets devtool
operate against a local regtest chain: `--network regtest` parses, persists by
name, and reconstructs as a LocalNetwork with every upgrade active from height 1
(NU5/Orchard included), matching the zebra/zcashd regtest convention.
`import-ufvk`/`init-fvk` now support regtest instead of rejecting it.

This enables zcash-devtool to act as the funding wallet for zecd's regtest
end-to-end tests: shield a mined transparent coinbase into Orchard, then send to
zecd's unified address.

https://claude.ai/code/session_011z9B9k8AMzQNHwFcaoLzVo
`init` previously always prompted for the mnemonic via `rpassword`, which
requires a TTY and so can't be driven from a script or test. Add an optional
`--mnemonic <PHRASE>` argument: when present it is used directly (and the wallet
is treated as a restore); when absent the interactive prompt is unchanged.

This lets zcash-devtool be initialised non-interactively as the funding wallet
in zecd's regtest end-to-end tests.

https://claude.ai/code/session_011z9B9k8AMzQNHwFcaoLzVo
After threading `data::Network` (instead of `consensus::Network`) through the
wallet stack, `opts.network.into()` / `self.network.into()` convert the type to
itself. Pass the value directly — fixes `clippy::useless_conversion` under
`-D warnings`.

https://claude.ai/code/session_011z9B9k8AMzQNHwFcaoLzVo
Derives an account's default unified address and its transparent receiver
straight from a mnemonic — no chain and no on-disk wallet. This lets automated
regtest funding learn the funding wallet's transparent address before any chain
exists (zebra needs it as its coinbase `miner_address` at launch), so the funder
can stay on a single chain and keep a valid wallet birthday anchor.

https://claude.ai/code/session_011z9B9k8AMzQNHwFcaoLzVo
Activating NU6.1 on regtest makes zebra's z_gettreestate fail with "block not in
the main chain" under lightwalletd v0.4.19, breaking wallet init. zecd's harness
and zecd itself therefore run regtest at NU6; devtool's funding wallet must match
or its shield/send transactions are rejected with an incorrect consensus branch
id. Real NU6.1/NU6.2 support is gated on a librustzcash bump.

https://claude.ai/code/session_011z9B9k8AMzQNHwFcaoLzVo
Bump all librustzcash crates to the current crates.io releases
(zcash_client_backend 0.23, zcash_client_sqlite 0.21, zcash_protocol 0.9,
orchard 0.14, …) and drop the [patch.crates-io] git pin to rev 77c422f.
This pulls in:

  - real coinbase-maturity filtering in get_spendable_transparent_outputs
    (the pin had none), so `wallet shield` no longer selects immature
    coinbases that zebra rejects;
  - the orchard 0.14 soundness fixes (retires yanked orchard 0.12.0); and
  - NU6.2 support — regtest_local() now activates the full NU6.x line
    from genesis.

Adapt to the 0.22→0.23 breaking surface:
  - propose_shielding gains a TransparentOutputFilter (use ::All);
  - propose_transfer / create_proposed_transactions gain a trailing
    proposed_version: Option<TxVersion> (pass None);
  - zip321 Payment::new returns Result, not Option;
  - transparent::sighash::SignableInput::from_parts takes the bundle and
    returns Result;
  - pczt into_effects() returns Result;
  - LocalNetwork gains nu6_1 / nu6_2 fields.

MSRV → 1.85.1.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
NU6.1's activation block must carry ZIP-271 lockbox disbursements out of
the deferred pool, which only accrues once NU6 is live — so the regtest
chain activates NU5/NU6 at height 1 and NU6.1/NU6.2 at height 4 (see
zecd's regtest-harness). The funder must use the same heights so its
transactions commit to the same consensus branch id.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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