From 5a2f6595947c5f3b82ef2176667819e3dc5a5cdc Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Wed, 12 Oct 2022 16:46:09 -0600 Subject: [PATCH] Ensure that only purely wallet-internal tx are returned as internal. Co-authored-by: Jack Grigg --- zcash_client_sqlite/src/wallet/init.rs | 12 +++++------- .../wallet/init/migrations/add_transaction_views.rs | 12 +++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/zcash_client_sqlite/src/wallet/init.rs b/zcash_client_sqlite/src/wallet/init.rs index 855d08233..5a605a83b 100644 --- a/zcash_client_sqlite/src/wallet/init.rs +++ b/zcash_client_sqlite/src/wallet/init.rs @@ -454,7 +454,7 @@ mod tests { notes.raw, SUM(notes.value) + MAX(notes.fee) AS net_value, MAX(notes.fee) AS fee_paid, - SUM(notes.is_wallet_internal) > 0 AS is_wallet_internal, + SUM(notes.sent_count) == 0 AS is_wallet_internal, SUM(notes.is_change) > 0 AS has_change, SUM(notes.sent_count) AS sent_note_count, SUM(notes.received_count) AS received_note_count, @@ -472,7 +472,7 @@ mod tests { WHEN received_notes.is_change THEN 0 ELSE value END AS value, - 0 AS is_wallet_internal, + 0 AS sent_count, CASE WHEN received_notes.is_change THEN 1 ELSE 0 @@ -481,7 +481,6 @@ mod tests { WHEN received_notes.is_change THEN 0 ELSE 1 END AS received_count, - 0 AS sent_count, CASE WHEN received_notes.memo IS NULL THEN 0 ELSE 1 @@ -498,12 +497,11 @@ mod tests { transactions.fee AS fee, -sent_notes.value AS value, CASE - WHEN sent_notes.from_account = sent_notes.to_account THEN 1 - ELSE 0 - END AS is_wallet_internal, + WHEN sent_notes.from_account = sent_notes.to_account THEN 0 + ELSE 1 + END AS sent_count, 0 AS is_change, 0 AS received_count, - 1 AS sent_count, CASE WHEN sent_notes.memo IS NULL THEN 0 ELSE 1 diff --git a/zcash_client_sqlite/src/wallet/init/migrations/add_transaction_views.rs b/zcash_client_sqlite/src/wallet/init/migrations/add_transaction_views.rs index ec2a0911a..bdd76f83e 100644 --- a/zcash_client_sqlite/src/wallet/init/migrations/add_transaction_views.rs +++ b/zcash_client_sqlite/src/wallet/init/migrations/add_transaction_views.rs @@ -209,7 +209,7 @@ impl RusqliteMigration for Migration

{ notes.raw, SUM(notes.value) + MAX(notes.fee) AS net_value, MAX(notes.fee) AS fee_paid, - SUM(notes.is_wallet_internal) > 0 AS is_wallet_internal, + SUM(notes.sent_count) == 0 AS is_wallet_internal, SUM(notes.is_change) > 0 AS has_change, SUM(notes.sent_count) AS sent_note_count, SUM(notes.received_count) AS received_note_count, @@ -227,7 +227,7 @@ impl RusqliteMigration for Migration

{ WHEN received_notes.is_change THEN 0 ELSE value END AS value, - 0 AS is_wallet_internal, + 0 AS sent_count, CASE WHEN received_notes.is_change THEN 1 ELSE 0 @@ -236,7 +236,6 @@ impl RusqliteMigration for Migration

{ WHEN received_notes.is_change THEN 0 ELSE 1 END AS received_count, - 0 AS sent_count, CASE WHEN received_notes.memo IS NULL THEN 0 ELSE 1 @@ -253,12 +252,11 @@ impl RusqliteMigration for Migration

{ transactions.fee AS fee, -sent_notes.value AS value, CASE - WHEN sent_notes.from_account = sent_notes.to_account THEN 1 - ELSE 0 - END AS is_wallet_internal, + WHEN sent_notes.from_account = sent_notes.to_account THEN 0 + ELSE 1 + END AS sent_count, 0 AS is_change, 0 AS received_count, - 1 AS sent_count, CASE WHEN sent_notes.memo IS NULL THEN 0 ELSE 1