From 000d939a2c8fcb1d0fa229acb2ca3c21dfa037e3 Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Wed, 3 Aug 2022 12:36:25 +0100 Subject: [PATCH 01/23] clear pending coinbase transactions now rely on utxo hashes --- base_layer/core/src/transactions/coinbase_builder.rs | 2 +- .../wallet/src/output_manager_service/service.rs | 4 ++-- .../output_manager_service/storage/database/backend.rs | 4 ++-- .../src/output_manager_service/storage/database/mod.rs | 6 +++--- .../output_manager_service/storage/sqlite_db/mod.rs | 8 ++++---- .../storage/sqlite_db/output_sql.rs | 10 ++++++++++ 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/base_layer/core/src/transactions/coinbase_builder.rs b/base_layer/core/src/transactions/coinbase_builder.rs index 6363831374..ecdce58e26 100644 --- a/base_layer/core/src/transactions/coinbase_builder.rs +++ b/base_layer/core/src/transactions/coinbase_builder.rs @@ -203,7 +203,7 @@ impl CoinbaseBuilder { let sig = Signature::sign(spending_key.clone(), nonce, &challenge) .map_err(|_| CoinbaseBuildError::BuildError("Challenge could not be represented as a scalar".into()))?; - let sender_offset_private_key = PrivateKey::random(&mut OsRng); + let sender_offset_private_key = PrivateKey::from_bytes(Blake256::digest(spending_key)); // H(spending_key) <- Blake256 let sender_offset_public_key = PublicKey::from_secret_key(&sender_offset_private_key); let covenant = self.covenant; diff --git a/base_layer/wallet/src/output_manager_service/service.rs b/base_layer/wallet/src/output_manager_service/service.rs index cc16d39468..c50c7da0aa 100644 --- a/base_layer/wallet/src/output_manager_service/service.rs +++ b/base_layer/wallet/src/output_manager_service/service.rs @@ -1012,12 +1012,12 @@ where match self .resources .db - .clear_pending_coinbase_transaction_at_block_height(block_height) + .clear_pending_coinbase_transaction_with_hash(output.hash.as_slice()) { Ok(_) => { debug!( target: LOG_TARGET, - "An existing pending coinbase was cleared for block height {}", block_height + "An existing pending coinbase was cleared with hash {}", output.hash.to_hex() ) }, Err(e) => match e { diff --git a/base_layer/wallet/src/output_manager_service/storage/database/backend.rs b/base_layer/wallet/src/output_manager_service/storage/database/backend.rs index 4527e1b561..e3a7cad923 100644 --- a/base_layer/wallet/src/output_manager_service/storage/database/backend.rs +++ b/base_layer/wallet/src/output_manager_service/storage/database/backend.rs @@ -97,9 +97,9 @@ pub trait OutputManagerBackend: Send + Sync + Clone { /// Get the output that was most recently spent, ordered descending by mined height fn get_last_spent_output(&self) -> Result, OutputManagerStorageError>; /// Check if there is a pending coinbase transaction at this block height, if there is clear it. - fn clear_pending_coinbase_transaction_at_block_height( + fn clear_pending_coinbase_transaction_with_hash( &self, - block_height: u64, + hash: &[u8], ) -> Result<(), OutputManagerStorageError>; /// Set if a coinbase output is abandoned or not fn set_coinbase_abandoned(&self, tx_id: TxId, abandoned: bool) -> Result<(), OutputManagerStorageError>; diff --git a/base_layer/wallet/src/output_manager_service/storage/database/mod.rs b/base_layer/wallet/src/output_manager_service/storage/database/mod.rs index 91c15e1bbb..d5af1bcbae 100644 --- a/base_layer/wallet/src/output_manager_service/storage/database/mod.rs +++ b/base_layer/wallet/src/output_manager_service/storage/database/mod.rs @@ -220,11 +220,11 @@ where T: OutputManagerBackend + 'static } /// Check if there is a pending coinbase transaction at this block height, if there is clear it. - pub fn clear_pending_coinbase_transaction_at_block_height( + pub fn clear_pending_coinbase_transaction_with_hash( &self, - block_height: u64, + hash: &[u8], ) -> Result<(), OutputManagerStorageError> { - self.db.clear_pending_coinbase_transaction_at_block_height(block_height) + self.db.clear_pending_coinbase_transaction_with_hash(hash) } pub fn fetch_all_unspent_outputs(&self) -> Result, OutputManagerStorageError> { diff --git a/base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs b/base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs index 09fdafe15d..f2d0a21e03 100644 --- a/base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs +++ b/base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs @@ -1074,21 +1074,21 @@ impl OutputManagerBackend for OutputManagerSqliteDatabase { Ok(()) } - fn clear_pending_coinbase_transaction_at_block_height( + fn clear_pending_coinbase_transaction_with_hash( &self, - block_height: u64, + hash: &[u8], ) -> Result<(), OutputManagerStorageError> { let start = Instant::now(); let conn = self.database_connection.get_pooled_connection()?; let acquire_lock = start.elapsed(); - let output = OutputSql::find_pending_coinbase_at_block_height(block_height, &conn)?; + let output = OutputSql::find_pending_coinbase_with_hash(hash, &conn)?; output.delete(&conn)?; if start.elapsed().as_millis() > 0 { trace!( target: LOG_TARGET, - "sqlite profile - clear_pending_coinbase_transaction_at_block_height: lock {} + db_op {} = {} ms", + "sqlite profile - clear_pending_coinbase_transaction_with_hash: lock {} + db_op {} = {} ms", acquire_lock.as_millis(), (start.elapsed() - acquire_lock).as_millis(), start.elapsed().as_millis() diff --git a/base_layer/wallet/src/output_manager_service/storage/sqlite_db/output_sql.rs b/base_layer/wallet/src/output_manager_service/storage/sqlite_db/output_sql.rs index 63480ee86c..804681ab59 100644 --- a/base_layer/wallet/src/output_manager_service/storage/sqlite_db/output_sql.rs +++ b/base_layer/wallet/src/output_manager_service/storage/sqlite_db/output_sql.rs @@ -576,6 +576,16 @@ impl OutputSql { .first::(conn)?) } + pub fn find_pending_coinbase_with_hash( + hash: &[u8], + conn: &SqliteConnection, + ) -> Result { + Ok(outputs::table + .filter(outputs::status.ne(OutputStatus::Unspent as i32)) + .filter(outputs::hash.eq(Some(hash))) + .first::(conn)?) + } + /// Find a particular Output, if it exists and is in the specified Spent state pub fn find_pending_coinbase_at_block_height( block_height: u64, From a84ec421ea75fb7c3dd50193ca192a698acc876b Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 8 Aug 2022 09:47:32 +0100 Subject: [PATCH 02/23] add initial migration --- .../2019-06-26-130555_initial/down.sql | 3 - .../2019-06-26-130555_initial/up.sql | 25 ------ .../down.sql | 16 ---- .../up.sql | 22 ----- .../down.sql | 4 - .../up.sql | 37 -------- .../2019-11-26-105357_contacts/down.sql | 1 - .../2019-11-26-105357_contacts/up.sql | 4 - .../2019-11-26-120903_peers/down.sql | 1 - .../migrations/2019-11-26-120903_peers/up.sql | 4 - .../down.sql | 12 --- .../up.sql | 13 --- .../down.sql | 6 -- .../up.sql | 1 - .../down.sql | 5 -- .../up.sql | 5 -- .../down.sql | 2 - .../up.sql | 2 - .../down.sql | 1 - .../up.sql | 4 - .../down.sql | 2 - .../up.sql | 2 - .../down.sql | 17 ---- .../up.sql | 19 ---- .../down.sql | 4 - .../up.sql | 1 - .../down.sql | 66 -------------- .../up.sql | 23 ----- .../down.sql | 90 ------------------- .../up.sql | 14 --- .../down.sql | 1 - .../down.sql | 37 -------- .../up.sql | 2 - .../down.sql | 19 ---- .../up.sql | 20 ----- .../down.sql | 1 - .../up.sql | 23 ----- .../down.sql | 39 -------- .../up.sql | 2 - .../down.sql | 41 --------- .../up.sql | 2 - .../2021-04-29-125155_known_scripts/down.sql | 1 - .../2021-04-29-125155_known_scripts/up.sql | 6 -- .../down.sql | 1 - .../up.sql | 25 ------ .../down.sql | 45 ---------- .../up.sql | 43 --------- .../down.sql | 1 - .../up.sql | 25 ------ .../down.sql | 1 - .../up.sql | 33 ------- .../down.sql | 0 .../up.sql | 32 ------- .../down.sql | 1 - .../up.sql | 66 -------------- .../down.sql | 1 - .../up.sql | 5 -- .../2021-10-13-121212_add_unique_id/down.sql | 0 .../2021-10-13-121212_add_unique_id/up.sql | 5 -- .../down.sql | 2 - .../up.sql | 2 - .../down.sql | 48 ---------- .../up.sql | 5 -- .../down.sql | 0 .../up.sql | 31 ------- .../down.sql | 0 .../up.sql | 25 ------ .../down.sql | 1 - .../up.sql | 7 -- .../down.sql | 2 - .../up.sql | 3 - .../down.sql | 1 - .../up.sql | 60 ------------- .../down.sql | 1 - .../up.sql | 32 ------- .../down.sql | 1 - .../up.sql | 12 --- .../down.sql | 1 - .../up.sql | 58 ------------ .../down.sql | 1 - .../up.sql | 47 ---------- .../down.sql | 2 - .../2022-06-22-133735_add_contract_id/up.sql | 4 - .../down.sql | 2 - .../up.sql | 2 - .../up.sql | 5 -- .../down.sql | 1 - .../up.sql | 0 .../down.sql | 1 - .../up.sql | 2 - .../up.sql | 4 +- 91 files changed, 2 insertions(+), 1245 deletions(-) delete mode 100644 base_layer/wallet/migrations/2019-06-26-130555_initial/down.sql delete mode 100644 base_layer/wallet/migrations/2019-06-26-130555_initial/up.sql delete mode 100644 base_layer/wallet/migrations/2019-10-30-084148_output_manager_service/down.sql delete mode 100644 base_layer/wallet/migrations/2019-10-30-084148_output_manager_service/up.sql delete mode 100644 base_layer/wallet/migrations/2019-11-20-090620_transaction_service/down.sql delete mode 100644 base_layer/wallet/migrations/2019-11-20-090620_transaction_service/up.sql delete mode 100644 base_layer/wallet/migrations/2019-11-26-105357_contacts/down.sql delete mode 100644 base_layer/wallet/migrations/2019-11-26-105357_contacts/up.sql delete mode 100644 base_layer/wallet/migrations/2019-11-26-120903_peers/down.sql delete mode 100644 base_layer/wallet/migrations/2019-11-26-120903_peers/up.sql delete mode 100644 base_layer/wallet/migrations/2020-05-05-122254_add_canceled_flag/down.sql delete mode 100644 base_layer/wallet/migrations/2020-05-05-122254_add_canceled_flag/up.sql delete mode 100644 base_layer/wallet/migrations/2020-05-11-124646_remove_coinbase_table/down.sql delete mode 100644 base_layer/wallet/migrations/2020-05-11-124646_remove_coinbase_table/up.sql delete mode 100644 base_layer/wallet/migrations/2020-05-12-142154_add_direct_send_success_column_to_pending_tx/down.sql delete mode 100644 base_layer/wallet/migrations/2020-05-12-142154_add_direct_send_success_column_to_pending_tx/up.sql delete mode 100644 base_layer/wallet/migrations/2020-05-21-170850_add_hash_to_outputs/down.sql delete mode 100644 base_layer/wallet/migrations/2020-05-21-170850_add_hash_to_outputs/up.sql delete mode 100644 base_layer/wallet/migrations/2020-06-15-084821_add_wallet_settings/down.sql delete mode 100644 base_layer/wallet/migrations/2020-06-15-084821_add_wallet_settings/up.sql delete mode 100644 base_layer/wallet/migrations/2020-06-23-135346_add_completed_transaction_direction/down.sql delete mode 100644 base_layer/wallet/migrations/2020-06-23-135346_add_completed_transaction_direction/up.sql delete mode 100644 base_layer/wallet/migrations/2020-06-29-130334_add_id_primary_key_to_outputs/down.sql delete mode 100644 base_layer/wallet/migrations/2020-06-29-130334_add_id_primary_key_to_outputs/up.sql delete mode 100644 base_layer/wallet/migrations/2020-07-08-083612_remove_peer_table/down.sql delete mode 100644 base_layer/wallet/migrations/2020-07-08-083612_remove_peer_table/up.sql delete mode 100644 base_layer/wallet/migrations/2020-07-20-084915_add_coinbase_handling/down.sql delete mode 100644 base_layer/wallet/migrations/2020-07-20-084915_add_coinbase_handling/up.sql delete mode 100644 base_layer/wallet/migrations/2020-08-17-141407_add_resend_count_and_timestamp_add_status_to_pending_txs/down.sql delete mode 100644 base_layer/wallet/migrations/2020-08-17-141407_add_resend_count_and_timestamp_add_status_to_pending_txs/up.sql delete mode 100644 base_layer/wallet/migrations/2020-10-20-094420_add_client_key_value_store/down.sql delete mode 100644 base_layer/wallet/migrations/2021-02-03-074953_add_valid_flag_to_transaction/down.sql delete mode 100644 base_layer/wallet/migrations/2021-02-03-074953_add_valid_flag_to_transaction/up.sql delete mode 100644 base_layer/wallet/migrations/2021-02-15-084900_add_outputs_unique_commitment/down.sql delete mode 100644 base_layer/wallet/migrations/2021-02-15-084900_add_outputs_unique_commitment/up.sql delete mode 100644 base_layer/wallet/migrations/2021-03-23-082938_update-outputs-for-tari-script/down.sql delete mode 100644 base_layer/wallet/migrations/2021-03-23-082938_update-outputs-for-tari-script/up.sql delete mode 100644 base_layer/wallet/migrations/2021-04-01-081220_add_transaction_confirmations/down.sql delete mode 100644 base_layer/wallet/migrations/2021-04-01-081220_add_transaction_confirmations/up.sql delete mode 100644 base_layer/wallet/migrations/2021-04-19-085137_add_mined_height_to_completed_transaction/down.sql delete mode 100644 base_layer/wallet/migrations/2021-04-19-085137_add_mined_height_to_completed_transaction/up.sql delete mode 100644 base_layer/wallet/migrations/2021-04-29-125155_known_scripts/down.sql delete mode 100644 base_layer/wallet/migrations/2021-04-29-125155_known_scripts/up.sql delete mode 100644 base_layer/wallet/migrations/2021-06-22-143855_sender_meta_signature/down.sql delete mode 100644 base_layer/wallet/migrations/2021-06-22-143855_sender_meta_signature/up.sql delete mode 100644 base_layer/wallet/migrations/2021-07-02-090239_remove_height_from_output/down.sql delete mode 100644 base_layer/wallet/migrations/2021-07-02-090239_remove_height_from_output/up.sql delete mode 100644 base_layer/wallet/migrations/2021-07-05-13201407_metadata_signature/down.sql delete mode 100644 base_layer/wallet/migrations/2021-07-05-13201407_metadata_signature/up.sql delete mode 100644 base_layer/wallet/migrations/2021-07-28-120000_add_mined_in_block/down.sql delete mode 100644 base_layer/wallet/migrations/2021-07-28-120000_add_mined_in_block/up.sql delete mode 100644 base_layer/wallet/migrations/2021-08-03-123456_update_outputs_mined/down.sql delete mode 100644 base_layer/wallet/migrations/2021-08-03-123456_update_outputs_mined/up.sql delete mode 100644 base_layer/wallet/migrations/2021-09-07-145830_remove_pending_transactions_table_and_tx_id_in_outputs/down.sql delete mode 100644 base_layer/wallet/migrations/2021-09-07-145830_remove_pending_transactions_table_and_tx_id_in_outputs/up.sql delete mode 100644 base_layer/wallet/migrations/2021-10-01-053552_clear_mined_height/down.sql delete mode 100644 base_layer/wallet/migrations/2021-10-01-053552_clear_mined_height/up.sql delete mode 100644 base_layer/wallet/migrations/2021-10-13-121212_add_unique_id/down.sql delete mode 100644 base_layer/wallet/migrations/2021-10-13-121212_add_unique_id/up.sql delete mode 100644 base_layer/wallet/migrations/2021-10-27-103505_update_key_manager_state/down.sql delete mode 100644 base_layer/wallet/migrations/2021-10-27-103505_update_key_manager_state/up.sql delete mode 100644 base_layer/wallet/migrations/2021-10-28-164318_add_transaction_signature/down.sql delete mode 100644 base_layer/wallet/migrations/2021-10-28-164318_add_transaction_signature/up.sql delete mode 100644 base_layer/wallet/migrations/2021-11-11-094000_add_script_lock_height/down.sql delete mode 100644 base_layer/wallet/migrations/2021-11-11-094000_add_script_lock_height/up.sql delete mode 100644 base_layer/wallet/migrations/2021-11-15-101010_add_template_features/down.sql delete mode 100644 base_layer/wallet/migrations/2021-11-15-101010_add_template_features/up.sql delete mode 100644 base_layer/wallet/migrations/2021-12-06-104545_add_block_scanned_cache/down.sql delete mode 100644 base_layer/wallet/migrations/2021-12-06-104545_add_block_scanned_cache/up.sql delete mode 100644 base_layer/wallet/migrations/2022-01-04-110518_add_covenant_to_output/down.sql delete mode 100644 base_layer/wallet/migrations/2022-01-04-110518_add_covenant_to_output/up.sql delete mode 100644 base_layer/wallet/migrations/2022-02-14-104456_cancellation_column_update/down.sql delete mode 100644 base_layer/wallet/migrations/2022-02-14-104456_cancellation_column_update/up.sql delete mode 100644 base_layer/wallet/migrations/2022-02-16-110518_add_last_seen_to_contacts/down.sql delete mode 100644 base_layer/wallet/migrations/2022-02-16-110518_add_last_seen_to_contacts/up.sql delete mode 100644 base_layer/wallet/migrations/2022-02-28-141501_key_manager_unique_index/down.sql delete mode 100644 base_layer/wallet/migrations/2022-02-28-141501_key_manager_unique_index/up.sql delete mode 100644 base_layer/wallet/migrations/2022-03-03-084134_add_recovery_byte/down.sql delete mode 100644 base_layer/wallet/migrations/2022-03-03-084134_add_recovery_byte/up.sql delete mode 100644 base_layer/wallet/migrations/2022-05-25-154612_add_encrypted_value/down.sql delete mode 100644 base_layer/wallet/migrations/2022-05-25-154612_add_encrypted_value/up.sql delete mode 100644 base_layer/wallet/migrations/2022-06-22-133735_add_contract_id/down.sql delete mode 100644 base_layer/wallet/migrations/2022-06-22-133735_add_contract_id/up.sql delete mode 100644 base_layer/wallet/migrations/2022-06-22-153811_rename_flags_to_output_type/down.sql delete mode 100644 base_layer/wallet/migrations/2022-06-22-153811_rename_flags_to_output_type/up.sql delete mode 100644 base_layer/wallet/migrations/2022-07-04-150000_add_mined_timestamp/up.sql delete mode 100644 base_layer/wallet/migrations/2022-07-11-142351_remove_recovery_byte/down.sql delete mode 100644 base_layer/wallet/migrations/2022-07-11-142351_remove_recovery_byte/up.sql delete mode 100644 base_layer/wallet/migrations/2022-07-15-214144_add_minimum_value_promise/down.sql delete mode 100644 base_layer/wallet/migrations/2022-07-15-214144_add_minimum_value_promise/up.sql rename base_layer/wallet/migrations/{2020-10-20-094420_add_client_key_value_store => 2022-08-08_initial}/up.sql (64%) diff --git a/base_layer/wallet/migrations/2019-06-26-130555_initial/down.sql b/base_layer/wallet/migrations/2019-06-26-130555_initial/down.sql deleted file mode 100644 index 1957bf7527..0000000000 --- a/base_layer/wallet/migrations/2019-06-26-130555_initial/down.sql +++ /dev/null @@ -1,3 +0,0 @@ --- DROP TABLE IF EXISTS sent_messages; --- DROP TABLE IF EXISTS received_messages; --- DROP TABLE IF EXISTS settings; \ No newline at end of file diff --git a/base_layer/wallet/migrations/2019-06-26-130555_initial/up.sql b/base_layer/wallet/migrations/2019-06-26-130555_initial/up.sql deleted file mode 100644 index 45915fb256..0000000000 --- a/base_layer/wallet/migrations/2019-06-26-130555_initial/up.sql +++ /dev/null @@ -1,25 +0,0 @@ --- CREATE TABLE sent_messages ( --- id TEXT PRIMARY KEY NOT NULL, --- source_pub_key TEXT NOT NULL, --- dest_pub_key TEXT NOT NULL, --- message TEXT NOT NULL, --- timestamp DATETIME NOT NULL, --- acknowledged INTEGER NOT NULL DEFAULT 0, --- is_read INTEGER NOT NULL DEFAULT 0, --- FOREIGN KEY(dest_pub_key) REFERENCES contacts(pub_key) --- ); - --- CREATE TABLE received_messages ( --- id BLOB PRIMARY KEY NOT NULL, --- source_pub_key TEXT NOT NULL, --- dest_pub_key TEXT NOT NULL, --- message TEXT NOT NULL, --- timestamp DATETIME NOT NULL --- ); - --- CREATE TABLE settings ( --- pub_key TEXT PRIMARY KEY NOT NULL, --- screen_name TEXT NOT NULL --- ) - - diff --git a/base_layer/wallet/migrations/2019-10-30-084148_output_manager_service/down.sql b/base_layer/wallet/migrations/2019-10-30-084148_output_manager_service/down.sql deleted file mode 100644 index c1938c169c..0000000000 --- a/base_layer/wallet/migrations/2019-10-30-084148_output_manager_service/down.sql +++ /dev/null @@ -1,16 +0,0 @@ --- Rename the master_key column to master_seed -PRAGMA foreign_keys=OFF; -ALTER TABLE key_manager_states - RENAME TO key_manager_states_old; -CREATE TABLE key_manager_states ( - id INTEGER PRIMARY KEY, - master_seed BLOB NOT NULL, - branch_seed TEXT NOT NULL, - primary_key_index INTEGER NOT NULL, - timestamp DATETIME NOT NULL -); -INSERT INTO key_manager_states (id, master_seed, branch_seed, primary_key_index, timestamp) -SELECT id, master_key, branch_seed, primary_key_index, timestamp -FROM key_manager_states_old; -DROP TABLE key_manager_states_old; -PRAGMA foreign_keys=ON; diff --git a/base_layer/wallet/migrations/2019-10-30-084148_output_manager_service/up.sql b/base_layer/wallet/migrations/2019-10-30-084148_output_manager_service/up.sql deleted file mode 100644 index 50e7955fe6..0000000000 --- a/base_layer/wallet/migrations/2019-10-30-084148_output_manager_service/up.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE TABLE outputs ( - spending_key BLOB PRIMARY KEY NOT NULL, - value INTEGER NOT NULL, - flags INTEGER NOT NULL, - maturity INTEGER NOT NULL, - status INTEGER NOT NULL, - tx_id INTEGER NULL -); - -CREATE TABLE pending_transaction_outputs ( - tx_id BIGINT PRIMARY KEY NOT NULL, - short_term INTEGER NOT NULL, - timestamp DATETIME NOT NULL -); - -CREATE TABLE key_manager_states ( - id INTEGER PRIMARY KEY, - master_seed BLOB NOT NULL, - branch_seed TEXT NOT NULL, - primary_key_index INTEGER NOT NULL, - timestamp DATETIME NOT NULL -); diff --git a/base_layer/wallet/migrations/2019-11-20-090620_transaction_service/down.sql b/base_layer/wallet/migrations/2019-11-20-090620_transaction_service/down.sql deleted file mode 100644 index ede4f8ef76..0000000000 --- a/base_layer/wallet/migrations/2019-11-20-090620_transaction_service/down.sql +++ /dev/null @@ -1,4 +0,0 @@ -DROP TABLE IF EXISTS pending_outbound_transactions; -DROP TABLE IF EXISTS pending_inbound_transactions; -DROP TABLE IF EXISTS pending_coinbase_transactions; -DROP TABLE IF EXISTS completed_transactions; \ No newline at end of file diff --git a/base_layer/wallet/migrations/2019-11-20-090620_transaction_service/up.sql b/base_layer/wallet/migrations/2019-11-20-090620_transaction_service/up.sql deleted file mode 100644 index d275563e06..0000000000 --- a/base_layer/wallet/migrations/2019-11-20-090620_transaction_service/up.sql +++ /dev/null @@ -1,37 +0,0 @@ -CREATE TABLE outbound_transactions ( - tx_id BIGINT PRIMARY KEY NOT NULL, - destination_public_key BLOB NOT NULL, - amount BIGINT NOT NULL, - fee BIGINT NOT NULL, - sender_protocol TEXT NOT NULL, - message TEXT NOT NULL, - timestamp DATETIME NOT NULL -); - -CREATE TABLE inbound_transactions ( - tx_id BIGINT PRIMARY KEY NOT NULL, - source_public_key BLOB NOT NULL, - amount BIGINT NOT NULL, - receiver_protocol TEXT NOT NULL, - message TEXT NOT NULL, - timestamp DATETIME NOT NULL -); - -CREATE TABLE coinbase_transactions ( - tx_id BIGINT PRIMARY KEY NOT NULL, - amount BIGINT NOT NULL, - commitment BLOB NOT NULL, - timestamp DATETIME NOT NULL -); - -CREATE TABLE completed_transactions ( - tx_id BIGINT PRIMARY KEY NOT NULL, - source_public_key BLOB NOT NULL, - destination_public_key BLOB NOT NULL, - amount BIGINT NOT NULL, - fee BIGINT NOT NULL, - transaction_protocol TEXT NOT NULL, - status INTEGER NOT NULL, - message TEXT NOT NULL, - timestamp DATETIME NOT NULL -); diff --git a/base_layer/wallet/migrations/2019-11-26-105357_contacts/down.sql b/base_layer/wallet/migrations/2019-11-26-105357_contacts/down.sql deleted file mode 100644 index 8a6ab255e9..0000000000 --- a/base_layer/wallet/migrations/2019-11-26-105357_contacts/down.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS contacts; diff --git a/base_layer/wallet/migrations/2019-11-26-105357_contacts/up.sql b/base_layer/wallet/migrations/2019-11-26-105357_contacts/up.sql deleted file mode 100644 index 214289670a..0000000000 --- a/base_layer/wallet/migrations/2019-11-26-105357_contacts/up.sql +++ /dev/null @@ -1,4 +0,0 @@ -CREATE TABLE contacts ( - public_key BLOB PRIMARY KEY NOT NULL UNIQUE, - alias TEXT NOT NULL -); diff --git a/base_layer/wallet/migrations/2019-11-26-120903_peers/down.sql b/base_layer/wallet/migrations/2019-11-26-120903_peers/down.sql deleted file mode 100644 index f4ce4b526e..0000000000 --- a/base_layer/wallet/migrations/2019-11-26-120903_peers/down.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS peers; \ No newline at end of file diff --git a/base_layer/wallet/migrations/2019-11-26-120903_peers/up.sql b/base_layer/wallet/migrations/2019-11-26-120903_peers/up.sql deleted file mode 100644 index 17a0212dd4..0000000000 --- a/base_layer/wallet/migrations/2019-11-26-120903_peers/up.sql +++ /dev/null @@ -1,4 +0,0 @@ -CREATE TABLE peers ( - public_key BLOB PRIMARY KEY NOT NULL UNIQUE, - peer TEXT NOT NULL -); diff --git a/base_layer/wallet/migrations/2020-05-05-122254_add_canceled_flag/down.sql b/base_layer/wallet/migrations/2020-05-05-122254_add_canceled_flag/down.sql deleted file mode 100644 index a7ac916f47..0000000000 --- a/base_layer/wallet/migrations/2020-05-05-122254_add_canceled_flag/down.sql +++ /dev/null @@ -1,12 +0,0 @@ -UPDATE completed_transactions -SET status = 5 -WHERE cancelled = 1; - -ALTER TABLE completed_transactions - DROP COLUMN cancelled; - -ALTER TABLE inbound_transactions - DROP COLUMN cancelled; - -ALTER TABLE outbound_transactions - DROP COLUMN cancelled; \ No newline at end of file diff --git a/base_layer/wallet/migrations/2020-05-05-122254_add_canceled_flag/up.sql b/base_layer/wallet/migrations/2020-05-05-122254_add_canceled_flag/up.sql deleted file mode 100644 index 6c7ad2e09a..0000000000 --- a/base_layer/wallet/migrations/2020-05-05-122254_add_canceled_flag/up.sql +++ /dev/null @@ -1,13 +0,0 @@ -ALTER TABLE completed_transactions - ADD COLUMN cancelled INTEGER NOT NULL DEFAULT 0; - -ALTER TABLE inbound_transactions - ADD COLUMN cancelled INTEGER NOT NULL DEFAULT 0; - -ALTER TABLE outbound_transactions - ADD COLUMN cancelled INTEGER NOT NULL DEFAULT 0; - -UPDATE completed_transactions -SET cancelled = 1, - status = 1 -WHERE status = 5; diff --git a/base_layer/wallet/migrations/2020-05-11-124646_remove_coinbase_table/down.sql b/base_layer/wallet/migrations/2020-05-11-124646_remove_coinbase_table/down.sql deleted file mode 100644 index 53f41a9ffa..0000000000 --- a/base_layer/wallet/migrations/2020-05-11-124646_remove_coinbase_table/down.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE coinbase_transactions ( - tx_id INTEGER PRIMARY KEY NOT NULL, - amount INTEGER NOT NULL, - commitment BLOB NOT NULL, - timestamp DATETIME NOT NULL -); diff --git a/base_layer/wallet/migrations/2020-05-11-124646_remove_coinbase_table/up.sql b/base_layer/wallet/migrations/2020-05-11-124646_remove_coinbase_table/up.sql deleted file mode 100644 index 613046f13a..0000000000 --- a/base_layer/wallet/migrations/2020-05-11-124646_remove_coinbase_table/up.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS coinbase_transactions; \ No newline at end of file diff --git a/base_layer/wallet/migrations/2020-05-12-142154_add_direct_send_success_column_to_pending_tx/down.sql b/base_layer/wallet/migrations/2020-05-12-142154_add_direct_send_success_column_to_pending_tx/down.sql deleted file mode 100644 index 6292112d53..0000000000 --- a/base_layer/wallet/migrations/2020-05-12-142154_add_direct_send_success_column_to_pending_tx/down.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE outbound_transactions - DROP COLUMN cancelled; - -ALTER TABLE outbound_transactions - DROP COLUMN cancelled; \ No newline at end of file diff --git a/base_layer/wallet/migrations/2020-05-12-142154_add_direct_send_success_column_to_pending_tx/up.sql b/base_layer/wallet/migrations/2020-05-12-142154_add_direct_send_success_column_to_pending_tx/up.sql deleted file mode 100644 index ddabe4d5e5..0000000000 --- a/base_layer/wallet/migrations/2020-05-12-142154_add_direct_send_success_column_to_pending_tx/up.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE outbound_transactions - ADD COLUMN direct_send_success INTEGER NOT NULL DEFAULT 0; - -ALTER TABLE inbound_transactions - ADD COLUMN direct_send_success INTEGER NOT NULL DEFAULT 0; \ No newline at end of file diff --git a/base_layer/wallet/migrations/2020-05-21-170850_add_hash_to_outputs/down.sql b/base_layer/wallet/migrations/2020-05-21-170850_add_hash_to_outputs/down.sql deleted file mode 100644 index 349ae98172..0000000000 --- a/base_layer/wallet/migrations/2020-05-21-170850_add_hash_to_outputs/down.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE outputs - DROP COLUMN hash; diff --git a/base_layer/wallet/migrations/2020-05-21-170850_add_hash_to_outputs/up.sql b/base_layer/wallet/migrations/2020-05-21-170850_add_hash_to_outputs/up.sql deleted file mode 100644 index f57eb504fd..0000000000 --- a/base_layer/wallet/migrations/2020-05-21-170850_add_hash_to_outputs/up.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE outputs - ADD COLUMN hash BLOB NULL; diff --git a/base_layer/wallet/migrations/2020-06-15-084821_add_wallet_settings/down.sql b/base_layer/wallet/migrations/2020-06-15-084821_add_wallet_settings/down.sql deleted file mode 100644 index 043e6e4c8e..0000000000 --- a/base_layer/wallet/migrations/2020-06-15-084821_add_wallet_settings/down.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS wallet_settings; \ No newline at end of file diff --git a/base_layer/wallet/migrations/2020-06-15-084821_add_wallet_settings/up.sql b/base_layer/wallet/migrations/2020-06-15-084821_add_wallet_settings/up.sql deleted file mode 100644 index b2233a2ebd..0000000000 --- a/base_layer/wallet/migrations/2020-06-15-084821_add_wallet_settings/up.sql +++ /dev/null @@ -1,4 +0,0 @@ -CREATE TABLE wallet_settings ( - key TEXT PRIMARY KEY NOT NULL, - value TEXT NOT NULL -); diff --git a/base_layer/wallet/migrations/2020-06-23-135346_add_completed_transaction_direction/down.sql b/base_layer/wallet/migrations/2020-06-23-135346_add_completed_transaction_direction/down.sql deleted file mode 100644 index 3778413d2a..0000000000 --- a/base_layer/wallet/migrations/2020-06-23-135346_add_completed_transaction_direction/down.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE completed_transactions - DROP COLUMN direction; \ No newline at end of file diff --git a/base_layer/wallet/migrations/2020-06-23-135346_add_completed_transaction_direction/up.sql b/base_layer/wallet/migrations/2020-06-23-135346_add_completed_transaction_direction/up.sql deleted file mode 100644 index 09b1821237..0000000000 --- a/base_layer/wallet/migrations/2020-06-23-135346_add_completed_transaction_direction/up.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE completed_transactions - ADD COLUMN direction INTEGER NULL; diff --git a/base_layer/wallet/migrations/2020-06-29-130334_add_id_primary_key_to_outputs/down.sql b/base_layer/wallet/migrations/2020-06-29-130334_add_id_primary_key_to_outputs/down.sql deleted file mode 100644 index e68095cee3..0000000000 --- a/base_layer/wallet/migrations/2020-06-29-130334_add_id_primary_key_to_outputs/down.sql +++ /dev/null @@ -1,17 +0,0 @@ -PRAGMA foreign_keys=OFF; -ALTER TABLE outputs - RENAME TO outputs_old; -CREATE TABLE outputs ( - spending_key BLOB PRIMARY KEY NOT NULL, - value INTEGER NOT NULL, - flags INTEGER NOT NULL, - maturity INTEGER NOT NULL, - status INTEGER NOT NULL, - tx_id INTEGER NULL, - hash BLOB NULL -); -INSERT INTO outputs (spending_key, value, flags, maturity, status, tx_id, hash) -SELECT spending_key, value, flags, maturity, status, tx_id, hash -FROM outputs_old; -DROP TABLE outputs_old; -PRAGMA foreign_keys=ON; diff --git a/base_layer/wallet/migrations/2020-06-29-130334_add_id_primary_key_to_outputs/up.sql b/base_layer/wallet/migrations/2020-06-29-130334_add_id_primary_key_to_outputs/up.sql deleted file mode 100644 index 856088c794..0000000000 --- a/base_layer/wallet/migrations/2020-06-29-130334_add_id_primary_key_to_outputs/up.sql +++ /dev/null @@ -1,19 +0,0 @@ -PRAGMA foreign_keys=OFF; -ALTER TABLE outputs - RENAME TO outputs_old; -CREATE TABLE outputs ( - id INTEGER NOT NULL PRIMARY KEY, - commitment BLOB NULL, - spending_key BLOB NOT NULL, - value INTEGER NOT NULL, - flags INTEGER NOT NULL, - maturity INTEGER NOT NULL, - status INTEGER NOT NULL, - tx_id INTEGER NULL, - hash BLOB NULL -); -INSERT INTO outputs (spending_key, value, flags, maturity, status, tx_id, hash) -SELECT spending_key, value, flags, maturity, status, tx_id, hash -FROM outputs_old; -DROP TABLE outputs_old; -PRAGMA foreign_keys=ON; diff --git a/base_layer/wallet/migrations/2020-07-08-083612_remove_peer_table/down.sql b/base_layer/wallet/migrations/2020-07-08-083612_remove_peer_table/down.sql deleted file mode 100644 index 17a0212dd4..0000000000 --- a/base_layer/wallet/migrations/2020-07-08-083612_remove_peer_table/down.sql +++ /dev/null @@ -1,4 +0,0 @@ -CREATE TABLE peers ( - public_key BLOB PRIMARY KEY NOT NULL UNIQUE, - peer TEXT NOT NULL -); diff --git a/base_layer/wallet/migrations/2020-07-08-083612_remove_peer_table/up.sql b/base_layer/wallet/migrations/2020-07-08-083612_remove_peer_table/up.sql deleted file mode 100644 index f4ce4b526e..0000000000 --- a/base_layer/wallet/migrations/2020-07-08-083612_remove_peer_table/up.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS peers; \ No newline at end of file diff --git a/base_layer/wallet/migrations/2020-07-20-084915_add_coinbase_handling/down.sql b/base_layer/wallet/migrations/2020-07-20-084915_add_coinbase_handling/down.sql deleted file mode 100644 index 069db33c5f..0000000000 --- a/base_layer/wallet/migrations/2020-07-20-084915_add_coinbase_handling/down.sql +++ /dev/null @@ -1,66 +0,0 @@ --- This file should undo anything in `up.sql` -PRAGMA foreign_keys=OFF; -ALTER TABLE key_manager_states - RENAME TO key_manager_states_old; - -CREATE TABLE key_manager_states ( - id INTEGER PRIMARY KEY, - master_seed BLOB NOT NULL, - branch_seed TEXT NOT NULL, - primary_key_index INTEGER NOT NULL, - timestamp DATETIME NOT NULL -); -INSERT INTO key_manager_states (id, master_seed, branch_seed, primary_key_index, timestamp) -SELECT id, master_key, branch_seed, primary_key_index, timestamp -FROM key_manager_states_old; -DROP TABLE key_manager_states_old; - -PRAGMA foreign_keys=ON; - -PRAGMA foreign_keys=OFF; -ALTER TABLE pending_transaction_outputs - RENAME TO pending_transaction_outputs_old; -CREATE TABLE pending_transaction_outputs ( - tx_id INTEGER PRIMARY KEY NOT NULL, - short_term INTEGER NOT NULL, - timestamp DATETIME NOT NULL -); -INSERT INTO pending_transaction_outputs (tx_id, short_term, timestamp) -SELECT tx_id, short_term, timestamp -FROM pending_transaction_outputs_old; -DROP TABLE pending_transaction_outputs_old; -PRAGMA foreign_keys=ON; - -PRAGMA foreign_keys=OFF; -ALTER TABLE completed_transactions - RENAME TO completed_transactions_old; -CREATE TABLE completed_transactions ( - tx_id INTEGER PRIMARY KEY NOT NULL, - source_public_key BLOB NOT NULL, - destination_public_key BLOB NOT NULL, - amount INTEGER NOT NULL, - fee INTEGER NOT NULL, - transaction_protocol TEXT NOT NULL, - status INTEGER NOT NULL, - message TEXT NOT NULL, - timestamp DATETIME NOT NULL, - cancelled INTEGER NOT NULL DEFAULT 0, - direction INTEGER NULL -); -INSERT INTO completed_transactions (tx_id, source_public_key, destination_public_key, amount, fee, transaction_protocol, - status, message, timestamp, cancelled, direction) -SELECT tx_id, - source_public_key, - destination_public_key, - amount, - fee, - transaction_protocol, - status, - message, - timestamp, - cancelled, - direction -FROM completed_transactions_old; - -DROP TABLE completed_transactions_old; -PRAGMA foreign_keys=ON; diff --git a/base_layer/wallet/migrations/2020-07-20-084915_add_coinbase_handling/up.sql b/base_layer/wallet/migrations/2020-07-20-084915_add_coinbase_handling/up.sql deleted file mode 100644 index fcf8aa3ca0..0000000000 --- a/base_layer/wallet/migrations/2020-07-20-084915_add_coinbase_handling/up.sql +++ /dev/null @@ -1,23 +0,0 @@ --- Rename the master_seed column to master_key -PRAGMA foreign_keys=OFF; -ALTER TABLE key_manager_states - RENAME TO key_manager_states_old; - -CREATE TABLE key_manager_states ( - id INTEGER PRIMARY KEY NOT NULL, - master_key BLOB NOT NULL, - branch_seed TEXT NOT NULL, - primary_key_index BIGINT NOT NULL, - timestamp DATETIME NOT NULL -); -INSERT INTO key_manager_states (id, master_key, branch_seed, primary_key_index, timestamp) -SELECT id, master_seed, branch_seed, primary_key_index, timestamp -FROM key_manager_states_old; -DROP TABLE key_manager_states_old; - -PRAGMA foreign_keys=ON; -ALTER TABLE pending_transaction_outputs - ADD COLUMN coinbase_block_height BIGINT NULL; - -ALTER TABLE completed_transactions - ADD COLUMN coinbase_block_height BIGINT NULL; diff --git a/base_layer/wallet/migrations/2020-08-17-141407_add_resend_count_and_timestamp_add_status_to_pending_txs/down.sql b/base_layer/wallet/migrations/2020-08-17-141407_add_resend_count_and_timestamp_add_status_to_pending_txs/down.sql deleted file mode 100644 index 07b5741e70..0000000000 --- a/base_layer/wallet/migrations/2020-08-17-141407_add_resend_count_and_timestamp_add_status_to_pending_txs/down.sql +++ /dev/null @@ -1,90 +0,0 @@ -PRAGMA foreign_keys=OFF; -ALTER TABLE completed_transactions - RENAME TO completed_transactions_old; -CREATE TABLE completed_transactions ( - tx_id INTEGER PRIMARY KEY NOT NULL, - source_public_key BLOB NOT NULL, - destination_public_key BLOB NOT NULL, - amount INTEGER NOT NULL, - fee INTEGER NOT NULL, - transaction_protocol TEXT NOT NULL, - status INTEGER NOT NULL, - message TEXT NOT NULL, - timestamp DATETIME NOT NULL, - cancelled INTEGER NOT NULL DEFAULT 0, - direction INTEGER NULL, - coinbase_block_height INTEGER NULL -); -INSERT INTO completed_transactions (tx_id, source_public_key, destination_public_key, amount, fee, transaction_protocol, - status, message, timestamp, cancelled, direction, coinbase_block_height) -SELECT tx_id, - source_public_key, - destination_public_key, - amount, - fee, - transaction_protocol, - status, - message, - timestamp, - cancelled, - direction, - coinbase_block_height -FROM completed_transactions_old; - -DROP TABLE completed_transactions_old; - -ALTER TABLE inbound_transactions - RENAME TO inbound_transactions_old; -CREATE TABLE inbound_transactions ( - tx_id INTEGER PRIMARY KEY NOT NULL, - source_public_key BLOB NOT NULL, - amount INTEGER NOT NULL, - receiver_protocol TEXT NOT NULL, - message TEXT NOT NULL, - timestamp DATETIME NOT NULL, - cancelled INTEGER NOT NULL DEFAULT 0, - direct_send_success INTEGER NOT NULL DEFAULT 0 -); -INSERT INTO inbound_transactions (tx_id, source_public_key, amount, receiver_protocol, message, timestamp, cancelled, - direct_send_success) -SELECT tx_id, - source_public_key, - amount, - receiver_protocol, - message, - timestamp, - cancelled, - direct_send_success -FROM inbound_transactions_old; - -DROP TABLE inbound_transactions_old; - -ALTER TABLE outbound_transactions - RENAME TO outbound_transactions_old; -CREATE TABLE outbound_transactions ( - tx_id INTEGER PRIMARY KEY NOT NULL, - destination_public_key BLOB NOT NULL, - amount INTEGER NOT NULL, - fee INTEGER NOT NULL, - sender_protocol TEXT NOT NULL, - message TEXT NOT NULL, - timestamp DATETIME NOT NULL, - cancelled INTEGER NOT NULL DEFAULT 0, - direct_send_success INTEGER NOT NULL DEFAULT 0 -); -INSERT INTO outbound_transactions (tx_id, destination_public_key, amount, fee, sender_protocol, message, timestamp, - cancelled, direct_send_success) -SELECT tx_id, - destination_public_key, - amount, - fee, - sender_protocol, - message, - timestamp, - cancelled, - direct_send_success -FROM outbound_transactions_old; - -DROP TABLE outbound_transactions_old; - -PRAGMA foreign_keys=ON; diff --git a/base_layer/wallet/migrations/2020-08-17-141407_add_resend_count_and_timestamp_add_status_to_pending_txs/up.sql b/base_layer/wallet/migrations/2020-08-17-141407_add_resend_count_and_timestamp_add_status_to_pending_txs/up.sql deleted file mode 100644 index 8a76caba02..0000000000 --- a/base_layer/wallet/migrations/2020-08-17-141407_add_resend_count_and_timestamp_add_status_to_pending_txs/up.sql +++ /dev/null @@ -1,14 +0,0 @@ -ALTER TABLE completed_transactions - ADD COLUMN send_count INTEGER NOT NULL DEFAULT 0; -ALTER TABLE completed_transactions - ADD COLUMN last_send_timestamp DATETIME NULL; - -ALTER TABLE inbound_transactions - ADD COLUMN send_count INTEGER NOT NULL DEFAULT 0; -ALTER TABLE inbound_transactions - ADD COLUMN last_send_timestamp DATETIME NULL; - -ALTER TABLE outbound_transactions - ADD COLUMN send_count INTEGER NOT NULL DEFAULT 0; -ALTER TABLE outbound_transactions - ADD COLUMN last_send_timestamp DATETIME NULL; diff --git a/base_layer/wallet/migrations/2020-10-20-094420_add_client_key_value_store/down.sql b/base_layer/wallet/migrations/2020-10-20-094420_add_client_key_value_store/down.sql deleted file mode 100644 index 9cd4663fc7..0000000000 --- a/base_layer/wallet/migrations/2020-10-20-094420_add_client_key_value_store/down.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS client_key_values; \ No newline at end of file diff --git a/base_layer/wallet/migrations/2021-02-03-074953_add_valid_flag_to_transaction/down.sql b/base_layer/wallet/migrations/2021-02-03-074953_add_valid_flag_to_transaction/down.sql deleted file mode 100644 index 94f890addd..0000000000 --- a/base_layer/wallet/migrations/2021-02-03-074953_add_valid_flag_to_transaction/down.sql +++ /dev/null @@ -1,37 +0,0 @@ -PRAGMA foreign_keys=OFF; -ALTER TABLE completed_transactions - RENAME TO completed_transactions_old; -CREATE TABLE completed_transactions ( - tx_id INTEGER PRIMARY KEY NOT NULL, - source_public_key BLOB NOT NULL, - destination_public_key BLOB NOT NULL, - amount INTEGER NOT NULL, - fee INTEGER NOT NULL, - transaction_protocol TEXT NOT NULL, - status INTEGER NOT NULL, - message TEXT NOT NULL, - timestamp DATETIME NOT NULL, - cancelled INTEGER NOT NULL DEFAULT 0, - direction INTEGER NULL, - coinbase_block_height INTEGER NULL, - send_count INTEGER NOT NULL DEFAULT 0, - last_send_timestamp DATETIME NULL, -); -INSERT INTO completed_transactions (tx_id, source_public_key, destination_public_key, amount, fee, transaction_protocol, - status, message, timestamp, cancelled, direction, coinbase_block_height, send_count, - last_send_timestamp) -SELECT tx_id, - source_public_key, - destination_public_key, - amount, - fee, - transaction_protocol, - status, - message, - timestamp, - cancelled, - direction, - coinbase_block_height, - send_count, - last_send_timestamp -FROM completed_transactions_old; diff --git a/base_layer/wallet/migrations/2021-02-03-074953_add_valid_flag_to_transaction/up.sql b/base_layer/wallet/migrations/2021-02-03-074953_add_valid_flag_to_transaction/up.sql deleted file mode 100644 index ae53f46def..0000000000 --- a/base_layer/wallet/migrations/2021-02-03-074953_add_valid_flag_to_transaction/up.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE completed_transactions - ADD COLUMN valid INTEGER NOT NULL DEFAULT 0; \ No newline at end of file diff --git a/base_layer/wallet/migrations/2021-02-15-084900_add_outputs_unique_commitment/down.sql b/base_layer/wallet/migrations/2021-02-15-084900_add_outputs_unique_commitment/down.sql deleted file mode 100644 index f25583bae2..0000000000 --- a/base_layer/wallet/migrations/2021-02-15-084900_add_outputs_unique_commitment/down.sql +++ /dev/null @@ -1,19 +0,0 @@ -PRAGMA foreign_keys=OFF; -ALTER TABLE outputs - RENAME TO outputs_old; -CREATE TABLE outputs ( - id INTEGER NOT NULL PRIMARY KEY, - commitment BLOB NULL, - spending_key BLOB NOT NULL, - value INTEGER NOT NULL, - flags INTEGER NOT NULL, - maturity INTEGER NOT NULL, - status INTEGER NOT NULL, - tx_id INTEGER NULL, - hash BLOB NULL, -); -INSERT INTO outputs -SELECT * -FROM outputs_old; -DROP TABLE outputs_old; -PRAGMA foreign_keys=ON; diff --git a/base_layer/wallet/migrations/2021-02-15-084900_add_outputs_unique_commitment/up.sql b/base_layer/wallet/migrations/2021-02-15-084900_add_outputs_unique_commitment/up.sql deleted file mode 100644 index 6b3ed366e5..0000000000 --- a/base_layer/wallet/migrations/2021-02-15-084900_add_outputs_unique_commitment/up.sql +++ /dev/null @@ -1,20 +0,0 @@ -PRAGMA foreign_keys=OFF; -ALTER TABLE outputs - RENAME TO outputs_old; -CREATE TABLE outputs ( - id INTEGER NOT NULL PRIMARY KEY, - commitment BLOB NULL, - spending_key BLOB NOT NULL, - value INTEGER NOT NULL, - flags INTEGER NOT NULL, - maturity INTEGER NOT NULL, - status INTEGER NOT NULL, - tx_id INTEGER NULL, - hash BLOB NULL, - CONSTRAINT unique_commitment UNIQUE (commitment) -); -INSERT INTO outputs -SELECT * -FROM outputs_old; -DROP TABLE outputs_old; -PRAGMA foreign_keys=ON; diff --git a/base_layer/wallet/migrations/2021-03-23-082938_update-outputs-for-tari-script/down.sql b/base_layer/wallet/migrations/2021-03-23-082938_update-outputs-for-tari-script/down.sql deleted file mode 100644 index b53bac2097..0000000000 --- a/base_layer/wallet/migrations/2021-03-23-082938_update-outputs-for-tari-script/down.sql +++ /dev/null @@ -1 +0,0 @@ --- This migration is only meant for fresh databases on a testnet reset, so the down is not needed \ No newline at end of file diff --git a/base_layer/wallet/migrations/2021-03-23-082938_update-outputs-for-tari-script/up.sql b/base_layer/wallet/migrations/2021-03-23-082938_update-outputs-for-tari-script/up.sql deleted file mode 100644 index 7109f61364..0000000000 --- a/base_layer/wallet/migrations/2021-03-23-082938_update-outputs-for-tari-script/up.sql +++ /dev/null @@ -1,23 +0,0 @@ --- This migration is part of a testnet reset and should not be used on db's with existing old data in them --- thus this migration does not accommodate db's with existing rows. - -PRAGMA foreign_keys=OFF; -DROP TABLE outputs; -CREATE TABLE outputs ( - id INTEGER NOT NULL PRIMARY KEY, - commitment BLOB NOT NULL, - spending_key BLOB NOT NULL, - value INTEGER NOT NULL, - flags INTEGER NOT NULL, - maturity INTEGER NOT NULL, - status INTEGER NOT NULL, - tx_id INTEGER NULL, - hash BLOB NOT NULL, - script BLOB NOT NULL, - input_data BLOB NOT NULL, - height INTEGER NOT NULL, - script_private_key BLOB NOT NULL, - sender_offset_public_key BLOB NOT NULL, - CONSTRAINT unique_commitment UNIQUE (commitment) -); -PRAGMA foreign_keys=ON; diff --git a/base_layer/wallet/migrations/2021-04-01-081220_add_transaction_confirmations/down.sql b/base_layer/wallet/migrations/2021-04-01-081220_add_transaction_confirmations/down.sql deleted file mode 100644 index ea69cb57ca..0000000000 --- a/base_layer/wallet/migrations/2021-04-01-081220_add_transaction_confirmations/down.sql +++ /dev/null @@ -1,39 +0,0 @@ -PRAGMA foreign_keys=OFF; -ALTER TABLE completed_transactions - RENAME TO completed_transactions_old; -CREATE TABLE completed_transactions ( - tx_id INTEGER PRIMARY KEY NOT NULL, - source_public_key BLOB NOT NULL, - destination_public_key BLOB NOT NULL, - amount INTEGER NOT NULL, - fee INTEGER NOT NULL, - transaction_protocol TEXT NOT NULL, - status INTEGER NOT NULL, - message TEXT NOT NULL, - timestamp DATETIME NOT NULL, - cancelled INTEGER NOT NULL DEFAULT 0, - direction INTEGER NULL DEFAULT NULL, - coinbase_block_height INTEGER NULL DEFAULT NULL, - send_count INTEGER NOT NULL DEFAULT 0, - last_send_timestamp DATETIME NULL DEFAULT NULL, - valid INTEGER NOT NULL DEFAULT 0, -); -INSERT INTO completed_transactions (tx_id, source_public_key, destination_public_key, amount, fee, transaction_protocol, - status, message, timestamp, cancelled, direction, coinbase_block_height, send_count, - last_send_timestamp, valid) -SELECT tx_id, - source_public_key, - destination_public_key, - amount, - fee, - transaction_protocol, - status, - message, - timestamp, - cancelled, - direction, - coinbase_block_height, - send_count, - last_send_timestamp, - valid -FROM completed_transactions_old; diff --git a/base_layer/wallet/migrations/2021-04-01-081220_add_transaction_confirmations/up.sql b/base_layer/wallet/migrations/2021-04-01-081220_add_transaction_confirmations/up.sql deleted file mode 100644 index c88bd991f1..0000000000 --- a/base_layer/wallet/migrations/2021-04-01-081220_add_transaction_confirmations/up.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE completed_transactions - ADD COLUMN confirmations BIGINT NULL DEFAULT NULL; diff --git a/base_layer/wallet/migrations/2021-04-19-085137_add_mined_height_to_completed_transaction/down.sql b/base_layer/wallet/migrations/2021-04-19-085137_add_mined_height_to_completed_transaction/down.sql deleted file mode 100644 index 0babec895d..0000000000 --- a/base_layer/wallet/migrations/2021-04-19-085137_add_mined_height_to_completed_transaction/down.sql +++ /dev/null @@ -1,41 +0,0 @@ -PRAGMA foreign_keys=OFF; -ALTER TABLE completed_transactions - RENAME TO completed_transactions_old; -CREATE TABLE completed_transactions ( - tx_id INTEGER PRIMARY KEY NOT NULL, - source_public_key BLOB NOT NULL, - destination_public_key BLOB NOT NULL, - amount INTEGER NOT NULL, - fee INTEGER NOT NULL, - transaction_protocol TEXT NOT NULL, - status INTEGER NOT NULL, - message TEXT NOT NULL, - timestamp DATETIME NOT NULL, - cancelled INTEGER NOT NULL DEFAULT 0, - direction INTEGER NULL DEFAULT NULL, - coinbase_block_height INTEGER NULL DEFAULT NULL, - send_count INTEGER NOT NULL DEFAULT 0, - last_send_timestamp DATETIME NULL DEFAULT NULL, - valid INTEGER NOT NULL DEFAULT 0, - confirmations INTEGER NULL DEFAULT NULL -); -INSERT INTO completed_transactions (tx_id, source_public_key, destination_public_key, amount, fee, transaction_protocol, - status, message, timestamp, cancelled, direction, coinbase_block_height, send_count, - last_send_timestamp, valid, confirmations) -SELECT tx_id, - source_public_key, - destination_public_key, - amount, - fee, - transaction_protocol, - status, - message, - timestamp, - cancelled, - direction, - coinbase_block_height, - send_count, - last_send_timestamp, - valid, - confirmations -FROM completed_transactions_old; diff --git a/base_layer/wallet/migrations/2021-04-19-085137_add_mined_height_to_completed_transaction/up.sql b/base_layer/wallet/migrations/2021-04-19-085137_add_mined_height_to_completed_transaction/up.sql deleted file mode 100644 index 393d990670..0000000000 --- a/base_layer/wallet/migrations/2021-04-19-085137_add_mined_height_to_completed_transaction/up.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE completed_transactions - ADD COLUMN mined_height BIGINT NULL; diff --git a/base_layer/wallet/migrations/2021-04-29-125155_known_scripts/down.sql b/base_layer/wallet/migrations/2021-04-29-125155_known_scripts/down.sql deleted file mode 100644 index 1d0edbc2d1..0000000000 --- a/base_layer/wallet/migrations/2021-04-29-125155_known_scripts/down.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS known_one_sided_payment_scripts; diff --git a/base_layer/wallet/migrations/2021-04-29-125155_known_scripts/up.sql b/base_layer/wallet/migrations/2021-04-29-125155_known_scripts/up.sql deleted file mode 100644 index 4c9e28ff3d..0000000000 --- a/base_layer/wallet/migrations/2021-04-29-125155_known_scripts/up.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE known_one_sided_payment_scripts ( - script_hash BLOB PRIMARY KEY NOT NULL, - private_key BLOB NOT NULL, - script BLOB NOT NULL, - input BLOB NOT NULL -); diff --git a/base_layer/wallet/migrations/2021-06-22-143855_sender_meta_signature/down.sql b/base_layer/wallet/migrations/2021-06-22-143855_sender_meta_signature/down.sql deleted file mode 100644 index b53bac2097..0000000000 --- a/base_layer/wallet/migrations/2021-06-22-143855_sender_meta_signature/down.sql +++ /dev/null @@ -1 +0,0 @@ --- This migration is only meant for fresh databases on a testnet reset, so the down is not needed \ No newline at end of file diff --git a/base_layer/wallet/migrations/2021-06-22-143855_sender_meta_signature/up.sql b/base_layer/wallet/migrations/2021-06-22-143855_sender_meta_signature/up.sql deleted file mode 100644 index 6e3d673b6a..0000000000 --- a/base_layer/wallet/migrations/2021-06-22-143855_sender_meta_signature/up.sql +++ /dev/null @@ -1,25 +0,0 @@ --- This migration is part of a testnet reset and should not be used on db's with existing old data in them --- thus this migration does not accommodate db's with existing rows. - -PRAGMA foreign_keys=OFF; -DROP TABLE outputs; -CREATE TABLE outputs ( - id INTEGER NOT NULL PRIMARY KEY, - commitment BLOB NOT NULL, - spending_key BLOB NOT NULL, - value INTEGER NOT NULL, - flags INTEGER NOT NULL, - maturity INTEGER NOT NULL, - status INTEGER NOT NULL, - tx_id INTEGER NULL, - hash BLOB NOT NULL, - script BLOB NOT NULL, - input_data BLOB NOT NULL, - height INTEGER NOT NULL, - script_private_key BLOB NOT NULL, - script_offset_public_key BLOB NOT NULL, - sender_metadata_signature_key BLOB NOT NULL, - sender_metadata_signature_nonce BLOB NOT NULL, - CONSTRAINT unique_commitment UNIQUE (commitment) -); -PRAGMA foreign_keys=ON; diff --git a/base_layer/wallet/migrations/2021-07-02-090239_remove_height_from_output/down.sql b/base_layer/wallet/migrations/2021-07-02-090239_remove_height_from_output/down.sql deleted file mode 100644 index aa13da0bd7..0000000000 --- a/base_layer/wallet/migrations/2021-07-02-090239_remove_height_from_output/down.sql +++ /dev/null @@ -1,45 +0,0 @@ -PRAGMA foreign_keys=OFF; -ALTER TABLE outputs - RENAME TO outputs_old; -CREATE TABLE outputs ( - id INTEGER NOT NULL PRIMARY KEY, - commitment BLOB NOT NULL, - spending_key BLOB NOT NULL, - value INTEGER NOT NULL, - flags INTEGER NOT NULL, - maturity INTEGER NOT NULL, - status INTEGER NOT NULL, - tx_id INTEGER NULL, - hash BLOB NOT NULL, - script BLOB NOT NULL, - input_data BLOB NOT NULL, - height INTEGER NOT NULL, - script_private_key BLOB NOT NULL, - script_offset_public_key BLOB NOT NULL, - sender_metadata_signature_key BLOB NOT NULL, - sender_metadata_signature_nonce BLOB NOT NULL, - CONSTRAINT unique_commitment UNIQUE (commitment) -); - -INSERT INTO outputs (id, commitment, spending_key, value, flags, maturity, status, tx_id, hash, script, input_data, - height, script_private_key, script_offset_public_key, sender_metadata_signature_key, - sender_metadata_signature_nonce) -SELECT id, - commitment, - spending_key, - value, - flags, - maturity, - status, - tx_id, - hash, - script, - input_data, - 0, - script_private_key, - script_offset_public_key, - sender_metadata_signature_key, - sender_metadata_signature_nonce -FROM outputs_old; -DROP TABLE outputs_old; -PRAGMA foreign_keys=ON; diff --git a/base_layer/wallet/migrations/2021-07-02-090239_remove_height_from_output/up.sql b/base_layer/wallet/migrations/2021-07-02-090239_remove_height_from_output/up.sql deleted file mode 100644 index 9402ababc7..0000000000 --- a/base_layer/wallet/migrations/2021-07-02-090239_remove_height_from_output/up.sql +++ /dev/null @@ -1,43 +0,0 @@ -PRAGMA foreign_keys=OFF; -ALTER TABLE outputs - RENAME TO outputs_old; -CREATE TABLE outputs ( - id INTEGER NOT NULL PRIMARY KEY, - commitment BLOB NOT NULL, - spending_key BLOB NOT NULL, - value INTEGER NOT NULL, - flags INTEGER NOT NULL, - maturity INTEGER NOT NULL, - status INTEGER NOT NULL, - tx_id INTEGER NULL, - hash BLOB NOT NULL, - script BLOB NOT NULL, - input_data BLOB NOT NULL, - script_private_key BLOB NOT NULL, - script_offset_public_key BLOB NOT NULL, - sender_metadata_signature_key BLOB NOT NULL, - sender_metadata_signature_nonce BLOB NOT NULL, - CONSTRAINT unique_commitment UNIQUE (commitment) -); - -INSERT INTO outputs (id, commitment, spending_key, value, flags, maturity, status, tx_id, hash, script, input_data, - script_private_key, script_offset_public_key, sender_metadata_signature_key, - sender_metadata_signature_nonce) -SELECT id, - commitment, - spending_key, - value, - flags, - maturity, - status, - tx_id, - hash, - script, - input_data, - script_private_key, - script_offset_public_key, - sender_metadata_signature_key, - sender_metadata_signature_nonce -FROM outputs_old; -DROP TABLE outputs_old; -PRAGMA foreign_keys=ON; diff --git a/base_layer/wallet/migrations/2021-07-05-13201407_metadata_signature/down.sql b/base_layer/wallet/migrations/2021-07-05-13201407_metadata_signature/down.sql deleted file mode 100644 index b53bac2097..0000000000 --- a/base_layer/wallet/migrations/2021-07-05-13201407_metadata_signature/down.sql +++ /dev/null @@ -1 +0,0 @@ --- This migration is only meant for fresh databases on a testnet reset, so the down is not needed \ No newline at end of file diff --git a/base_layer/wallet/migrations/2021-07-05-13201407_metadata_signature/up.sql b/base_layer/wallet/migrations/2021-07-05-13201407_metadata_signature/up.sql deleted file mode 100644 index 145be56e60..0000000000 --- a/base_layer/wallet/migrations/2021-07-05-13201407_metadata_signature/up.sql +++ /dev/null @@ -1,25 +0,0 @@ --- This migration is part of a testnet reset and should not be used on db's with existing old data in them --- thus this migration does not accommodate db's with existing rows. - -PRAGMA foreign_keys=OFF; -DROP TABLE outputs; -CREATE TABLE outputs ( - id INTEGER NOT NULL PRIMARY KEY, --auto inc, - commitment BLOB NULL, - spending_key BLOB NOT NULL, - value BIGINT NOT NULL, - flags INTEGER NOT NULL, - maturity BIGINT NOT NULL, - status INTEGER NOT NULL, - tx_id BIGINT NULL, - hash BLOB NULL, - script BLOB NOT NULL, - input_data BLOB NOT NULL, - script_private_key BLOB NOT NULL, - sender_offset_public_key BLOB NOT NULL, - metadata_signature_nonce BLOB NOT NULL, - metadata_signature_u_key BLOB NOT NULL, - metadata_signature_v_key BLOB NOT NULL, - CONSTRAINT unique_commitment UNIQUE (commitment) -); -PRAGMA foreign_keys=ON; diff --git a/base_layer/wallet/migrations/2021-07-28-120000_add_mined_in_block/down.sql b/base_layer/wallet/migrations/2021-07-28-120000_add_mined_in_block/down.sql deleted file mode 100644 index 6472d3ab75..0000000000 --- a/base_layer/wallet/migrations/2021-07-28-120000_add_mined_in_block/down.sql +++ /dev/null @@ -1 +0,0 @@ --- not supported diff --git a/base_layer/wallet/migrations/2021-07-28-120000_add_mined_in_block/up.sql b/base_layer/wallet/migrations/2021-07-28-120000_add_mined_in_block/up.sql deleted file mode 100644 index 06ff11c0f6..0000000000 --- a/base_layer/wallet/migrations/2021-07-28-120000_add_mined_in_block/up.sql +++ /dev/null @@ -1,33 +0,0 @@ --- Copyright 2021. The Tari Project --- --- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the --- following conditions are met: --- --- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following --- disclaimer. --- --- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the --- following disclaimer in the documentation and/or other materials provided with the distribution. --- --- 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote --- products derived from this software without specific prior written permission. --- --- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, --- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE --- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR --- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, --- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE --- USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -ALTER TABLE completed_transactions - ADD mined_in_block BLOB NULL; - -ALTER TABLE outputs - ADD mined_height UNSIGNED BIGINT NULL; - -ALTER TABLE outputs - ADD mined_in_block BLOB NULL; - -ALTER TABLE outputs - ADD mined_mmr_position BIGINT NULL; diff --git a/base_layer/wallet/migrations/2021-08-03-123456_update_outputs_mined/down.sql b/base_layer/wallet/migrations/2021-08-03-123456_update_outputs_mined/down.sql deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/base_layer/wallet/migrations/2021-08-03-123456_update_outputs_mined/up.sql b/base_layer/wallet/migrations/2021-08-03-123456_update_outputs_mined/up.sql deleted file mode 100644 index e21d85bd9d..0000000000 --- a/base_layer/wallet/migrations/2021-08-03-123456_update_outputs_mined/up.sql +++ /dev/null @@ -1,32 +0,0 @@ --- Copyright 2021. The Tari Project --- --- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the --- following conditions are met: --- --- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following --- disclaimer. --- --- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the --- following disclaimer in the documentation and/or other materials provided with the distribution. --- --- 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote --- products derived from this software without specific prior written permission. --- --- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, --- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE --- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR --- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, --- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE --- USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -ALTER TABLE outputs - ADD marked_deleted_at_height BIGINT; -ALTER TABLE outputs - ADD marked_deleted_in_block BLOB; -ALTER TABLE outputs - ADD received_in_tx_id BIGINT; -ALTER TABLE outputs - ADD spent_in_tx_id BIGINT; -UPDATE outputs -SET received_in_tx_id = tx_id; diff --git a/base_layer/wallet/migrations/2021-09-07-145830_remove_pending_transactions_table_and_tx_id_in_outputs/down.sql b/base_layer/wallet/migrations/2021-09-07-145830_remove_pending_transactions_table_and_tx_id_in_outputs/down.sql deleted file mode 100644 index 291a97c5ce..0000000000 --- a/base_layer/wallet/migrations/2021-09-07-145830_remove_pending_transactions_table_and_tx_id_in_outputs/down.sql +++ /dev/null @@ -1 +0,0 @@ --- This file should undo anything in `up.sql` \ No newline at end of file diff --git a/base_layer/wallet/migrations/2021-09-07-145830_remove_pending_transactions_table_and_tx_id_in_outputs/up.sql b/base_layer/wallet/migrations/2021-09-07-145830_remove_pending_transactions_table_and_tx_id_in_outputs/up.sql deleted file mode 100644 index ea4cb4a772..0000000000 --- a/base_layer/wallet/migrations/2021-09-07-145830_remove_pending_transactions_table_and_tx_id_in_outputs/up.sql +++ /dev/null @@ -1,66 +0,0 @@ -DROP TABLE IF EXISTS pending_transaction_outputs; - --- Remove tx_id column -PRAGMA foreign_keys=OFF; -ALTER TABLE outputs - RENAME TO outputs_old; -CREATE TABLE outputs ( - id INTEGER NOT NULL PRIMARY KEY, --auto inc, - commitment BLOB NULL, - spending_key BLOB NOT NULL, - value BIGINT NOT NULL, - flags INTEGER NOT NULL, - maturity BIGINT NOT NULL, - status INTEGER NOT NULL, - hash BLOB NULL, - script BLOB NOT NULL, - input_data BLOB NOT NULL, - script_private_key BLOB NOT NULL, - sender_offset_public_key BLOB NOT NULL, - metadata_signature_nonce BLOB NOT NULL, - metadata_signature_u_key BLOB NOT NULL, - metadata_signature_v_key BLOB NOT NULL, - mined_height UNSIGNED BIGINT NULL, - mined_in_block BLOB NULL, - mined_mmr_position BIGINT NULL, - marked_deleted_at_height BIGINT, - marked_deleted_in_block BLOB, - received_in_tx_id BIGINT, - spent_in_tx_id BIGINT, - coinbase_block_height UNSIGNED BIGINT NULL, - CONSTRAINT unique_commitment UNIQUE (commitment) -); -PRAGMA foreign_keys=ON; - -INSERT INTO outputs (id, commitment, spending_key, value, flags, maturity, status, hash, script, input_data, - script_private_key, sender_offset_public_key, metadata_signature_nonce, metadata_signature_u_key, - metadata_signature_v_key, mined_height, mined_in_block, mined_mmr_position, marked_deleted_at_height, - marked_deleted_in_block, received_in_tx_id, spent_in_tx_id) -SELECT id, - commitment, - spending_key, - value, - flags, - maturity, - status, - hash, - script, - input_data, - script_private_key, - sender_offset_public_key, - metadata_signature_nonce, - metadata_signature_u_key, - metadata_signature_v_key, - mined_height, - mined_in_block, - mined_mmr_position, - marked_deleted_at_height, - marked_deleted_in_block, - received_in_tx_id, - spent_in_tx_id -FROM outputs_old; - -DROP TABLE outputs_old; -PRAGMA foreign_keys=ON; - - diff --git a/base_layer/wallet/migrations/2021-10-01-053552_clear_mined_height/down.sql b/base_layer/wallet/migrations/2021-10-01-053552_clear_mined_height/down.sql deleted file mode 100644 index 291a97c5ce..0000000000 --- a/base_layer/wallet/migrations/2021-10-01-053552_clear_mined_height/down.sql +++ /dev/null @@ -1 +0,0 @@ --- This file should undo anything in `up.sql` \ No newline at end of file diff --git a/base_layer/wallet/migrations/2021-10-01-053552_clear_mined_height/up.sql b/base_layer/wallet/migrations/2021-10-01-053552_clear_mined_height/up.sql deleted file mode 100644 index 1bea3b8d28..0000000000 --- a/base_layer/wallet/migrations/2021-10-01-053552_clear_mined_height/up.sql +++ /dev/null @@ -1,5 +0,0 @@ --- mined_height and mined_in_block should always be set together, since mined_in_block is NULL we set mined_height to NULL --- so that the transactions can be revalidated. -UPDATE completed_transactions -SET mined_height = NULL -WHERE mined_height IS NOT NULL AND mined_in_block IS NULL; \ No newline at end of file diff --git a/base_layer/wallet/migrations/2021-10-13-121212_add_unique_id/down.sql b/base_layer/wallet/migrations/2021-10-13-121212_add_unique_id/down.sql deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/base_layer/wallet/migrations/2021-10-13-121212_add_unique_id/up.sql b/base_layer/wallet/migrations/2021-10-13-121212_add_unique_id/up.sql deleted file mode 100644 index cb4f9b0bc3..0000000000 --- a/base_layer/wallet/migrations/2021-10-13-121212_add_unique_id/up.sql +++ /dev/null @@ -1,5 +0,0 @@ --- alter table outbound_transactions add unique_id blob; --- alter table completed_transactions add unique_id blob; -alter table outputs add metadata blob; -alter table outputs add features_parent_public_key blob; -alter table outputs add features_unique_id blob; diff --git a/base_layer/wallet/migrations/2021-10-27-103505_update_key_manager_state/down.sql b/base_layer/wallet/migrations/2021-10-27-103505_update_key_manager_state/down.sql deleted file mode 100644 index a6861c31e7..0000000000 --- a/base_layer/wallet/migrations/2021-10-27-103505_update_key_manager_state/down.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE key_manager_states - RENAME COLUMN seed TO master_key; \ No newline at end of file diff --git a/base_layer/wallet/migrations/2021-10-27-103505_update_key_manager_state/up.sql b/base_layer/wallet/migrations/2021-10-27-103505_update_key_manager_state/up.sql deleted file mode 100644 index bca3dfaa6d..0000000000 --- a/base_layer/wallet/migrations/2021-10-27-103505_update_key_manager_state/up.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE key_manager_states - RENAME COLUMN master_key TO seed; \ No newline at end of file diff --git a/base_layer/wallet/migrations/2021-10-28-164318_add_transaction_signature/down.sql b/base_layer/wallet/migrations/2021-10-28-164318_add_transaction_signature/down.sql deleted file mode 100644 index e6f0ea5bae..0000000000 --- a/base_layer/wallet/migrations/2021-10-28-164318_add_transaction_signature/down.sql +++ /dev/null @@ -1,48 +0,0 @@ -PRAGMA foreign_keys=OFF; -ALTER TABLE completed_transactions - RENAME TO completed_transactions_old; -CREATE TABLE completed_transactions ( - tx_id INTEGER PRIMARY KEY NOT NULL, - source_public_key BLOB NOT NULL, - destination_public_key BLOB NOT NULL, - amount INTEGER NOT NULL, - fee INTEGER NOT NULL, - transaction_protocol TEXT NOT NULL, - status INTEGER NOT NULL, - message TEXT NOT NULL, - timestamp DATETIME NOT NULL, - cancelled INTEGER NOT NULL DEFAULT 0, - direction INTEGER NULL DEFAULT NULL, - coinbase_block_height INTEGER NULL DEFAULT NULL, - send_count INTEGER NOT NULL DEFAULT 0, - last_send_timestamp DATETIME NULL DEFAULT NULL, - valid INTEGER NOT NULL DEFAULT 0, - confirmations INTEGER NULL DEFAULT NULL, - mined_height BIGINT NULL DEFAULT NULL, - mined_in_block BLOB NULL DEFAULT NULL - -); -INSERT INTO completed_transactions (tx_id, source_public_key, destination_public_key, amount, fee, transaction_protocol, - status, message, timestamp, cancelled, direction, coinbase_block_height, send_count, - last_send_timestamp, valid, confirmations) -SELECT tx_id, - source_public_key, - destination_public_key, - amount, - fee, - transaction_protocol, - status, - message, - timestamp, - cancelled, - direction, - coinbase_block_height, - send_count, - last_send_timestamp, - valid, - confirmations, - mined_height, - mined_in_block -FROM completed_transactions_old; -DROP TABLE completed_transactions_old; -PRAGMA foreign_keys=ON; diff --git a/base_layer/wallet/migrations/2021-10-28-164318_add_transaction_signature/up.sql b/base_layer/wallet/migrations/2021-10-28-164318_add_transaction_signature/up.sql deleted file mode 100644 index 179e7b39bb..0000000000 --- a/base_layer/wallet/migrations/2021-10-28-164318_add_transaction_signature/up.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE completed_transactions - ADD transaction_signature_nonce BLOB NOT NULL DEFAULT 0; - -ALTER TABLE completed_transactions - ADD transaction_signature_key BLOB NOT NULL DEFAULT 0; diff --git a/base_layer/wallet/migrations/2021-11-11-094000_add_script_lock_height/down.sql b/base_layer/wallet/migrations/2021-11-11-094000_add_script_lock_height/down.sql deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/base_layer/wallet/migrations/2021-11-11-094000_add_script_lock_height/up.sql b/base_layer/wallet/migrations/2021-11-11-094000_add_script_lock_height/up.sql deleted file mode 100644 index da064ece7d..0000000000 --- a/base_layer/wallet/migrations/2021-11-11-094000_add_script_lock_height/up.sql +++ /dev/null @@ -1,31 +0,0 @@ --- Copyright 2021. The Tari Project --- --- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the --- following conditions are met: --- --- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following --- disclaimer. --- --- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the --- following disclaimer in the documentation and/or other materials provided with the distribution. --- --- 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote --- products derived from this software without specific prior written permission. --- --- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, --- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE --- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR --- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, --- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE --- USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -ALTER TABLE outputs - ADD script_lock_height UNSIGNED BIGINT NOT NULL DEFAULT 0; - -ALTER TABLE outputs - ADD spending_priority UNSIGNED Integer NOT NULL DEFAULT 500; - -ALTER TABLE known_one_sided_payment_scripts - ADD script_lock_height UNSIGNED BIGINT NOT NULL DEFAULT 0; - diff --git a/base_layer/wallet/migrations/2021-11-15-101010_add_template_features/down.sql b/base_layer/wallet/migrations/2021-11-15-101010_add_template_features/down.sql deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/base_layer/wallet/migrations/2021-11-15-101010_add_template_features/up.sql b/base_layer/wallet/migrations/2021-11-15-101010_add_template_features/up.sql deleted file mode 100644 index f786ee30b5..0000000000 --- a/base_layer/wallet/migrations/2021-11-15-101010_add_template_features/up.sql +++ /dev/null @@ -1,25 +0,0 @@ --- // Copyright 2021. The Tari Project --- // --- // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the --- // following conditions are met: --- // --- // 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following --- // disclaimer. --- // --- // 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the --- // following disclaimer in the documentation and/or other materials provided with the distribution. --- // --- // 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote --- // products derived from this software without specific prior written permission. --- // --- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, --- // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE --- // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR --- // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, --- // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE --- // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -alter table outputs -add features_json text not null default '{}'; - diff --git a/base_layer/wallet/migrations/2021-12-06-104545_add_block_scanned_cache/down.sql b/base_layer/wallet/migrations/2021-12-06-104545_add_block_scanned_cache/down.sql deleted file mode 100644 index 3ecdf26d20..0000000000 --- a/base_layer/wallet/migrations/2021-12-06-104545_add_block_scanned_cache/down.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS scanned_blocks; \ No newline at end of file diff --git a/base_layer/wallet/migrations/2021-12-06-104545_add_block_scanned_cache/up.sql b/base_layer/wallet/migrations/2021-12-06-104545_add_block_scanned_cache/up.sql deleted file mode 100644 index 60967bf7fb..0000000000 --- a/base_layer/wallet/migrations/2021-12-06-104545_add_block_scanned_cache/up.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE scanned_blocks ( - header_hash BLOB PRIMARY KEY NOT NULL, - height BIGINT NOT NULL, - num_outputs BIGINT NULL, - amount BIGINT NULL, - timestamp DATETIME NOT NULL -); diff --git a/base_layer/wallet/migrations/2022-01-04-110518_add_covenant_to_output/down.sql b/base_layer/wallet/migrations/2022-01-04-110518_add_covenant_to_output/down.sql deleted file mode 100644 index 1efbdb5e9f..0000000000 --- a/base_layer/wallet/migrations/2022-01-04-110518_add_covenant_to_output/down.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE outputs - DROP COLUMN covenant; diff --git a/base_layer/wallet/migrations/2022-01-04-110518_add_covenant_to_output/up.sql b/base_layer/wallet/migrations/2022-01-04-110518_add_covenant_to_output/up.sql deleted file mode 100644 index c30de3e692..0000000000 --- a/base_layer/wallet/migrations/2022-01-04-110518_add_covenant_to_output/up.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE outputs - ADD covenant blob NOT NULL DEFAULT ''; - diff --git a/base_layer/wallet/migrations/2022-02-14-104456_cancellation_column_update/down.sql b/base_layer/wallet/migrations/2022-02-14-104456_cancellation_column_update/down.sql deleted file mode 100644 index 291a97c5ce..0000000000 --- a/base_layer/wallet/migrations/2022-02-14-104456_cancellation_column_update/down.sql +++ /dev/null @@ -1 +0,0 @@ --- This file should undo anything in `up.sql` \ No newline at end of file diff --git a/base_layer/wallet/migrations/2022-02-14-104456_cancellation_column_update/up.sql b/base_layer/wallet/migrations/2022-02-14-104456_cancellation_column_update/up.sql deleted file mode 100644 index e25d452b02..0000000000 --- a/base_layer/wallet/migrations/2022-02-14-104456_cancellation_column_update/up.sql +++ /dev/null @@ -1,60 +0,0 @@ -PRAGMA foreign_keys=OFF; - -ALTER TABLE completed_transactions - RENAME TO completed_transactions_old; - -CREATE TABLE completed_transactions -( - tx_id BIGINT NOT NULL PRIMARY KEY, - source_public_key BLOB NOT NULL, - destination_public_key BLOB NOT NULL, - amount BIGINT NOT NULL, - fee BIGINT NOT NULL, - transaction_protocol TEXT NOT NULL, - status INTEGER NOT NULL, - message TEXT NOT NULL, - timestamp DATETIME NOT NULL, - cancelled INTEGER NULL, - direction INTEGER, - coinbase_block_height BIGINT, - send_count INTEGER default 0 NOT NULL, - last_send_timestamp DATETIME, - confirmations BIGINT default NULL, - mined_height BIGINT, - mined_in_block BLOB, - transaction_signature_nonce BLOB default 0 NOT NULL, - transaction_signature_key BLOB default 0 NOT NULL -); - -INSERT INTO completed_transactions (tx_id, source_public_key, destination_public_key, amount, fee, transaction_protocol, - status, message, timestamp, cancelled, direction, coinbase_block_height, send_count, - last_send_timestamp, confirmations, mined_height, mined_in_block, transaction_signature_nonce, - transaction_signature_key) -SELECT tx_id, - source_public_key, - destination_public_key, - amount, - fee, - transaction_protocol, - status, - message, - timestamp, - CASE completed_transactions_old.valid --This flag was only ever used to signify an abandoned coinbase, we will do that in the cancelled reason enum now - WHEN 0 - THEN 7 -- This is the value for AbandonedCoinbase - ELSE - NULLIF(cancelled, 0) - END, - direction, - coinbase_block_height, - send_count, - last_send_timestamp, - confirmations, - mined_height, - mined_in_block, - transaction_signature_nonce, - transaction_signature_key -FROM completed_transactions_old; - -DROP TABLE completed_transactions_old; -PRAGMA foreign_keys=ON; \ No newline at end of file diff --git a/base_layer/wallet/migrations/2022-02-16-110518_add_last_seen_to_contacts/down.sql b/base_layer/wallet/migrations/2022-02-16-110518_add_last_seen_to_contacts/down.sql deleted file mode 100644 index b53bac2097..0000000000 --- a/base_layer/wallet/migrations/2022-02-16-110518_add_last_seen_to_contacts/down.sql +++ /dev/null @@ -1 +0,0 @@ --- This migration is only meant for fresh databases on a testnet reset, so the down is not needed \ No newline at end of file diff --git a/base_layer/wallet/migrations/2022-02-16-110518_add_last_seen_to_contacts/up.sql b/base_layer/wallet/migrations/2022-02-16-110518_add_last_seen_to_contacts/up.sql deleted file mode 100644 index ecda6bae2d..0000000000 --- a/base_layer/wallet/migrations/2022-02-16-110518_add_last_seen_to_contacts/up.sql +++ /dev/null @@ -1,32 +0,0 @@ --- Copyright 2021. The Tari Project --- --- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the --- following conditions are met: --- --- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following --- disclaimer. --- --- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the --- following disclaimer in the documentation and/or other materials provided with the distribution. --- --- 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote --- products derived from this software without specific prior written permission. --- --- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, --- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE --- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR --- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, --- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE --- USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -PRAGMA foreign_keys=OFF; -DROP TABLE contacts; -CREATE TABLE contacts ( - public_key BLOB PRIMARY KEY NOT NULL UNIQUE, - node_id BLOB NOT NULL UNIQUE, - alias TEXT NOT NULL, - last_seen DATETIME, - latency INTEGER -); -PRAGMA foreign_keys=ON; diff --git a/base_layer/wallet/migrations/2022-02-28-141501_key_manager_unique_index/down.sql b/base_layer/wallet/migrations/2022-02-28-141501_key_manager_unique_index/down.sql deleted file mode 100644 index 291a97c5ce..0000000000 --- a/base_layer/wallet/migrations/2022-02-28-141501_key_manager_unique_index/down.sql +++ /dev/null @@ -1 +0,0 @@ --- This file should undo anything in `up.sql` \ No newline at end of file diff --git a/base_layer/wallet/migrations/2022-02-28-141501_key_manager_unique_index/up.sql b/base_layer/wallet/migrations/2022-02-28-141501_key_manager_unique_index/up.sql deleted file mode 100644 index 44a1b6bc90..0000000000 --- a/base_layer/wallet/migrations/2022-02-28-141501_key_manager_unique_index/up.sql +++ /dev/null @@ -1,12 +0,0 @@ -PRAGMA foreign_keys=OFF; -ALTER TABLE key_manager_states - RENAME TO key_manager_states_old; - -CREATE TABLE key_manager_states ( - id INTEGER PRIMARY KEY NOT NULL, - branch_seed TEXT UNIQUE NOT NULL, - primary_key_index BLOB NOT NULL, - timestamp DATETIME NOT NULL -); - -PRAGMA foreign_keys=ON; diff --git a/base_layer/wallet/migrations/2022-03-03-084134_add_recovery_byte/down.sql b/base_layer/wallet/migrations/2022-03-03-084134_add_recovery_byte/down.sql deleted file mode 100644 index d9a93fe9a1..0000000000 --- a/base_layer/wallet/migrations/2022-03-03-084134_add_recovery_byte/down.sql +++ /dev/null @@ -1 +0,0 @@ --- This file should undo anything in `up.sql` diff --git a/base_layer/wallet/migrations/2022-03-03-084134_add_recovery_byte/up.sql b/base_layer/wallet/migrations/2022-03-03-084134_add_recovery_byte/up.sql deleted file mode 100644 index 90664692b9..0000000000 --- a/base_layer/wallet/migrations/2022-03-03-084134_add_recovery_byte/up.sql +++ /dev/null @@ -1,58 +0,0 @@ -PRAGMA foreign_keys=OFF; - -ALTER TABLE outputs - RENAME TO outputs_old; - -CREATE TABLE outputs -( - id INTEGER NOT NULL PRIMARY KEY, --auto inc, - commitment BLOB NULL, - spending_key BLOB NOT NULL, - value BIGINT NOT NULL, - flags INTEGER NOT NULL, - maturity BIGINT NOT NULL, - recovery_byte INTEGER NOT NULL DEFAULT 0, - status INTEGER NOT NULL, - hash BLOB NULL, - script BLOB NOT NULL, - input_data BLOB NOT NULL, - script_private_key BLOB NOT NULL, - script_lock_height UNSIGNED BIGINT NOT NULL DEFAULT 0, - sender_offset_public_key BLOB NOT NULL, - metadata_signature_nonce BLOB NOT NULL, - metadata_signature_u_key BLOB NOT NULL, - metadata_signature_v_key BLOB NOT NULL, - mined_height UNSIGNED BIGINT NULL, - mined_in_block BLOB NULL, - mined_mmr_position BIGINT NULL, - marked_deleted_at_height BIGINT, - marked_deleted_in_block BLOB, - received_in_tx_id BIGINT, - spent_in_tx_id BIGINT, - coinbase_block_height UNSIGNED BIGINT NULL, - metadata BLOB, - features_parent_public_key BLOB, - features_unique_id BLOB, - features_json TEXT NOT NULL DEFAULT '{}', - spending_priority UNSIGNED Integer NOT NULL DEFAULT 500, - covenant BLOB NOT NULL DEFAULT '', - CONSTRAINT unique_commitment UNIQUE (commitment) -); - -INSERT INTO outputs -( - id, commitment, spending_key, value, flags, maturity, recovery_byte, status, hash, script, input_data, - script_private_key, script_lock_height, sender_offset_public_key, metadata_signature_nonce, - metadata_signature_u_key, metadata_signature_v_key, mined_height, mined_in_block, mined_mmr_position, - marked_deleted_at_height, marked_deleted_in_block, received_in_tx_id, spent_in_tx_id, coinbase_block_height, - metadata, features_parent_public_key, features_unique_id, features_json, covenant -) -SELECT id, commitment, spending_key, value, flags, maturity, 0, status, hash, script, input_data, - script_private_key, script_lock_height, sender_offset_public_key, metadata_signature_nonce, - metadata_signature_u_key, metadata_signature_v_key, mined_height, mined_in_block, mined_mmr_position, - marked_deleted_at_height, marked_deleted_in_block, received_in_tx_id, spent_in_tx_id, coinbase_block_height, - metadata, features_parent_public_key, features_unique_id, features_json, covenant -FROM outputs_old; - -DROP TABLE outputs_old; -PRAGMA foreign_keys=ON; diff --git a/base_layer/wallet/migrations/2022-05-25-154612_add_encrypted_value/down.sql b/base_layer/wallet/migrations/2022-05-25-154612_add_encrypted_value/down.sql deleted file mode 100644 index d9a93fe9a1..0000000000 --- a/base_layer/wallet/migrations/2022-05-25-154612_add_encrypted_value/down.sql +++ /dev/null @@ -1 +0,0 @@ --- This file should undo anything in `up.sql` diff --git a/base_layer/wallet/migrations/2022-05-25-154612_add_encrypted_value/up.sql b/base_layer/wallet/migrations/2022-05-25-154612_add_encrypted_value/up.sql deleted file mode 100644 index 8983f479a4..0000000000 --- a/base_layer/wallet/migrations/2022-05-25-154612_add_encrypted_value/up.sql +++ /dev/null @@ -1,47 +0,0 @@ -PRAGMA foreign_keys=OFF; - -ALTER TABLE outputs - RENAME TO outputs_old; - -CREATE TABLE outputs -( - id INTEGER NOT NULL PRIMARY KEY, --auto inc, - commitment BLOB NULL, - spending_key BLOB NOT NULL, - value BIGINT NOT NULL, - flags INTEGER NOT NULL, - maturity BIGINT NOT NULL, - recovery_byte INTEGER NOT NULL DEFAULT 0, - status INTEGER NOT NULL, - hash BLOB NULL, - script BLOB NOT NULL, - input_data BLOB NOT NULL, - script_private_key BLOB NOT NULL, - script_lock_height UNSIGNED BIGINT NOT NULL DEFAULT 0, - sender_offset_public_key BLOB NOT NULL, - metadata_signature_nonce BLOB NOT NULL, - metadata_signature_u_key BLOB NOT NULL, - metadata_signature_v_key BLOB NOT NULL, - mined_height UNSIGNED BIGINT NULL, - mined_in_block BLOB NULL, - mined_mmr_position BIGINT NULL, - marked_deleted_at_height BIGINT, - marked_deleted_in_block BLOB, - received_in_tx_id BIGINT, - spent_in_tx_id BIGINT, - coinbase_block_height UNSIGNED BIGINT NULL, - metadata BLOB, - features_parent_public_key BLOB, - features_unique_id BLOB, - features_json TEXT NOT NULL DEFAULT '{}', - spending_priority UNSIGNED Integer NOT NULL DEFAULT 500, - covenant BLOB NOT NULL DEFAULT '', - encrypted_value BLOB NOT NULL, - CONSTRAINT unique_commitment UNIQUE (commitment) -); - -INSERT INTO outputs -SELECT *, NULL -FROM outputs_old; -DROP TABLE outputs_old; -PRAGMA foreign_keys=ON; diff --git a/base_layer/wallet/migrations/2022-06-22-133735_add_contract_id/down.sql b/base_layer/wallet/migrations/2022-06-22-133735_add_contract_id/down.sql deleted file mode 100644 index 83e26d0a29..0000000000 --- a/base_layer/wallet/migrations/2022-06-22-133735_add_contract_id/down.sql +++ /dev/null @@ -1,2 +0,0 @@ -DROP INDEX outputs_contract_id_index; -ALTER TABLE outputs DROP COLUMN contract_id; diff --git a/base_layer/wallet/migrations/2022-06-22-133735_add_contract_id/up.sql b/base_layer/wallet/migrations/2022-06-22-133735_add_contract_id/up.sql deleted file mode 100644 index 1dea687f5b..0000000000 --- a/base_layer/wallet/migrations/2022-06-22-133735_add_contract_id/up.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE outputs - ADD contract_id blob NULL; - -CREATE INDEX outputs_contract_id_index ON outputs (contract_id); \ No newline at end of file diff --git a/base_layer/wallet/migrations/2022-06-22-153811_rename_flags_to_output_type/down.sql b/base_layer/wallet/migrations/2022-06-22-153811_rename_flags_to_output_type/down.sql deleted file mode 100644 index 7d6184acc0..0000000000 --- a/base_layer/wallet/migrations/2022-06-22-153811_rename_flags_to_output_type/down.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE outputs - RENAME COLUMN output_type TO flags; diff --git a/base_layer/wallet/migrations/2022-06-22-153811_rename_flags_to_output_type/up.sql b/base_layer/wallet/migrations/2022-06-22-153811_rename_flags_to_output_type/up.sql deleted file mode 100644 index 7dd8171c09..0000000000 --- a/base_layer/wallet/migrations/2022-06-22-153811_rename_flags_to_output_type/up.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE outputs - RENAME COLUMN flags TO output_type; \ No newline at end of file diff --git a/base_layer/wallet/migrations/2022-07-04-150000_add_mined_timestamp/up.sql b/base_layer/wallet/migrations/2022-07-04-150000_add_mined_timestamp/up.sql deleted file mode 100644 index 5c2870183d..0000000000 --- a/base_layer/wallet/migrations/2022-07-04-150000_add_mined_timestamp/up.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE completed_transactions - ADD mined_timestamp DATETIME NULL; - -ALTER TABLE outputs - ADD mined_timestamp DATETIME NULL; \ No newline at end of file diff --git a/base_layer/wallet/migrations/2022-07-11-142351_remove_recovery_byte/down.sql b/base_layer/wallet/migrations/2022-07-11-142351_remove_recovery_byte/down.sql deleted file mode 100644 index db26b3b027..0000000000 --- a/base_layer/wallet/migrations/2022-07-11-142351_remove_recovery_byte/down.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE outputs DROP COLUMN recovery_byte; diff --git a/base_layer/wallet/migrations/2022-07-11-142351_remove_recovery_byte/up.sql b/base_layer/wallet/migrations/2022-07-11-142351_remove_recovery_byte/up.sql deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/base_layer/wallet/migrations/2022-07-15-214144_add_minimum_value_promise/down.sql b/base_layer/wallet/migrations/2022-07-15-214144_add_minimum_value_promise/down.sql deleted file mode 100644 index 4bdb163c23..0000000000 --- a/base_layer/wallet/migrations/2022-07-15-214144_add_minimum_value_promise/down.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE outputs DROP COLUMN minimum_value_promise; \ No newline at end of file diff --git a/base_layer/wallet/migrations/2022-07-15-214144_add_minimum_value_promise/up.sql b/base_layer/wallet/migrations/2022-07-15-214144_add_minimum_value_promise/up.sql deleted file mode 100644 index 2048ada7c2..0000000000 --- a/base_layer/wallet/migrations/2022-07-15-214144_add_minimum_value_promise/up.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE outputs - ADD minimum_value_promise BIGINT NOT NULL; \ No newline at end of file diff --git a/base_layer/wallet/migrations/2020-10-20-094420_add_client_key_value_store/up.sql b/base_layer/wallet/migrations/2022-08-08_initial/up.sql similarity index 64% rename from base_layer/wallet/migrations/2020-10-20-094420_add_client_key_value_store/up.sql rename to base_layer/wallet/migrations/2022-08-08_initial/up.sql index a01f2132e7..6e61e72bb0 100644 --- a/base_layer/wallet/migrations/2020-10-20-094420_add_client_key_value_store/up.sql +++ b/base_layer/wallet/migrations/2022-08-08_initial/up.sql @@ -1,4 +1,4 @@ CREATE TABLE client_key_values ( key TEXT PRIMARY KEY NOT NULL, - value TEXT NOT NULL -); + value TEXT NOT NULL, +) \ No newline at end of file From 3490b47680f4db1f7707e4a020fb8ea32e4fff80 Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 8 Aug 2022 09:52:29 +0100 Subject: [PATCH 03/23] add state --- .../wallet/migrations/2022-08-08_initial/up.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/base_layer/wallet/migrations/2022-08-08_initial/up.sql b/base_layer/wallet/migrations/2022-08-08_initial/up.sql index 6e61e72bb0..ebc8a6b55d 100644 --- a/base_layer/wallet/migrations/2022-08-08_initial/up.sql +++ b/base_layer/wallet/migrations/2022-08-08_initial/up.sql @@ -1,4 +1,17 @@ CREATE TABLE client_key_values ( key TEXT PRIMARY KEY NOT NULL, value TEXT NOT NULL, +) + +CREATE TABLE completed_transactions ( + tx_id BIGINT PRIMARY KEY NOT NULL, + source_public_key BLOB NOT NULL, + destination_public_key BLOB NOT NULL, + amount BIGINT NOT NULL, + fee BIGINT NOT NULL, + transaction_protocol TEXT NOT NULL, + status INTEGER NOT NULL, + message TEXT NOT NULL, + timestamp DATETIME NOT NULL, + ) \ No newline at end of file From 0b7dbe167dd34c8d0e4612669280a84adc173d5b Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 8 Aug 2022 09:56:23 +0100 Subject: [PATCH 04/23] add changes --- base_layer/wallet/migrations/2022-08-08_initial/up.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/base_layer/wallet/migrations/2022-08-08_initial/up.sql b/base_layer/wallet/migrations/2022-08-08_initial/up.sql index ebc8a6b55d..2e3777a243 100644 --- a/base_layer/wallet/migrations/2022-08-08_initial/up.sql +++ b/base_layer/wallet/migrations/2022-08-08_initial/up.sql @@ -13,5 +13,6 @@ CREATE TABLE completed_transactions ( status INTEGER NOT NULL, message TEXT NOT NULL, timestamp DATETIME NOT NULL, - + cancelled + ) \ No newline at end of file From 087631690631c7f681f5c819922d04be16324a7d Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 8 Aug 2022 10:12:14 +0100 Subject: [PATCH 05/23] add contacts table --- .../migrations/2022-08-08_initial/up.sql | 40 ++++++++++++++----- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/base_layer/wallet/migrations/2022-08-08_initial/up.sql b/base_layer/wallet/migrations/2022-08-08_initial/up.sql index 2e3777a243..6e6cdac06c 100644 --- a/base_layer/wallet/migrations/2022-08-08_initial/up.sql +++ b/base_layer/wallet/migrations/2022-08-08_initial/up.sql @@ -4,15 +4,33 @@ CREATE TABLE client_key_values ( ) CREATE TABLE completed_transactions ( - tx_id BIGINT PRIMARY KEY NOT NULL, - source_public_key BLOB NOT NULL, - destination_public_key BLOB NOT NULL, - amount BIGINT NOT NULL, - fee BIGINT NOT NULL, - transaction_protocol TEXT NOT NULL, - status INTEGER NOT NULL, - message TEXT NOT NULL, - timestamp DATETIME NOT NULL, - cancelled + tx_id BIGINT PRIMARY KEY NOT NULL, + source_public_key BLOB NOT NULL, + destination_public_key BLOB NOT NULL, + amount BIGINT NOT NULL, + fee BIGINT NOT NULL, + transaction_protocol TEXT NOT NULL, + status INTEGER NOT NULL, + message TEXT NOT NULL, + timestamp DATETIME NOT NULL, + cancelled INTEGER, + direction INTEGER, + coinbase_block_height BIGINT, + send_count INTEGER default 0 NOT NULL, + last_send_timestamp DATETIME, + confirmations BIGINT, + mined_height BIGINT, + mined_in_block BLOB, + mined_timestamp DATETIME, + transaction_signature_nonce BLOB default 0 NOT NULL, + transaction_signature_key BLOB default 0 NOT NULL, +) + +CREATE TABLE contacts ( + public_key BLOB PRIMARY KEY NOT NULL, + node_id BLOB NOT NULL, + alias TEXT NOT NULL, + last_seen DATETIME, + latency INTEGER, +) -) \ No newline at end of file From 861e93b1cd501d22f4f4437fd7d5583ab00c3f7f Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 8 Aug 2022 10:22:13 +0100 Subject: [PATCH 06/23] add inbound_transactions and key_manager_states SQL queries --- .../migrations/2022-08-08_initial/up.sql | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/base_layer/wallet/migrations/2022-08-08_initial/up.sql b/base_layer/wallet/migrations/2022-08-08_initial/up.sql index 6e6cdac06c..1677f0ac26 100644 --- a/base_layer/wallet/migrations/2022-08-08_initial/up.sql +++ b/base_layer/wallet/migrations/2022-08-08_initial/up.sql @@ -27,10 +27,29 @@ CREATE TABLE completed_transactions ( ) CREATE TABLE contacts ( - public_key BLOB PRIMARY KEY NOT NULL, - node_id BLOB NOT NULL, + public_key BLOB PRIMARY KEY NOT NULL UNIQUE, + node_id BLOB NOT NULL UNIQUE, alias TEXT NOT NULL, last_seen DATETIME, latency INTEGER, ) +CREATE TABLE inbound_transactions ( + tx_id BIGINT PRIMARY KEY NOT NULL, + source_public_key BLOB NOT NULL, + amount BIGINT NOT NULL, + receiver_protocol TEXT NOT NULL, + message TEXT NOT NULL, + timestamp DATETIME NOT NULL, + cancelled INTEGER NOT NULL, + direct_send_success INTEGER NOT NULL, + send_count INTEGER NOT NULL, + last_send_timestamp TIMESTAMP, +) + +CREATE TABLE key_manager_states ( + id INTEGER PRIMARY KEY NOT NULL, + branch_seed TEXT NOT NULL, + primary_key_index BLOB NOT NULL, + timestamp DATETIME NOT NULL, +) \ No newline at end of file From 0665b4234cd3452cf59a46fccdba1d1deca3e2ae Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 8 Aug 2022 10:25:13 +0100 Subject: [PATCH 07/23] add changes --- base_layer/wallet/migrations/2022-08-08_initial/up.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/base_layer/wallet/migrations/2022-08-08_initial/up.sql b/base_layer/wallet/migrations/2022-08-08_initial/up.sql index 1677f0ac26..98664d8a50 100644 --- a/base_layer/wallet/migrations/2022-08-08_initial/up.sql +++ b/base_layer/wallet/migrations/2022-08-08_initial/up.sql @@ -42,9 +42,9 @@ CREATE TABLE inbound_transactions ( message TEXT NOT NULL, timestamp DATETIME NOT NULL, cancelled INTEGER NOT NULL, - direct_send_success INTEGER NOT NULL, - send_count INTEGER NOT NULL, - last_send_timestamp TIMESTAMP, + direct_send_success INTEGER default 0 NOT NULL, + send_count INTEGER default 0 NOT NULL, + last_send_timestamp DATETIME, ) CREATE TABLE key_manager_states ( From 9e381d6bfa4d2f585ecbbcd147b23326971db218 Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 8 Aug 2022 10:34:43 +0100 Subject: [PATCH 08/23] add sql query for key_manager_states_old --- base_layer/wallet/migrations/2022-08-08_initial/up.sql | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/base_layer/wallet/migrations/2022-08-08_initial/up.sql b/base_layer/wallet/migrations/2022-08-08_initial/up.sql index 98664d8a50..c281d30342 100644 --- a/base_layer/wallet/migrations/2022-08-08_initial/up.sql +++ b/base_layer/wallet/migrations/2022-08-08_initial/up.sql @@ -49,7 +49,15 @@ CREATE TABLE inbound_transactions ( CREATE TABLE key_manager_states ( id INTEGER PRIMARY KEY NOT NULL, - branch_seed TEXT NOT NULL, + branch_seed TEXT UNIQUE NOT NULL, primary_key_index BLOB NOT NULL, timestamp DATETIME NOT NULL, +) + +CREATE TABLE key_manager_states_old ( + id BIGINT PRIMARY KEY NOT NULL, + seed BLOB NOT NULL, + branch_seed TEXT NOT NULL, + primary_key_index BIGINT NOT NULL, + timestamp DATETIME NOT NULL, ) \ No newline at end of file From 219bc65263ef2c8b4ca4570da7194100bfc86655 Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 8 Aug 2022 11:12:37 +0100 Subject: [PATCH 09/23] add reamining tables queries --- .../migrations/2022-08-08_initial/up.sql | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/base_layer/wallet/migrations/2022-08-08_initial/up.sql b/base_layer/wallet/migrations/2022-08-08_initial/up.sql index c281d30342..25f7f338d3 100644 --- a/base_layer/wallet/migrations/2022-08-08_initial/up.sql +++ b/base_layer/wallet/migrations/2022-08-08_initial/up.sql @@ -60,4 +60,76 @@ CREATE TABLE key_manager_states_old ( branch_seed TEXT NOT NULL, primary_key_index BIGINT NOT NULL, timestamp DATETIME NOT NULL, +) + +CREATE TABLE known_one_sided_payment_scripts ( + script_hash BLOB PRIMARY KEY NOT NULL, + private_key BLOB NOT NULL, + script BLOB NOT NULL, + input BLOB NOT NULL, + script_lock_height BLOB NOT NULL, +) + +CREATE TABLE outbount_transactions ( + tx_id BIGINT PRIMARY KEY NOT NULL, + destination_public_key BLOB NOT NULL, + amount BIGINT NOT NULL, + fee BIGINT NOT NULL, + sender_protocol TEXT NOT NULL, + message TEXT NOT NULL, + timestamp DATETIME NOT NULL, + cancelled INTEGER NOT NULL, + direct_send_success INTEGER NOT NULL, + send_count INTEGER NOT NULL, + last_send_timestamp DATETIME NOT NULL, +) + +CREATE TABLE outputs ( + id INTEGER PRIMARY KEY NOT NULL, + commitment BLOB, + spending_key BLOB NOT NULL, + value BIGINT NOT NULL, + output_type INTEGER NOT NULL, + maturity BIGINT NOT NULL, + status INTEGER NOT NULL, + hash BLOB, + script BLOB NOT NULL, + input_data BLOB NOT NULL, + script_private_key BLOB NOT NULL, + script_lock_height BIGINT NOT NULL, + sender_offset_public_key BLOB NOT NULL, + metadata_signature_nonce BLOB NOT NULL, + metadata_signature_y_key BLOB NOT NULL, + metadata_signature_v_key BLOB NOT NULL, + mined_height BIGINT, + mined_in_block BLOB, + mined_mmr_position BLOB, + marked_deleted_at_height BIGINT, + marked_deleted_in_block BLOB, + received_in_tx_id BIGINT, + spent_in_tx_id BIGINT, + coinbase_block_height BIGINT, + metadata BLOB, + features_parent_public_key BLOB, + features_unique_id BLOB, + features_json TEXT NOT NULL, + spending_priority INTEGER NOT NULL, + covenant BLOB NOT NULL, + mined_timestamp DATETIME, + encrypted_value BLOB NOT NULL, + contract_id BLOB, + minimum_value_precision BIGINT NOT NULL, +) + +CREATE TABLE scanned_blocks ( + header_hash BLOB PRIMARY KEY NOT NULL, + height BIGINT NOT NULL, + num_outputs BIGINT, + amount BIGINT, + timestamp DATETIME NOT NULL, +) + +CREATE TABLE wallet_settings ( + key TEXT PRIMARY KEY NOT NULL, + value TEXT NOT NULL, ) \ No newline at end of file From dd7dc11ca000957c62f335a13207c3b1f3017292 Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 8 Aug 2022 11:15:02 +0100 Subject: [PATCH 10/23] add changes --- .../wallet/migrations/2022-08-08_initial/up.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/base_layer/wallet/migrations/2022-08-08_initial/up.sql b/base_layer/wallet/migrations/2022-08-08_initial/up.sql index 25f7f338d3..5f38887782 100644 --- a/base_layer/wallet/migrations/2022-08-08_initial/up.sql +++ b/base_layer/wallet/migrations/2022-08-08_initial/up.sql @@ -16,14 +16,14 @@ CREATE TABLE completed_transactions ( cancelled INTEGER, direction INTEGER, coinbase_block_height BIGINT, - send_count INTEGER default 0 NOT NULL, + send_count INTEGER DEFAULT 0 NOT NULL, last_send_timestamp DATETIME, confirmations BIGINT, mined_height BIGINT, mined_in_block BLOB, mined_timestamp DATETIME, - transaction_signature_nonce BLOB default 0 NOT NULL, - transaction_signature_key BLOB default 0 NOT NULL, + transaction_signature_nonce BLOB DEFAULT 0 NOT NULL, + transaction_signature_key BLOB DEFAULT 0 NOT NULL, ) CREATE TABLE contacts ( @@ -42,8 +42,8 @@ CREATE TABLE inbound_transactions ( message TEXT NOT NULL, timestamp DATETIME NOT NULL, cancelled INTEGER NOT NULL, - direct_send_success INTEGER default 0 NOT NULL, - send_count INTEGER default 0 NOT NULL, + direct_send_success INTEGER DEFAULT 0 NOT NULL, + send_count INTEGER DEFAULT 0 NOT NULL, last_send_timestamp DATETIME, ) @@ -67,7 +67,7 @@ CREATE TABLE known_one_sided_payment_scripts ( private_key BLOB NOT NULL, script BLOB NOT NULL, input BLOB NOT NULL, - script_lock_height BLOB NOT NULL, + script_lock_height UNSIGNED BIGINT NOT NULL DEFAULT 0 ) CREATE TABLE outbount_transactions ( From 2511121a335f10a3201f3ffb57d52310dc88cdbb Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 8 Aug 2022 11:18:40 +0100 Subject: [PATCH 11/23] add changes to table outbound_transactions --- base_layer/wallet/migrations/2022-08-08_initial/up.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/base_layer/wallet/migrations/2022-08-08_initial/up.sql b/base_layer/wallet/migrations/2022-08-08_initial/up.sql index 5f38887782..f228448206 100644 --- a/base_layer/wallet/migrations/2022-08-08_initial/up.sql +++ b/base_layer/wallet/migrations/2022-08-08_initial/up.sql @@ -70,7 +70,7 @@ CREATE TABLE known_one_sided_payment_scripts ( script_lock_height UNSIGNED BIGINT NOT NULL DEFAULT 0 ) -CREATE TABLE outbount_transactions ( +CREATE TABLE outbound_transactions ( tx_id BIGINT PRIMARY KEY NOT NULL, destination_public_key BLOB NOT NULL, amount BIGINT NOT NULL, @@ -78,9 +78,9 @@ CREATE TABLE outbount_transactions ( sender_protocol TEXT NOT NULL, message TEXT NOT NULL, timestamp DATETIME NOT NULL, - cancelled INTEGER NOT NULL, - direct_send_success INTEGER NOT NULL, - send_count INTEGER NOT NULL, + cancelled INTEGER DEFAULT 0 NOT NULL, + direct_send_success INTEGER DEFAULT 0 NOT NULL, + send_count INTEGER DEFAULT 0 NOT NULL, last_send_timestamp DATETIME NOT NULL, ) From 04a0e09f4b9ab3121c078f5f31db9c3dd6b0e911 Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 8 Aug 2022 11:24:59 +0100 Subject: [PATCH 12/23] add changes to outputs table --- .../migrations/2022-08-08_initial/up.sql | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/base_layer/wallet/migrations/2022-08-08_initial/up.sql b/base_layer/wallet/migrations/2022-08-08_initial/up.sql index f228448206..faf28a9621 100644 --- a/base_layer/wallet/migrations/2022-08-08_initial/up.sql +++ b/base_layer/wallet/migrations/2022-08-08_initial/up.sql @@ -13,15 +13,15 @@ CREATE TABLE completed_transactions ( status INTEGER NOT NULL, message TEXT NOT NULL, timestamp DATETIME NOT NULL, - cancelled INTEGER, - direction INTEGER, - coinbase_block_height BIGINT, + cancelled INTEGER NULL, + direction INTEGER NULL, + coinbase_block_height BIGINT NULL, send_count INTEGER DEFAULT 0 NOT NULL, - last_send_timestamp DATETIME, - confirmations BIGINT, - mined_height BIGINT, - mined_in_block BLOB, - mined_timestamp DATETIME, + last_send_timestamp DATETIME NULL, + confirmations BIGINT NULL, + mined_height BIGINT NULL, + mined_in_block BLOB NULL, + mined_timestamp DATETIME NULL, transaction_signature_nonce BLOB DEFAULT 0 NOT NULL, transaction_signature_key BLOB DEFAULT 0 NOT NULL, ) @@ -30,8 +30,8 @@ CREATE TABLE contacts ( public_key BLOB PRIMARY KEY NOT NULL UNIQUE, node_id BLOB NOT NULL UNIQUE, alias TEXT NOT NULL, - last_seen DATETIME, - latency INTEGER, + last_seen DATETIME NULL, + latency INTEGER NULL, ) CREATE TABLE inbound_transactions ( @@ -44,7 +44,7 @@ CREATE TABLE inbound_transactions ( cancelled INTEGER NOT NULL, direct_send_success INTEGER DEFAULT 0 NOT NULL, send_count INTEGER DEFAULT 0 NOT NULL, - last_send_timestamp DATETIME, + last_send_timestamp DATETIME NULL, ) CREATE TABLE key_manager_states ( @@ -86,46 +86,46 @@ CREATE TABLE outbound_transactions ( CREATE TABLE outputs ( id INTEGER PRIMARY KEY NOT NULL, - commitment BLOB, + commitment BLOB NULL, spending_key BLOB NOT NULL, value BIGINT NOT NULL, output_type INTEGER NOT NULL, maturity BIGINT NOT NULL, status INTEGER NOT NULL, - hash BLOB, + hash BLOB NULL, script BLOB NOT NULL, input_data BLOB NOT NULL, script_private_key BLOB NOT NULL, script_lock_height BIGINT NOT NULL, sender_offset_public_key BLOB NOT NULL, metadata_signature_nonce BLOB NOT NULL, - metadata_signature_y_key BLOB NOT NULL, + metadata_signature_u_key BLOB NOT NULL, metadata_signature_v_key BLOB NOT NULL, - mined_height BIGINT, - mined_in_block BLOB, - mined_mmr_position BLOB, - marked_deleted_at_height BIGINT, - marked_deleted_in_block BLOB, - received_in_tx_id BIGINT, - spent_in_tx_id BIGINT, - coinbase_block_height BIGINT, - metadata BLOB, - features_parent_public_key BLOB, - features_unique_id BLOB, + mined_height BIGINT NULL, + mined_in_block BLOB NULL, + mined_mmr_position BLOB NULL, + marked_deleted_at_height BIGINT NULL, + marked_deleted_in_block BLOB NULL, + received_in_tx_id BIGINT NULL, + spent_in_tx_id BIGINT NULL, + coinbase_block_height BIGINT NULL, + metadata BLOB NULL, + features_parent_public_key BLOB NULL, + features_unique_id BLOB NULL, features_json TEXT NOT NULL, spending_priority INTEGER NOT NULL, covenant BLOB NOT NULL, - mined_timestamp DATETIME, + mined_timestamp DATETIME NULL, encrypted_value BLOB NOT NULL, - contract_id BLOB, + contract_id BLOB NULL, minimum_value_precision BIGINT NOT NULL, ) CREATE TABLE scanned_blocks ( header_hash BLOB PRIMARY KEY NOT NULL, height BIGINT NOT NULL, - num_outputs BIGINT, - amount BIGINT, + num_outputs BIGINT NULL, + amount BIGINT NULL, timestamp DATETIME NOT NULL, ) From fc2145864fe6a6b568d93d6e092f967e9b3d87db Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 8 Aug 2022 11:33:31 +0100 Subject: [PATCH 13/23] add changes to outputs table --- .../wallet/migrations/2022-08-08_initial/up.sql | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/base_layer/wallet/migrations/2022-08-08_initial/up.sql b/base_layer/wallet/migrations/2022-08-08_initial/up.sql index faf28a9621..6281af0585 100644 --- a/base_layer/wallet/migrations/2022-08-08_initial/up.sql +++ b/base_layer/wallet/migrations/2022-08-08_initial/up.sql @@ -96,29 +96,30 @@ CREATE TABLE outputs ( script BLOB NOT NULL, input_data BLOB NOT NULL, script_private_key BLOB NOT NULL, - script_lock_height BIGINT NOT NULL, + script_lock_height UNSIGNED BIGINT NOT NULL DEFAULT 0, sender_offset_public_key BLOB NOT NULL, metadata_signature_nonce BLOB NOT NULL, metadata_signature_u_key BLOB NOT NULL, metadata_signature_v_key BLOB NOT NULL, - mined_height BIGINT NULL, + mined_height UNSIGNED BIGINT NULL, mined_in_block BLOB NULL, - mined_mmr_position BLOB NULL, + mined_mmr_position BIGINT NULL, marked_deleted_at_height BIGINT NULL, marked_deleted_in_block BLOB NULL, received_in_tx_id BIGINT NULL, spent_in_tx_id BIGINT NULL, - coinbase_block_height BIGINT NULL, + coinbase_block_height UNSIGNED BIGINT NULL, metadata BLOB NULL, features_parent_public_key BLOB NULL, features_unique_id BLOB NULL, - features_json TEXT NOT NULL, - spending_priority INTEGER NOT NULL, + features_json TEXT NOT NULL DEFAULT '{}', + spending_priority UNSIGNED INTEGER NOT NULL DEFAULT 500, covenant BLOB NOT NULL, mined_timestamp DATETIME NULL, encrypted_value BLOB NOT NULL, contract_id BLOB NULL, minimum_value_precision BIGINT NOT NULL, + CONSTRAINT unique_commitment UNIQUE (commitment) ) CREATE TABLE scanned_blocks ( From a228be15e0670712136a606c0714c69fff4df35b Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 8 Aug 2022 11:48:32 +0100 Subject: [PATCH 14/23] refactor outbount_transactions table --- base_layer/wallet/migrations/2022-08-08_initial/up.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base_layer/wallet/migrations/2022-08-08_initial/up.sql b/base_layer/wallet/migrations/2022-08-08_initial/up.sql index 6281af0585..e4dddffafb 100644 --- a/base_layer/wallet/migrations/2022-08-08_initial/up.sql +++ b/base_layer/wallet/migrations/2022-08-08_initial/up.sql @@ -81,7 +81,7 @@ CREATE TABLE outbound_transactions ( cancelled INTEGER DEFAULT 0 NOT NULL, direct_send_success INTEGER DEFAULT 0 NOT NULL, send_count INTEGER DEFAULT 0 NOT NULL, - last_send_timestamp DATETIME NOT NULL, + last_send_timestamp DATETIME NULL, ) CREATE TABLE outputs ( From f4b049e16266429bd8d466322cc2c353f084ef92 Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 8 Aug 2022 12:09:00 +0100 Subject: [PATCH 15/23] add changes --- base_layer/core/src/transactions/coinbase_builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base_layer/core/src/transactions/coinbase_builder.rs b/base_layer/core/src/transactions/coinbase_builder.rs index 5b984352cf..0b55b78e6d 100644 --- a/base_layer/core/src/transactions/coinbase_builder.rs +++ b/base_layer/core/src/transactions/coinbase_builder.rs @@ -205,7 +205,7 @@ impl CoinbaseBuilder { let sig = Signature::sign(spending_key.clone(), nonce, &challenge) .map_err(|_| CoinbaseBuildError::BuildError("Challenge could not be represented as a scalar".into()))?; - let sender_offset_private_key = PrivateKey::from_bytes(Blake256::digest(spending_key)); // H(spending_key) <- Blake256 + let sender_offset_private_key = PrivateKey::random(&mut OsRng); let sender_offset_public_key = PublicKey::from_secret_key(&sender_offset_private_key); let covenant = self.covenant; From aa225a474a69c0cf0ad02f203c1de853063742b2 Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 8 Aug 2022 12:15:51 +0100 Subject: [PATCH 16/23] sync with dev --- base_layer/core/src/transactions/coinbase_builder.rs | 2 +- .../wallet/src/output_manager_service/service.rs | 4 ++-- .../output_manager_service/storage/database/backend.rs | 4 ++-- .../src/output_manager_service/storage/database/mod.rs | 6 +++--- .../output_manager_service/storage/sqlite_db/mod.rs | 8 ++++---- .../storage/sqlite_db/output_sql.rs | 10 ---------- 6 files changed, 12 insertions(+), 22 deletions(-) diff --git a/base_layer/core/src/transactions/coinbase_builder.rs b/base_layer/core/src/transactions/coinbase_builder.rs index 5b984352cf..0b55b78e6d 100644 --- a/base_layer/core/src/transactions/coinbase_builder.rs +++ b/base_layer/core/src/transactions/coinbase_builder.rs @@ -205,7 +205,7 @@ impl CoinbaseBuilder { let sig = Signature::sign(spending_key.clone(), nonce, &challenge) .map_err(|_| CoinbaseBuildError::BuildError("Challenge could not be represented as a scalar".into()))?; - let sender_offset_private_key = PrivateKey::from_bytes(Blake256::digest(spending_key)); // H(spending_key) <- Blake256 + let sender_offset_private_key = PrivateKey::random(&mut OsRng); let sender_offset_public_key = PublicKey::from_secret_key(&sender_offset_private_key); let covenant = self.covenant; diff --git a/base_layer/wallet/src/output_manager_service/service.rs b/base_layer/wallet/src/output_manager_service/service.rs index 9e8395c57a..97bdfd64a3 100644 --- a/base_layer/wallet/src/output_manager_service/service.rs +++ b/base_layer/wallet/src/output_manager_service/service.rs @@ -1014,12 +1014,12 @@ where match self .resources .db - .clear_pending_coinbase_transaction_with_hash(output.hash.as_slice()) + .clear_pending_coinbase_transaction_at_block_height(block_height) { Ok(_) => { debug!( target: LOG_TARGET, - "An existing pending coinbase was cleared with hash {}", output.hash.to_hex() + "An existing pending coinbase was cleared for block height {}", block_height ) }, Err(e) => match e { diff --git a/base_layer/wallet/src/output_manager_service/storage/database/backend.rs b/base_layer/wallet/src/output_manager_service/storage/database/backend.rs index e3a7cad923..4527e1b561 100644 --- a/base_layer/wallet/src/output_manager_service/storage/database/backend.rs +++ b/base_layer/wallet/src/output_manager_service/storage/database/backend.rs @@ -97,9 +97,9 @@ pub trait OutputManagerBackend: Send + Sync + Clone { /// Get the output that was most recently spent, ordered descending by mined height fn get_last_spent_output(&self) -> Result, OutputManagerStorageError>; /// Check if there is a pending coinbase transaction at this block height, if there is clear it. - fn clear_pending_coinbase_transaction_with_hash( + fn clear_pending_coinbase_transaction_at_block_height( &self, - hash: &[u8], + block_height: u64, ) -> Result<(), OutputManagerStorageError>; /// Set if a coinbase output is abandoned or not fn set_coinbase_abandoned(&self, tx_id: TxId, abandoned: bool) -> Result<(), OutputManagerStorageError>; diff --git a/base_layer/wallet/src/output_manager_service/storage/database/mod.rs b/base_layer/wallet/src/output_manager_service/storage/database/mod.rs index d5af1bcbae..91c15e1bbb 100644 --- a/base_layer/wallet/src/output_manager_service/storage/database/mod.rs +++ b/base_layer/wallet/src/output_manager_service/storage/database/mod.rs @@ -220,11 +220,11 @@ where T: OutputManagerBackend + 'static } /// Check if there is a pending coinbase transaction at this block height, if there is clear it. - pub fn clear_pending_coinbase_transaction_with_hash( + pub fn clear_pending_coinbase_transaction_at_block_height( &self, - hash: &[u8], + block_height: u64, ) -> Result<(), OutputManagerStorageError> { - self.db.clear_pending_coinbase_transaction_with_hash(hash) + self.db.clear_pending_coinbase_transaction_at_block_height(block_height) } pub fn fetch_all_unspent_outputs(&self) -> Result, OutputManagerStorageError> { diff --git a/base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs b/base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs index 9fab53d2d1..73af04cd9c 100644 --- a/base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs +++ b/base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs @@ -1074,21 +1074,21 @@ impl OutputManagerBackend for OutputManagerSqliteDatabase { Ok(()) } - fn clear_pending_coinbase_transaction_with_hash( + fn clear_pending_coinbase_transaction_at_block_height( &self, - hash: &[u8], + block_height: u64, ) -> Result<(), OutputManagerStorageError> { let start = Instant::now(); let conn = self.database_connection.get_pooled_connection()?; let acquire_lock = start.elapsed(); - let output = OutputSql::find_pending_coinbase_with_hash(hash, &conn)?; + let output = OutputSql::find_pending_coinbase_at_block_height(block_height, &conn)?; output.delete(&conn)?; if start.elapsed().as_millis() > 0 { trace!( target: LOG_TARGET, - "sqlite profile - clear_pending_coinbase_transaction_with_hash: lock {} + db_op {} = {} ms", + "sqlite profile - clear_pending_coinbase_transaction_at_block_height: lock {} + db_op {} = {} ms", acquire_lock.as_millis(), (start.elapsed() - acquire_lock).as_millis(), start.elapsed().as_millis() diff --git a/base_layer/wallet/src/output_manager_service/storage/sqlite_db/output_sql.rs b/base_layer/wallet/src/output_manager_service/storage/sqlite_db/output_sql.rs index cfedab1288..8e6cbdd476 100644 --- a/base_layer/wallet/src/output_manager_service/storage/sqlite_db/output_sql.rs +++ b/base_layer/wallet/src/output_manager_service/storage/sqlite_db/output_sql.rs @@ -576,16 +576,6 @@ impl OutputSql { .first::(conn)?) } - pub fn find_pending_coinbase_with_hash( - hash: &[u8], - conn: &SqliteConnection, - ) -> Result { - Ok(outputs::table - .filter(outputs::status.ne(OutputStatus::Unspent as i32)) - .filter(outputs::hash.eq(Some(hash))) - .first::(conn)?) - } - /// Find a particular Output, if it exists and is in the specified Spent state pub fn find_pending_coinbase_at_block_height( block_height: u64, From 7b6f3c5919ee49701bbe21a4fc24463d133c5e52 Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 8 Aug 2022 13:45:25 +0100 Subject: [PATCH 17/23] add down.sql --- .../2022-08-08-134037_initial/down.sql | 0 .../up.sql | 30 +++++++------------ 2 files changed, 11 insertions(+), 19 deletions(-) create mode 100644 base_layer/wallet/migrations/2022-08-08-134037_initial/down.sql rename base_layer/wallet/migrations/{2022-08-08_initial => 2022-08-08-134037_initial}/up.sql (93%) diff --git a/base_layer/wallet/migrations/2022-08-08-134037_initial/down.sql b/base_layer/wallet/migrations/2022-08-08-134037_initial/down.sql new file mode 100644 index 0000000000..e69de29bb2 diff --git a/base_layer/wallet/migrations/2022-08-08_initial/up.sql b/base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql similarity index 93% rename from base_layer/wallet/migrations/2022-08-08_initial/up.sql rename to base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql index e4dddffafb..7f2184bd5d 100644 --- a/base_layer/wallet/migrations/2022-08-08_initial/up.sql +++ b/base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql @@ -1,7 +1,7 @@ CREATE TABLE client_key_values ( key TEXT PRIMARY KEY NOT NULL, value TEXT NOT NULL, -) +); CREATE TABLE completed_transactions ( tx_id BIGINT PRIMARY KEY NOT NULL, @@ -24,7 +24,7 @@ CREATE TABLE completed_transactions ( mined_timestamp DATETIME NULL, transaction_signature_nonce BLOB DEFAULT 0 NOT NULL, transaction_signature_key BLOB DEFAULT 0 NOT NULL, -) +); CREATE TABLE contacts ( public_key BLOB PRIMARY KEY NOT NULL UNIQUE, @@ -32,7 +32,7 @@ CREATE TABLE contacts ( alias TEXT NOT NULL, last_seen DATETIME NULL, latency INTEGER NULL, -) +); CREATE TABLE inbound_transactions ( tx_id BIGINT PRIMARY KEY NOT NULL, @@ -45,22 +45,14 @@ CREATE TABLE inbound_transactions ( direct_send_success INTEGER DEFAULT 0 NOT NULL, send_count INTEGER DEFAULT 0 NOT NULL, last_send_timestamp DATETIME NULL, -) +); CREATE TABLE key_manager_states ( id INTEGER PRIMARY KEY NOT NULL, branch_seed TEXT UNIQUE NOT NULL, primary_key_index BLOB NOT NULL, timestamp DATETIME NOT NULL, -) - -CREATE TABLE key_manager_states_old ( - id BIGINT PRIMARY KEY NOT NULL, - seed BLOB NOT NULL, - branch_seed TEXT NOT NULL, - primary_key_index BIGINT NOT NULL, - timestamp DATETIME NOT NULL, -) +); CREATE TABLE known_one_sided_payment_scripts ( script_hash BLOB PRIMARY KEY NOT NULL, @@ -68,7 +60,7 @@ CREATE TABLE known_one_sided_payment_scripts ( script BLOB NOT NULL, input BLOB NOT NULL, script_lock_height UNSIGNED BIGINT NOT NULL DEFAULT 0 -) +); CREATE TABLE outbound_transactions ( tx_id BIGINT PRIMARY KEY NOT NULL, @@ -82,7 +74,7 @@ CREATE TABLE outbound_transactions ( direct_send_success INTEGER DEFAULT 0 NOT NULL, send_count INTEGER DEFAULT 0 NOT NULL, last_send_timestamp DATETIME NULL, -) +); CREATE TABLE outputs ( id INTEGER PRIMARY KEY NOT NULL, @@ -119,8 +111,8 @@ CREATE TABLE outputs ( encrypted_value BLOB NOT NULL, contract_id BLOB NULL, minimum_value_precision BIGINT NOT NULL, - CONSTRAINT unique_commitment UNIQUE (commitment) -) + CONSTRAINT unique_commitment UNIQUE (commitment), +); CREATE TABLE scanned_blocks ( header_hash BLOB PRIMARY KEY NOT NULL, @@ -128,9 +120,9 @@ CREATE TABLE scanned_blocks ( num_outputs BIGINT NULL, amount BIGINT NULL, timestamp DATETIME NOT NULL, -) +); CREATE TABLE wallet_settings ( key TEXT PRIMARY KEY NOT NULL, value TEXT NOT NULL, -) \ No newline at end of file +); From 93d927acf6fe0b0adbae1106ff4641aadcbe082a Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 8 Aug 2022 13:51:31 +0100 Subject: [PATCH 18/23] add changes --- .../2022-08-08-134037_initial/up.sql | 18 +++++----- base_layer/wallet/src/schema.rs | 35 +------------------ 2 files changed, 10 insertions(+), 43 deletions(-) diff --git a/base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql b/base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql index 7f2184bd5d..5349faad4c 100644 --- a/base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql +++ b/base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql @@ -1,6 +1,6 @@ CREATE TABLE client_key_values ( key TEXT PRIMARY KEY NOT NULL, - value TEXT NOT NULL, + value TEXT NOT NULL ); CREATE TABLE completed_transactions ( @@ -23,7 +23,7 @@ CREATE TABLE completed_transactions ( mined_in_block BLOB NULL, mined_timestamp DATETIME NULL, transaction_signature_nonce BLOB DEFAULT 0 NOT NULL, - transaction_signature_key BLOB DEFAULT 0 NOT NULL, + transaction_signature_key BLOB DEFAULT 0 NOT NULL ); CREATE TABLE contacts ( @@ -31,7 +31,7 @@ CREATE TABLE contacts ( node_id BLOB NOT NULL UNIQUE, alias TEXT NOT NULL, last_seen DATETIME NULL, - latency INTEGER NULL, + latency INTEGER NULL ); CREATE TABLE inbound_transactions ( @@ -44,14 +44,14 @@ CREATE TABLE inbound_transactions ( cancelled INTEGER NOT NULL, direct_send_success INTEGER DEFAULT 0 NOT NULL, send_count INTEGER DEFAULT 0 NOT NULL, - last_send_timestamp DATETIME NULL, + last_send_timestamp DATETIME NULL ); CREATE TABLE key_manager_states ( id INTEGER PRIMARY KEY NOT NULL, branch_seed TEXT UNIQUE NOT NULL, primary_key_index BLOB NOT NULL, - timestamp DATETIME NOT NULL, + timestamp DATETIME NOT NULL ); CREATE TABLE known_one_sided_payment_scripts ( @@ -73,7 +73,7 @@ CREATE TABLE outbound_transactions ( cancelled INTEGER DEFAULT 0 NOT NULL, direct_send_success INTEGER DEFAULT 0 NOT NULL, send_count INTEGER DEFAULT 0 NOT NULL, - last_send_timestamp DATETIME NULL, + last_send_timestamp DATETIME NULL ); CREATE TABLE outputs ( @@ -111,7 +111,7 @@ CREATE TABLE outputs ( encrypted_value BLOB NOT NULL, contract_id BLOB NULL, minimum_value_precision BIGINT NOT NULL, - CONSTRAINT unique_commitment UNIQUE (commitment), + CONSTRAINT unique_commitment UNIQUE (commitment) ); CREATE TABLE scanned_blocks ( @@ -119,10 +119,10 @@ CREATE TABLE scanned_blocks ( height BIGINT NOT NULL, num_outputs BIGINT NULL, amount BIGINT NULL, - timestamp DATETIME NOT NULL, + timestamp DATETIME NOT NULL ); CREATE TABLE wallet_settings ( key TEXT PRIMARY KEY NOT NULL, - value TEXT NOT NULL, + value TEXT NOT NULL ); diff --git a/base_layer/wallet/src/schema.rs b/base_layer/wallet/src/schema.rs index 9d03a623d2..ce4f2d0331 100644 --- a/base_layer/wallet/src/schema.rs +++ b/base_layer/wallet/src/schema.rs @@ -1,25 +1,3 @@ -// Copyright 2020. The Tari Project -// -// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the -// following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following -// disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the -// following disclaimer in the documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote -// products derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - table! { client_key_values (key) { key -> Text, @@ -86,16 +64,6 @@ table! { } } -table! { - key_manager_states_old (id) { - id -> Integer, - seed -> Binary, - branch_seed -> Text, - primary_key_index -> BigInt, - timestamp -> Timestamp, - } -} - table! { known_one_sided_payment_scripts (script_hash) { script_hash -> Binary, @@ -157,7 +125,7 @@ table! { mined_timestamp -> Nullable, encrypted_value -> Binary, contract_id -> Nullable, - minimum_value_promise -> BigInt, + minimum_value_precision -> BigInt, } } @@ -184,7 +152,6 @@ allow_tables_to_appear_in_same_query!( contacts, inbound_transactions, key_manager_states, - key_manager_states_old, known_one_sided_payment_scripts, outbound_transactions, outputs, From 870747677b2f30ff6df390a3cf2009020e1fff20 Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 8 Aug 2022 15:08:44 +0100 Subject: [PATCH 19/23] add key manager states old table --- .../wallet/migrations/2022-08-08-134037_initial/up.sql | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql b/base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql index 5349faad4c..5d333ff336 100644 --- a/base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql +++ b/base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql @@ -54,6 +54,13 @@ CREATE TABLE key_manager_states ( timestamp DATETIME NOT NULL ); +CREATE TABLE key_manager_states_old ( + id INTEGER PRIMARY KEY NOT NULL, + seed TEXT UNIQUE NOT NULL, + primary_key_index BLOB NOT NULL, + timestamp DATETIME NOT NULL +) + CREATE TABLE known_one_sided_payment_scripts ( script_hash BLOB PRIMARY KEY NOT NULL, private_key BLOB NOT NULL, From 8ba2ce6e890363151f409a76fab910f5e25b8f4d Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 8 Aug 2022 15:21:40 +0100 Subject: [PATCH 20/23] add changes --- .../wallet/migrations/2022-08-08-134037_initial/up.sql | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql b/base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql index 5d333ff336..3263f1a25e 100644 --- a/base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql +++ b/base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql @@ -55,10 +55,11 @@ CREATE TABLE key_manager_states ( ); CREATE TABLE key_manager_states_old ( - id INTEGER PRIMARY KEY NOT NULL, - seed TEXT UNIQUE NOT NULL, - primary_key_index BLOB NOT NULL, - timestamp DATETIME NOT NULL + id INTEGER PRIMARY KEY NOT NULL, + seed BLOB NOT NULL, + branch_seed TEXT UNIQUE NOT NULL, + primary_key_index BLOB NOT NULL, + timestamp DATETIME NOT NULL ) CREATE TABLE known_one_sided_payment_scripts ( From 2ee62d91aa6cfdc4b32ec1fdd0903f0df7351a0e Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 8 Aug 2022 17:27:06 +0100 Subject: [PATCH 21/23] add schema tables --- base_layer/wallet/src/schema.rs | 35 ++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/base_layer/wallet/src/schema.rs b/base_layer/wallet/src/schema.rs index ce4f2d0331..9d03a623d2 100644 --- a/base_layer/wallet/src/schema.rs +++ b/base_layer/wallet/src/schema.rs @@ -1,3 +1,25 @@ +// Copyright 2020. The Tari Project +// +// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the +// following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following +// disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the +// following disclaimer in the documentation and/or other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote +// products derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + table! { client_key_values (key) { key -> Text, @@ -64,6 +86,16 @@ table! { } } +table! { + key_manager_states_old (id) { + id -> Integer, + seed -> Binary, + branch_seed -> Text, + primary_key_index -> BigInt, + timestamp -> Timestamp, + } +} + table! { known_one_sided_payment_scripts (script_hash) { script_hash -> Binary, @@ -125,7 +157,7 @@ table! { mined_timestamp -> Nullable, encrypted_value -> Binary, contract_id -> Nullable, - minimum_value_precision -> BigInt, + minimum_value_promise -> BigInt, } } @@ -152,6 +184,7 @@ allow_tables_to_appear_in_same_query!( contacts, inbound_transactions, key_manager_states, + key_manager_states_old, known_one_sided_payment_scripts, outbound_transactions, outputs, From 2d6abbe6fe8e4d816a2f56678ce9b6c6a529af3e Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Mon, 8 Aug 2022 17:32:02 +0100 Subject: [PATCH 22/23] refactor tests --- base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql b/base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql index 3263f1a25e..a751b2b94b 100644 --- a/base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql +++ b/base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql @@ -60,7 +60,7 @@ CREATE TABLE key_manager_states_old ( branch_seed TEXT UNIQUE NOT NULL, primary_key_index BLOB NOT NULL, timestamp DATETIME NOT NULL -) +); CREATE TABLE known_one_sided_payment_scripts ( script_hash BLOB PRIMARY KEY NOT NULL, From 0793a1f318f0a71d8abffdb56f8b7c59bbbd5558 Mon Sep 17 00:00:00 2001 From: jorgeantonio21 Date: Tue, 9 Aug 2022 08:36:14 +0100 Subject: [PATCH 23/23] incorrect renaming --- base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql b/base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql index a751b2b94b..e8ed3c9e5c 100644 --- a/base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql +++ b/base_layer/wallet/migrations/2022-08-08-134037_initial/up.sql @@ -118,7 +118,7 @@ CREATE TABLE outputs ( mined_timestamp DATETIME NULL, encrypted_value BLOB NOT NULL, contract_id BLOB NULL, - minimum_value_precision BIGINT NOT NULL, + minimum_value_promise BIGINT NOT NULL, CONSTRAINT unique_commitment UNIQUE (commitment) );