Skip to content

Add Zcash memo support to Rust SDK and CLI#276

Merged
frolvanya merged 3 commits into
Near-One:mainfrom
tzarebczan:feat/zcash-memo-support
May 29, 2026
Merged

Add Zcash memo support to Rust SDK and CLI#276
frolvanya merged 3 commits into
Near-One:mainfrom
tzarebczan:feat/zcash-memo-support

Conversation

@tzarebczan

@tzarebczan tzarebczan commented May 11, 2026

Copy link
Copy Markdown
Contributor

Package: Zcash memo support

This is the Rust SDK / CLI half of a coordinated two-repo package for Zcash memo support.

Companion PR: Near-One/bridge-sdk-js#470

Summary

Adds an explicit Zcash-only memo path for NEAR-to-Zcash withdrawals while keeping the existing shared BTC/Zcash commands unchanged for users who do not need memo support.

The implementation is additive:

  • Adds near-submit-zcash-transfer with optional --memo.
  • Adds internal init-near-to-zcash-transfer with optional --memo.
  • Adds SDK wrapper methods that preserve existing public method signatures and route None through the existing behavior.
  • Embeds the memo only when the destination resolves to an Orchard shielded output.
  • Leaves transparent Zcash recipients and Bitcoin paths without memo behavior.

Details

The memo is encoded through zcash_protocol::memo::Memo::from_str(...).encode() before being passed into add_orchard_output, matching the Zcash crate's canonical ZIP-302 text memo path. None still uses MemoBytes::empty(), and an empty string follows the crate's canonical empty memo encoding.

This PR also adapts memo propagation to the current upstream random UTXO selection code, so the selected inputs used for Orchard bundle construction remain the upstream selection.selected result.

Cargo.lock includes the local package version sync from the current upstream manifests (bridge-cli 0.3.52 and omni-connector 0.3.15). This was generated by cargo after rebasing onto the latest upstream base.

Relationship to JS PR

The JS companion PR adds the consumer-facing destinationMemo type and validates the 512-byte UTF-8 memo boundary before callers hand the value to the Rust-backed Zcash transfer flow.

Together, the two PRs make Zcash memo support available end-to-end while keeping existing BTC and shared BTC/Zcash paths unchanged.

CLI surface

Existing shared path remains unchanged and does not mention memo:

bridge-cli.exe testnet near-submit-btc-transfer --help
# no --memo option

New Zcash-specific paths expose memo explicitly:

bridge-cli.exe testnet near-submit-zcash-transfer --help
# -m, --memo <MEMO>

bridge-cli.exe testnet internal init-near-to-zcash-transfer --help
# -m, --memo <MEMO>

Validation

  • cargo fmt --check --manifest-path bridge-cli/Cargo.toml
  • cargo fmt --check --manifest-path bridge-sdk/connectors/omni-connector/Cargo.toml
  • cargo test --manifest-path bridge-sdk/connectors/omni-connector/Cargo.toml
  • cargo check --manifest-path bridge-cli/Cargo.toml
  • cargo build --release --manifest-path bridge-cli/Cargo.toml
  • Verified release CLI help output for:
    • near-submit-btc-transfer
    • near-submit-zcash-transfer
    • internal init-near-to-zcash-transfer

Notes

On this Windows checkout, the debug CLI binary currently stack-overflows while rendering clap help before any command runs. The release binary renders help successfully, and all compile/test checks above pass.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@tzarebczan tzarebczan force-pushed the feat/zcash-memo-support branch 2 times, most recently from 8b8aa3c to 1963078 Compare May 18, 2026 13:13
@tzarebczan tzarebczan force-pushed the feat/zcash-memo-support branch from 1963078 to 368de13 Compare May 20, 2026 13:04
@tzarebczan tzarebczan requested a review from a team as a code owner May 20, 2026 13:04
@tzarebczan tzarebczan force-pushed the feat/zcash-memo-support branch 2 times, most recently from deda850 to 94dbd05 Compare May 25, 2026 13:04
Comment thread bridge-cli/src/omni_connector_command.rs Outdated
@tzarebczan tzarebczan force-pushed the feat/zcash-memo-support branch from 94dbd05 to 1822228 Compare May 26, 2026 21:11
@frolvanya frolvanya requested a review from a team May 26, 2026 21:23
Comment thread bridge-sdk/connectors/omni-connector/src/zcash.rs Outdated
@tzarebczan

Copy link
Copy Markdown
Contributor Author

Looks like Near-One/bridge-sdk-js#470 was recently merged, would be great to get this in to go alongside it. Near-One/bridge-sdk-js#470

Once they are in, anyway I can track the downstream changes required for this to be fully possible via one click api, etc?

@frolvanya frolvanya left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good, thanks for the contribution!

@frolvanya frolvanya merged commit 9ea39e8 into Near-One:main May 29, 2026
6 checks passed
@tzarebczan

Copy link
Copy Markdown
Contributor Author

Awesome! Thank you for taking the time to review and consider 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.

2 participants