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.)
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:
vpub_new
and subtractvpub_old
.valueBalanceSapling
.valueBalanceOrchard
.That is, a negative
valueBalanceSapling
orvalueBalanceOutput
, or a nonzero value in anyvpub_old
, represents a net transfer into the corresponding shielded pool, and is treated like an output of that magnitude when calculating the fee. A positivevalueBalanceSapling
orvalueBalanceOutput
, or a nonzero value in anyvpub_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.)