Skip to content

Support P2SH address in zcash - #306

Merged
olga24912 merged 1 commit into
mainfrom
zcash-p2sh
Jul 29, 2026
Merged

Support P2SH address in zcash#306
olga24912 merged 1 commit into
mainfrom
zcash-p2sh

Conversation

@olga24912

Copy link
Copy Markdown
Contributor

No description provided.

@olga24912
olga24912 requested a review from a team as a code owner July 28, 2026 22:27
@olga24912
olga24912 requested a review from kiseln July 28, 2026 22:27
@claude

claude Bot commented Jul 28, 2026

Copy link
Copy Markdown

Pull request overview

This PR adds support for Zcash P2SH (t3/t2) recipient addresses, which were previously rejected at parse time. Zcash addresses are decoded through the zcash_address crate's TryFromAddress trait, whose default try_from_transparent_p2sh returns Unsupported — so both TryFromAddress implementors are extended to handle the P2SH case. A P2SH recipient classifies as transparent/non-orchard, so it flows through the standard transparent (get_tx_outs_multi / get_tx_outs) path rather than the Orchard bundle builder.

Changes:

  • UTXOAddress::try_from_transparent_p2sh maps a 20-byte script hash to the existing UTXOAddress::P2sh variant (mainnet ⇒ t3, testnet ⇒ t2).
  • ZcashAddressReceivers::try_from_transparent_p2sh classifies P2SH as has_transparent = true, has_orchard = false, so get_orchard_mode returns false and routes the withdrawal to the transparent path.
  • Tests flipped from asserting rejection to asserting P2SH parse + roundtrip + transparent classification, plus a new test that get_tx_outs yields a P2SH recipient output alongside a P2PKH change output.

Reviewed changes

Per-file summary
File Description
bridge-sdk/utxo-utils/src/address.rs Adds try_from_transparent_p2sh to TryFromAddress for UTXOAddress, reusing the existing P2sh variant, script_pubkey(), and Display handling.
bridge-sdk/utxo-utils/src/lib.rs Adds try_from_transparent_p2sh to TryFromAddress for ZcashAddressReceivers (transparent, non-orchard); updates/adds tests for t3 parse, classification, and P2SH recipient tx-out building.

Findings

I verified the full routing by static analysis:

  • get_orchard_mode (omni_connector.rs:3651) now returns false for t3 ((false, true) arm), so P2SH recipients take the transparent get_tx_outs_multi path — a valid transparent Zcash output, the same flow already used for t1.
  • The Orchard change-address guard (lib.rs:737) that rejects non-P2PKH change is untouched, so the script_bytes[3..23] P2PKH extraction in get_builder_with_transparent (zcash.rs:230) cannot be fed a P2SH script.
  • UTXOAddress::P2sh already existed (used by BTC), so script_pubkey(), Display, and from_script all handle it — no new exhaustive-match gaps.
  • Both TryFromAddress implementors in the workspace are updated; no other implementors exist. No stale P2SH/t3 rejection guards remain elsewhere in the connector or CLI.

No blocking issues found.

Non-blocking (optional):

  • address.rs:92-98 — the network match is now duplicated across four try_from_* methods; the existing TryFrom<NetworkType> for Network (address.rs:26) could DRY these up. Pre-existing pattern, not introduced here — safe to ignore.

(Note: I could not execute cargo test -p utxo-utils in this sandbox, so the added tests were reviewed statically rather than run.)

✅ Approved

@olga24912
olga24912 merged commit dd8ae79 into main Jul 29, 2026
7 checks passed
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