zcash_client_sqlite: Fix bug in `utxos_to_txos` migration
zcash/librustzcash@72d8df8e68 altered the `v_received_notes` view to include transparent coins (renaming it to `v_received_outputs`), and updated `v_transactions` to not separately query transparent coins. The latter queried `v_received_notes` twice, once to fetch notes received in a transaction, and again to fetch notes spent in a transaction. The spent notes were obtained by joining on the junction table `v_received_note_spends` to get the spent-in transaction's ID. The commit retained the junction table join, but didn't use it due to a typo, leading to notes being "spent-in" the transaction they were received in. This bug had several effects: - `account_balance_delta` showed `+change` for transactions in which a change note was received that had not yet been spent. - `account_balance_delta` showed `0` for transactions in which all received notes had been subsequently spent. - Transactions that spent funds with no change were omitted.
This commit is contained in:
parent
e29622e972
commit
1a562fb208
|
@ -700,7 +700,7 @@ notes AS (
|
|||
ON ros.pool = ro.pool
|
||||
AND ros.received_output_id = ro.id_within_pool_table
|
||||
JOIN transactions
|
||||
ON transactions.id_tx = ro.transaction_id
|
||||
ON transactions.id_tx = ros.transaction_id
|
||||
),
|
||||
-- Obtain a count of the notes that the wallet created in each transaction,
|
||||
-- not counting change notes.
|
||||
|
|
|
@ -229,7 +229,7 @@ impl RusqliteMigration for Migration {
|
|||
ON ros.pool = ro.pool
|
||||
AND ros.received_output_id = ro.id_within_pool_table
|
||||
JOIN transactions
|
||||
ON transactions.id_tx = ro.transaction_id
|
||||
ON transactions.id_tx = ros.transaction_id
|
||||
),
|
||||
-- Obtain a count of the notes that the wallet created in each transaction,
|
||||
-- not counting change notes.
|
||||
|
|
Loading…
Reference in New Issue