You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.