Skip to content

Add transparent refund address for shielded Zcash Maya swaps#459

Open
j0ntz wants to merge 1 commit into
masterfrom
jon/zec-shielded-refund-address
Open

Add transparent refund address for shielded Zcash Maya swaps#459
j0ntz wants to merge 1 commit into
masterfrom
jon/zec-shielded-refund-address

Conversation

@j0ntz

@j0ntz j0ntz commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Description

Asana: https://app.asana.com/0/1215088146871429/1214541361005860

Problem. When Edge sends a shielded-Zcash swap to Maya, the swap memo carries no refund address. Maya cannot refund a shielded source and rejects the refund:

can't refund ZEC from shielded source without a refund address
fail to refund for halted trading

For every chain except Zcash, Maya defaults the refund to the sending address, which is correct. A shielded ZEC source has no transparent sending address to refund to, so the integrator must supply a transparent (t-address) refund address in the swap memo.

Fix. In the shared Thorchain/Maya common code, when the source wallet is Zcash, fetch the wallet's transparent address (getAddress(fromWallet, 'transparentAddress'), the same helper already used for the ZEC receive side) and pass it as refund_address to the quote/swap endpoint. The node bakes it into the swap memo's destination field per the Maya memo spec (SWAP:ASSET:DESTADDR/REFUNDADDR:...). For ZEC the memo then flows into the existing ZIP-321 shielded-memo path unchanged. Non-Zcash sources are untouched and keep defaulting to the sending address (refund_address is only added when present, so their quote requests are byte-for-byte identical).

The change lives entirely in the dependency; no gui-side wiring is required.

Verification.

  • tsc --noEmit, eslint, and yarn test all pass.
  • Verified the mechanism directly against the live Maya node (mayanode.mayachain.info): the same quote/swap request returns memo =:e:0x04c5... without refund_address and =:e:0x04c5.../bc1q... with it, confirming the node appends the refund address to the destination field exactly as this change relies on.
  • In-app ZEC to asset swap-to-success could not be driven on the sim: Maya ZEC trading is currently halted (trading is halted, can't process swap) at the protocol level, so no ZEC quote/swap can be produced regardless of wallet funding. Re-run the in-app smoke once Maya resumes ZEC trading.

Note

Medium Risk
Changes Maya/Thorchain ZEC swap memo construction and refund routing; mistakes could misdirect refunds, but the change is narrowly scoped to ZEC sources and post-quote memo mutation only.

Overview
Shielded Zcash → Maya swaps now carry a transparent t-address refund in the swap memo so Maya can refund when the source is shielded (it cannot default to the sender like other chains).

For ZEC source wallets, the plugin loads transparentAddress via the same getAddress helper used elsewhere. The refund is not sent on quote/swap—that would blow past Zcash’s 80-character transparent-memo limit and fail quoting. After the quote returns, the ZEC / ZIP-321 path rewrites memo field 3 from DESTADDR to DESTADDR/REFUNDADDR before the memo is encoded into the shielded note (which is not subject to that limit). Non-ZEC swaps are unchanged.

CHANGELOG documents the Maya behavior under Unreleased.

Reviewed by Cursor Bugbot for commit dfd5a7a. Bugbot is set up for automated code reviews on this repo. Configure here.

@j0ntz

j0ntz commented Jun 13, 2026

Copy link
Copy Markdown
Contributor Author

📸 Test evidence — in-app Maya shielded-ZEC swap order (verification followup)

agent proof 1214541361005860 02 maya zec order

agent proof 1214541361005860 02 maya zec order

Captured by the agent's in-app test run (build-and-test).

@j0ntz j0ntz force-pushed the jon/zec-shielded-refund-address branch 2 times, most recently from d550dc3 to 67bbce0 Compare June 16, 2026 01:08

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 67bbce0. Configure here.

Comment thread src/swap/defi/thorchain/thorchainCommon.ts
Maya cannot refund a shielded Zcash source and rejects the refund with
"can't refund ZEC from shielded source without a refund address". Add the
wallet's transparent (t-address) refund address to the Maya swap memo as
DESTADDR/REFUNDADDR so Maya can process refunds.

The refund is injected into the memo client-side rather than passed to the
quote endpoint. Appending it to the quote request overflows Zcash's 80-char
transparent-memo limit and the quote endpoint rejects the swap. The ZEC swap
carries its memo in the shielded note, which is not bound by that limit, so
the refund is added after the quote is fetched. Non-Zcash sources are
unchanged and continue to default to the sending address.
@j0ntz j0ntz force-pushed the jon/zec-shielded-refund-address branch from 67bbce0 to dfd5a7a Compare June 16, 2026 01:17
@j0ntz

j0ntz commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

📸 Test evidence (in-app, after fix)

agent proof 1214541361005860 04 zec dash fixed order

agent proof 1214541361005860 04 zec dash fixed order

agent proof 1214541361005860 05 zec dash swap success

agent proof 1214541361005860 05 zec dash swap success

agent proof 1214541361005860 06 btc eth unaffected order

agent proof 1214541361005860 06 btc eth unaffected order

Captured by the agent's in-app test run (build-and-test).

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