Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Zcash] [Bug] Fees are incorrect for transactions with shielded components #1160

Open
daira opened this issue Nov 25, 2024 · 0 comments
Open

Comments

@daira
Copy link

daira commented Nov 25, 2024

This explorer is calculating fees incorrectly for Zcash transactions with shielded components.

Example: https://zecblockexplorer.com/tx/63679fc7f9628bc5065636813ee6adbe89f6dfdf3635524ac0792b344a9fd588 shows a fee of 72.56179835 ZEC. In fact this is a shielding transaction which transfers 72.56024835 ZEC to the shielded pool. The remaining 72.56179835 - 72.56024835 = 0.00155 ZEC is the fee.

That transaction is shown correctly by other block explorers at https://mainnet.zcashexplorer.app/transactions/63679fc7f9628bc5065636813ee6adbe89f6dfdf3635524ac0792b344a9fd588 and https://3xpl.com/zcash/transaction/63679fc7f9628bc5065636813ee6adbe89f6dfdf3635524ac0792b344a9fd588 .

In order to calculate the fee correctly in all cases:

  • for each JoinSplit description, add vpub_new and subtract vpub_old.
  • add valueBalanceSapling.
  • add valueBalanceOrchard.

That is, a negative valueBalanceSapling or valueBalanceOutput, or a nonzero value in any vpub_old, represents a net transfer into the corresponding shielded pool, and is treated like an output of that magnitude when calculating the fee. A positive valueBalanceSapling or valueBalanceOutput, or a nonzero value in any vpub_new, represents a net transfer out of the corresponding shielded pool, and is treated like an input of that magnitude when calculating the fee.

(The transaction given as an example is a v4 transaction that only involves Sapling. I can give other examples that involve the Sprout and Orchard pools if needed.)

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

No branches or pull requests

1 participant