Open AArnott opened 6 months ago
v_tx_outputs
queries notes twice:
https://github.com/zcash/librustzcash/blob/3ccc14f501c569bc948735d6320b09ce89c1d57c/zcash_client_sqlite/src/wallet/init.rs#L957-L970
https://github.com/zcash/librustzcash/blob/3ccc14f501c569bc948735d6320b09ce89c1d57c/zcash_client_sqlite/src/wallet/init.rs#L983-L997
Both of these join v_received_notes
and sent_notes
, so there is immediate possibility of duplication of change notes (which are added to both tables). What is meant to prevent this is the WHERE COALESCE(v_received_notes.is_change, 0) = 0
which should exclude change notes selected via the sent_notes
table; there might be an Orchard bug here.
Additionally, for cross-account notes (outgoing from one, incoming from the other) that won't show up as change notes, there is no filtering. We're not addressing this for the current release series targeting Zashi 1.0 because that doesn't support multiple accounts; this should be fixed as part of #1305 or something similar.
My MainNet test account with UFVK:
Birthday height: 2,224,314
txid: 89299683638fc1d183a442683b217e86205d1f9a5c167e4eafab378a6f1bd5c9 block height: 2315025
In
v_tx_outputs
this transaction has 3 rows:Note how the first two rows claim to describe the same output, but one specifies the address and one doesn't. I believe this double representation of the same output is related to why
v_transactions
reports anaccount_balance_delta
value of-220000
for this transaction instead of the expected-110000
.