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 d061ca200..03bcee7b6 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 @@ -14,19 +14,17 @@ use zcash_primitives::{ use super::super::{WalletMigration2, WalletMigrationError}; -pub(super) struct Migration
{ - pub(super) params: P, +pub(crate) fn migration_id() -> Uuid { + Uuid::parse_str("282fad2e-8372-4ca0-8bed-71821320909f").unwrap() } -impl
Migration
{ - fn id() -> Uuid { - Uuid::parse_str("282fad2e-8372-4ca0-8bed-71821320909f").unwrap() - } +pub(crate) struct Migration
{ + pub(super) params: P, } impl
schemer::Migration for Migration
{ fn id(&self) -> Uuid { - Migration::
::id()
+ migration_id()
}
fn dependencies(&self) -> HashSet {
SUM(
CASE
WHEN sent_notes.memo IS NULL THEN 0
- WHEN SUBSTR(sent_notes.memo, 0, 2) = X'F6' THEN 0
+ WHEN sent_notes.memo = X'F600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' THEN 0
ELSE 1
END
) AS memo_count,
@@ -118,7 +116,7 @@ impl {
SUM(
CASE
WHEN received_notes.memo IS NULL THEN 0
- WHEN SUBSTR(received_notes.memo, 0, 2) = X'F6' THEN 0
+ WHEN received_notes.memo = X'F600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' THEN 0
ELSE 1
END
) AS memo_count,
@@ -154,7 +152,7 @@ impl {
received_notes.is_change AS is_change,
CASE
WHEN received_notes.memo IS NULL THEN 0
- WHEN SUBSTR(received_notes.memo, 0, 2) = X'F6' THEN 0
+ WHEN received_notes.memo = X'F600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' THEN 0
ELSE 1
END AS memo_present
FROM transactions
@@ -171,7 +169,7 @@ impl {
false AS is_change,
CASE
WHEN sent_notes.memo IS NULL THEN 0
- WHEN SUBSTR(sent_notes.memo, 0, 2) = X'F6' THEN 0
+ WHEN sent_notes.memo = X'F600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' THEN 0
ELSE 1
END AS memo_present
FROM transactions
@@ -192,15 +190,29 @@ impl {
#[cfg(test)]
mod tests {
use rusqlite::{self, NO_PARAMS};
-
use tempfile::NamedTempFile;
- use crate::{
- tests::{self},
- wallet::init::init_wallet_db,
- WalletDb,
+ #[cfg(feature = "transparent-inputs")]
+ use {
+ crate::wallet::init::{init_wallet_db_internal, WalletMigration2},
+ rusqlite::params,
+ zcash_client_backend::{encoding::AddressCodec, keys::UnifiedSpendingKey},
+ zcash_primitives::{
+ consensus::{BlockHeight, BranchId, Network},
+ legacy::{keys::IncomingViewingKey, Script},
+ transaction::{
+ components::{
+ transparent::{self, Authorized, OutPoint},
+ Amount, TxIn, TxOut,
+ },
+ TransactionData, TxVersion,
+ },
+ zip32::AccountId,
+ },
};
+ use crate::{tests, wallet::init::init_wallet_db, WalletDb};
+
#[test]
fn transaction_views() {
let data_file = NamedTempFile::new().unwrap();
@@ -217,7 +229,7 @@ mod tests {
INSERT INTO sent_notes (tx, output_pool, output_index, from_account, address, value, memo)
VALUES (0, 2, 1, 0, '', 3, X'61');
INSERT INTO sent_notes (tx, output_pool, output_index, from_account, address, value, memo)
- VALUES (0, 2, 2, 0, '', 0, X'f600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
+ VALUES (0, 2, 2, 0, '', 0, X'F600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000');
INSERT INTO received_notes (tx, output_index, account, diversifier, value, rcm, nf, is_change, memo)
VALUES (0, 0, 0, '', 5, '', 'a', false, X'62');
@@ -276,4 +288,91 @@ mod tests {
}
assert_eq!(row_count, 1);
}
+
+ #[test]
+ #[cfg(feature = "transparent-inputs")]
+ fn migrate_from_wm2() {
+ let data_file = NamedTempFile::new().unwrap();
+ let mut db_data = WalletDb::for_path(data_file.path(), tests::network()).unwrap();
+ init_wallet_db_internal(&mut db_data, None, Some(WalletMigration2::