diff --git a/multinode_integration_tests/src/masq_real_node.rs b/multinode_integration_tests/src/masq_real_node.rs index d986f6645..e458f0d64 100644 --- a/multinode_integration_tests/src/masq_real_node.rs +++ b/multinode_integration_tests/src/masq_real_node.rs @@ -14,7 +14,7 @@ use masq_lib::constants::{CURRENT_LOGFILE_NAME, DEFAULT_UI_PORT}; use masq_lib::test_utils::utils::TEST_DEFAULT_MULTINODE_CHAIN; use masq_lib::utils::localhost; use masq_lib::utils::{DEFAULT_CONSUMING_DERIVATION_PATH, DEFAULT_EARNING_DERIVATION_PATH}; -use node_lib::blockchain::bip32::Bip32ECKeyProvider; +use node_lib::blockchain::bip32::Bip32EncryptionKeyProvider; use node_lib::neighborhood::DEFAULT_MIN_HOPS; use node_lib::sub_lib::accountant::{ PaymentThresholds, DEFAULT_EARNING_WALLET, DEFAULT_PAYMENT_THRESHOLDS, @@ -377,7 +377,7 @@ impl NodeStartupConfig { EarningWalletInfo::Address(address) => Wallet::from_str(address).unwrap(), EarningWalletInfo::DerivationPath(phrase, derivation_path) => { let mnemonic = Mnemonic::from_phrase(phrase.as_str(), Language::English).unwrap(); - let keypair = Bip32ECKeyProvider::try_from(( + let keypair = Bip32EncryptionKeyProvider::try_from(( Seed::new(&mnemonic, "passphrase").as_ref(), derivation_path.as_str(), )) @@ -392,12 +392,12 @@ impl NodeStartupConfig { ConsumingWalletInfo::None => None, ConsumingWalletInfo::PrivateKey(key) => { let key_bytes = key.from_hex::>().unwrap(); - let keypair = Bip32ECKeyProvider::from_raw_secret(&key_bytes).unwrap(); + let keypair = Bip32EncryptionKeyProvider::from_raw_secret(&key_bytes).unwrap(); Some(Wallet::from(keypair)) } ConsumingWalletInfo::DerivationPath(phrase, derivation_path) => { let mnemonic = Mnemonic::from_phrase(phrase, Language::English).unwrap(); - let keypair = Bip32ECKeyProvider::try_from(( + let keypair = Bip32EncryptionKeyProvider::try_from(( Seed::new(&mnemonic, "passphrase").as_ref(), derivation_path.as_str(), )) diff --git a/multinode_integration_tests/src/utils.rs b/multinode_integration_tests/src/utils.rs index 10ca36c9f..47f452881 100644 --- a/multinode_integration_tests/src/utils.rs +++ b/multinode_integration_tests/src/utils.rs @@ -5,10 +5,8 @@ use crate::masq_node::{MASQNode, MASQNodeUtils}; use crate::masq_real_node::MASQRealNode; use masq_lib::test_utils::utils::TEST_DEFAULT_MULTINODE_CHAIN; use masq_lib::utils::NeighborhoodModeLight; -use node_lib::accountant::database_access_objects::payable_dao::{PayableDao, PayableDaoReal}; -use node_lib::accountant::database_access_objects::receivable_dao::{ - ReceivableDao, ReceivableDaoReal, -}; +use node_lib::accountant::db_access_objects::payable_dao::{PayableDao, PayableDaoReal}; +use node_lib::accountant::db_access_objects::receivable_dao::{ReceivableDao, ReceivableDaoReal}; use node_lib::database::connection_wrapper::ConnectionWrapper; use node_lib::database::db_initializer::{ DbInitializationConfig, DbInitializer, DbInitializerReal, ExternalData, diff --git a/multinode_integration_tests/tests/blockchain_interaction_test.rs b/multinode_integration_tests/tests/blockchain_interaction_test.rs index 020db13d2..f3b632880 100644 --- a/multinode_integration_tests/tests/blockchain_interaction_test.rs +++ b/multinode_integration_tests/tests/blockchain_interaction_test.rs @@ -22,7 +22,7 @@ use multinode_integration_tests_lib::utils::{ config_dao, node_chain_specific_data_directory, open_all_file_permissions, receivable_dao, UrlHolder, }; -use node_lib::accountant::database_access_objects::dao_utils::CustomQuery; +use node_lib::accountant::db_access_objects::dao_utils::CustomQuery; use node_lib::sub_lib::wallet::Wallet; #[test] diff --git a/multinode_integration_tests/tests/bookkeeping_test.rs b/multinode_integration_tests/tests/bookkeeping_test.rs index 1de7745a1..cd6bfe6ba 100644 --- a/multinode_integration_tests/tests/bookkeeping_test.rs +++ b/multinode_integration_tests/tests/bookkeeping_test.rs @@ -6,9 +6,9 @@ use multinode_integration_tests_lib::masq_real_node::{ STANDARD_CLIENT_TIMEOUT_MILLIS, }; use multinode_integration_tests_lib::utils::{payable_dao, receivable_dao}; -use node_lib::accountant::database_access_objects::dao_utils::CustomQuery; -use node_lib::accountant::database_access_objects::payable_dao::PayableAccount; -use node_lib::accountant::database_access_objects::receivable_dao::ReceivableAccount; +use node_lib::accountant::db_access_objects::dao_utils::CustomQuery; +use node_lib::accountant::db_access_objects::payable_dao::PayableAccount; +use node_lib::accountant::db_access_objects::receivable_dao::ReceivableAccount; use node_lib::sub_lib::wallet::Wallet; use std::collections::HashMap; use std::thread; diff --git a/multinode_integration_tests/tests/verify_bill_payment.rs b/multinode_integration_tests/tests/verify_bill_payment.rs index 95d1ccbb2..9689c0691 100644 --- a/multinode_integration_tests/tests/verify_bill_payment.rs +++ b/multinode_integration_tests/tests/verify_bill_payment.rs @@ -13,11 +13,9 @@ use multinode_integration_tests_lib::masq_real_node::{ use multinode_integration_tests_lib::utils::{ node_chain_specific_data_directory, open_all_file_permissions, UrlHolder, }; -use node_lib::accountant::database_access_objects::payable_dao::{PayableDao, PayableDaoReal}; -use node_lib::accountant::database_access_objects::receivable_dao::{ - ReceivableDao, ReceivableDaoReal, -}; -use node_lib::blockchain::bip32::Bip32ECKeyProvider; +use node_lib::accountant::db_access_objects::payable_dao::{PayableDao, PayableDaoReal}; +use node_lib::accountant::db_access_objects::receivable_dao::{ReceivableDao, ReceivableDaoReal}; +use node_lib::blockchain::bip32::Bip32EncryptionKeyProvider; use node_lib::blockchain::blockchain_interface::{ BlockchainInterface, BlockchainInterfaceWeb3, REQUESTS_IN_PARALLEL, }; @@ -393,7 +391,7 @@ fn make_node_wallet(seed: &Seed, derivation_path: &str) -> (Wallet, String) { let secret = extended_priv_key.secret().to_hex::(); ( - Wallet::from(Bip32ECKeyProvider::from_key(extended_priv_key)), + Wallet::from(Bip32EncryptionKeyProvider::from_key(extended_priv_key)), secret, ) } diff --git a/node/src/accountant/database_access_objects/banned_dao.rs b/node/src/accountant/db_access_objects/banned_dao.rs similarity index 99% rename from node/src/accountant/database_access_objects/banned_dao.rs rename to node/src/accountant/db_access_objects/banned_dao.rs index 44088e973..852bb3675 100644 --- a/node/src/accountant/database_access_objects/banned_dao.rs +++ b/node/src/accountant/db_access_objects/banned_dao.rs @@ -1,7 +1,5 @@ // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. -use crate::accountant::database_access_objects::dao_utils::{ - DaoFactoryReal, VigilantRusqliteFlatten, -}; +use crate::accountant::db_access_objects::dao_utils::{DaoFactoryReal, VigilantRusqliteFlatten}; use crate::database::connection_wrapper::ConnectionWrapper; use crate::sub_lib::wallet::Wallet; use lazy_static::lazy_static; diff --git a/node/src/accountant/database_access_objects/dao_utils.rs b/node/src/accountant/db_access_objects/dao_utils.rs similarity index 99% rename from node/src/accountant/database_access_objects/dao_utils.rs rename to node/src/accountant/db_access_objects/dao_utils.rs index 39671afe9..18c1a6eb4 100644 --- a/node/src/accountant/database_access_objects/dao_utils.rs +++ b/node/src/accountant/db_access_objects/dao_utils.rs @@ -1,8 +1,8 @@ // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. -use crate::accountant::big_int_processing::big_int_divider::BigIntDivider; -use crate::accountant::database_access_objects::payable_dao::PayableAccount; -use crate::accountant::database_access_objects::receivable_dao::ReceivableAccount; +use crate::accountant::db_access_objects::payable_dao::PayableAccount; +use crate::accountant::db_access_objects::receivable_dao::ReceivableAccount; +use crate::accountant::db_big_integer::big_int_divider::BigIntDivider; use crate::accountant::{checked_conversion, gwei_to_wei, sign_conversion}; use crate::database::connection_wrapper::ConnectionWrapper; use crate::database::db_initializer::{ diff --git a/node/src/accountant/database_access_objects/mod.rs b/node/src/accountant/db_access_objects/mod.rs similarity index 100% rename from node/src/accountant/database_access_objects/mod.rs rename to node/src/accountant/db_access_objects/mod.rs diff --git a/node/src/accountant/database_access_objects/payable_dao.rs b/node/src/accountant/db_access_objects/payable_dao.rs similarity index 98% rename from node/src/accountant/database_access_objects/payable_dao.rs rename to node/src/accountant/db_access_objects/payable_dao.rs index fe89ed1e0..b3a3cbb19 100644 --- a/node/src/accountant/database_access_objects/payable_dao.rs +++ b/node/src/accountant/db_access_objects/payable_dao.rs @@ -1,21 +1,21 @@ // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. -use crate::accountant::big_int_processing::big_int_db_processor::KnownKeyVariants::{ +use crate::accountant::db_big_integer::big_int_db_processor::KnownKeyVariants::{ PendingPayableRowid, WalletAddress, }; -use crate::accountant::big_int_processing::big_int_db_processor::WeiChange::{ +use crate::accountant::db_big_integer::big_int_db_processor::WeiChange::{ Addition, Subtraction, }; -use crate::accountant::big_int_processing::big_int_db_processor::{ +use crate::accountant::db_big_integer::big_int_db_processor::{ BigIntDbProcessor, BigIntSqlConfig, Param, SQLParamsBuilder, TableNameDAO, }; -use crate::accountant::big_int_processing::big_int_divider::BigIntDivider; -use crate::accountant::database_access_objects::dao_utils; -use crate::accountant::database_access_objects::dao_utils::{ +use crate::accountant::db_big_integer::big_int_divider::BigIntDivider; +use crate::accountant::db_access_objects::dao_utils; +use crate::accountant::db_access_objects::dao_utils::{ sum_i128_values_from_table, to_time_t, AssemblerFeeder, CustomQuery, DaoFactoryReal, RangeStmConfig, TopStmConfig, VigilantRusqliteFlatten, }; -use crate::accountant::database_access_objects::payable_dao::mark_pending_payable_associated_functions::{ +use crate::accountant::db_access_objects::payable_dao::mark_pending_payable_associated_functions::{ compose_case_expression, execute_command, serialize_wallets, }; use crate::accountant::{checked_conversion, sign_conversion, PendingPayableId}; @@ -402,10 +402,10 @@ impl TableNameDAO for PayableDaoReal { mod mark_pending_payable_associated_functions { use crate::accountant::comma_joined_stringifiable; - use crate::accountant::database_access_objects::dao_utils::{ + use crate::accountant::db_access_objects::dao_utils::{ update_rows_and_return_valid_count, VigilantRusqliteFlatten, }; - use crate::accountant::database_access_objects::payable_dao::PayableDaoError; + use crate::accountant::db_access_objects::payable_dao::PayableDaoError; use crate::database::connection_wrapper::ConnectionWrapper; use crate::sub_lib::wallet::Wallet; use itertools::Itertools; @@ -552,9 +552,9 @@ mod mark_pending_payable_associated_functions { #[cfg(test)] mod tests { use super::*; - use crate::accountant::database_access_objects::dao_utils::{from_time_t, now_time_t, to_time_t}; + use crate::accountant::db_access_objects::dao_utils::{from_time_t, now_time_t, to_time_t}; use crate::accountant::gwei_to_wei; - use crate::accountant::database_access_objects::payable_dao::mark_pending_payable_associated_functions::explanatory_extension; + use crate::accountant::db_access_objects::payable_dao::mark_pending_payable_associated_functions::explanatory_extension; use crate::accountant::test_utils::{ assert_account_creation_fn_fails_on_finding_wrong_columns_and_value_types, make_pending_payable_fingerprint, diff --git a/node/src/accountant/database_access_objects/pending_payable_dao.rs b/node/src/accountant/db_access_objects/pending_payable_dao.rs similarity index 98% rename from node/src/accountant/database_access_objects/pending_payable_dao.rs rename to node/src/accountant/db_access_objects/pending_payable_dao.rs index 582c12a36..fd7043bb7 100644 --- a/node/src/accountant/database_access_objects/pending_payable_dao.rs +++ b/node/src/accountant/db_access_objects/pending_payable_dao.rs @@ -1,9 +1,9 @@ // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. -use crate::accountant::big_int_processing::big_int_divider::BigIntDivider; -use crate::accountant::database_access_objects::dao_utils::{ +use crate::accountant::db_access_objects::dao_utils::{ from_time_t, to_time_t, DaoFactoryReal, VigilantRusqliteFlatten, }; +use crate::accountant::db_big_integer::big_int_divider::BigIntDivider; use crate::accountant::{checked_conversion, comma_joined_stringifiable}; use crate::blockchain::blockchain_bridge::PendingPayableFingerprint; use crate::database::connection_wrapper::ConnectionWrapper; @@ -241,12 +241,12 @@ impl<'a> PendingPayableDaoReal<'a> { #[cfg(test)] mod tests { - use crate::accountant::big_int_processing::big_int_divider::BigIntDivider; use crate::accountant::checked_conversion; - use crate::accountant::database_access_objects::dao_utils::from_time_t; - use crate::accountant::database_access_objects::pending_payable_dao::{ + use crate::accountant::db_access_objects::dao_utils::from_time_t; + use crate::accountant::db_access_objects::pending_payable_dao::{ PendingPayableDao, PendingPayableDaoError, PendingPayableDaoReal, }; + use crate::accountant::db_big_integer::big_int_divider::BigIntDivider; use crate::blockchain::blockchain_bridge::PendingPayableFingerprint; use crate::blockchain::test_utils::make_tx_hash; use crate::database::connection_wrapper::ConnectionWrapperReal; diff --git a/node/src/accountant/database_access_objects/receivable_dao.rs b/node/src/accountant/db_access_objects/receivable_dao.rs similarity index 98% rename from node/src/accountant/database_access_objects/receivable_dao.rs rename to node/src/accountant/db_access_objects/receivable_dao.rs index be626d1bb..122362e88 100644 --- a/node/src/accountant/database_access_objects/receivable_dao.rs +++ b/node/src/accountant/db_access_objects/receivable_dao.rs @@ -1,20 +1,18 @@ // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. -use crate::accountant::big_int_processing::big_int_db_processor::KnownKeyVariants::WalletAddress; -use crate::accountant::big_int_processing::big_int_db_processor::WeiChange::{ - Addition, Subtraction, -}; -use crate::accountant::big_int_processing::big_int_db_processor::{ - BigIntDbProcessor, BigIntSqlConfig, Param, SQLParamsBuilder, TableNameDAO, -}; -use crate::accountant::big_int_processing::big_int_divider::BigIntDivider; use crate::accountant::checked_conversion; -use crate::accountant::database_access_objects::dao_utils; -use crate::accountant::database_access_objects::dao_utils::{ +use crate::accountant::db_access_objects::dao_utils; +use crate::accountant::db_access_objects::dao_utils::{ sum_i128_values_from_table, to_time_t, AssemblerFeeder, CustomQuery, DaoFactoryReal, RangeStmConfig, ThresholdUtils, TopStmConfig, VigilantRusqliteFlatten, }; -use crate::accountant::database_access_objects::receivable_dao::ReceivableDaoError::RusqliteError; +use crate::accountant::db_access_objects::receivable_dao::ReceivableDaoError::RusqliteError; +use crate::accountant::db_big_integer::big_int_db_processor::KnownKeyVariants::WalletAddress; +use crate::accountant::db_big_integer::big_int_db_processor::WeiChange::{Addition, Subtraction}; +use crate::accountant::db_big_integer::big_int_db_processor::{ + BigIntDbProcessor, BigIntSqlConfig, Param, SQLParamsBuilder, TableNameDAO, +}; +use crate::accountant::db_big_integer::big_int_divider::BigIntDivider; use crate::accountant::gwei_to_wei; use crate::blockchain::blockchain_interface::BlockchainTransaction; use crate::database::connection_wrapper::ConnectionWrapper; @@ -413,9 +411,7 @@ impl TableNameDAO for ReceivableDaoReal { #[cfg(test)] mod tests { use super::*; - use crate::accountant::database_access_objects::dao_utils::{ - from_time_t, now_time_t, to_time_t, - }; + use crate::accountant::db_access_objects::dao_utils::{from_time_t, now_time_t, to_time_t}; use crate::accountant::gwei_to_wei; use crate::accountant::test_utils::{ assert_account_creation_fn_fails_on_finding_wrong_columns_and_value_types, diff --git a/node/src/accountant/big_int_processing/big_int_db_processor.rs b/node/src/accountant/db_big_integer/big_int_db_processor.rs similarity index 98% rename from node/src/accountant/big_int_processing/big_int_db_processor.rs rename to node/src/accountant/db_big_integer/big_int_db_processor.rs index 5c57bc1b5..474b6ebd2 100644 --- a/node/src/accountant/big_int_processing/big_int_db_processor.rs +++ b/node/src/accountant/db_big_integer/big_int_db_processor.rs @@ -1,9 +1,9 @@ // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. -use crate::accountant::big_int_processing::big_int_divider::BigIntDivider; use crate::accountant::checked_conversion; -use crate::accountant::database_access_objects::payable_dao::PayableDaoError; -use crate::accountant::database_access_objects::receivable_dao::ReceivableDaoError; +use crate::accountant::db_access_objects::payable_dao::PayableDaoError; +use crate::accountant::db_access_objects::receivable_dao::ReceivableDaoError; +use crate::accountant::db_big_integer::big_int_divider::BigIntDivider; use crate::database::connection_wrapper::ConnectionWrapper; use crate::sub_lib::wallet::Wallet; use itertools::Either; @@ -498,12 +498,12 @@ big_int_db_error_from!(PayableDaoError, ReceivableDaoError); #[cfg(test)] mod tests { use super::*; - use crate::accountant::big_int_processing::big_int_db_processor::ByteMagnitude::{High, Low}; - use crate::accountant::big_int_processing::big_int_db_processor::KnownKeyVariants::TestKey; - use crate::accountant::big_int_processing::big_int_db_processor::WeiChange::{ + use crate::accountant::db_big_integer::big_int_db_processor::ByteMagnitude::{High, Low}; + use crate::accountant::db_big_integer::big_int_db_processor::KnownKeyVariants::TestKey; + use crate::accountant::db_big_integer::big_int_db_processor::WeiChange::{ Addition, Subtraction, }; - use crate::accountant::big_int_processing::test_utils::restricted::{ + use crate::accountant::db_big_integer::test_utils::restricted::{ create_new_empty_db, test_database_key, }; use crate::database::connection_wrapper::{ConnectionWrapper, ConnectionWrapperReal}; diff --git a/node/src/accountant/big_int_processing/big_int_divider.rs b/node/src/accountant/db_big_integer/big_int_divider.rs similarity index 99% rename from node/src/accountant/big_int_processing/big_int_divider.rs rename to node/src/accountant/db_big_integer/big_int_divider.rs index 40d5a15f1..f52846cf4 100644 --- a/node/src/accountant/big_int_processing/big_int_divider.rs +++ b/node/src/accountant/db_big_integer/big_int_divider.rs @@ -1,6 +1,6 @@ // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. -use crate::accountant::big_int_processing::big_int_divider::UserDefinedFunctionError::InvalidInputValue; +use crate::accountant::db_big_integer::big_int_divider::UserDefinedFunctionError::InvalidInputValue; use crate::accountant::gwei_to_wei; use rusqlite::functions::{Context, FunctionFlags}; use rusqlite::Connection; @@ -135,7 +135,7 @@ impl Display for UserDefinedFunctionError { #[cfg(test)] mod tests { use super::*; - use crate::accountant::big_int_processing::test_utils::restricted::create_new_empty_db; + use crate::accountant::db_big_integer::test_utils::restricted::create_new_empty_db; use rusqlite::Error::SqliteFailure; use rusqlite::ErrorCode; diff --git a/node/src/accountant/big_int_processing/mod.rs b/node/src/accountant/db_big_integer/mod.rs similarity index 100% rename from node/src/accountant/big_int_processing/mod.rs rename to node/src/accountant/db_big_integer/mod.rs diff --git a/node/src/accountant/big_int_processing/test_utils.rs b/node/src/accountant/db_big_integer/test_utils.rs similarity index 75% rename from node/src/accountant/big_int_processing/test_utils.rs rename to node/src/accountant/db_big_integer/test_utils.rs index b231db20c..2a16e4575 100644 --- a/node/src/accountant/big_int_processing/test_utils.rs +++ b/node/src/accountant/db_big_integer/test_utils.rs @@ -1,8 +1,8 @@ // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. -pub(in crate::accountant::big_int_processing) mod restricted { - use crate::accountant::big_int_processing::big_int_db_processor::KnownKeyVariants::TestKey; - use crate::accountant::big_int_processing::big_int_db_processor::{ +pub(in crate::accountant::db_big_integer) mod restricted { + use crate::accountant::db_big_integer::big_int_db_processor::KnownKeyVariants::TestKey; + use crate::accountant::db_big_integer::big_int_db_processor::{ ExtendedParamsMarker, KnownKeyVariants, }; use masq_lib::test_utils::utils::ensure_node_home_directory_exists; diff --git a/node/src/accountant/financials.rs b/node/src/accountant/financials.rs index 465d247d6..c6585431a 100644 --- a/node/src/accountant/financials.rs +++ b/node/src/accountant/financials.rs @@ -24,7 +24,7 @@ where } pub(in crate::accountant) mod visibility_restricted_module { - use crate::accountant::database_access_objects::dao_utils::CustomQuery; + use crate::accountant::db_access_objects::dao_utils::CustomQuery; use crate::accountant::financials::{fits_in_0_to_i64max_for_u64, OPCODE_FINANCIALS}; use masq_lib::constants::{ REQUEST_WITH_MUTUALLY_EXCLUSIVE_PARAMS, REQUEST_WITH_NO_VALUES, VALUE_EXCEEDS_ALLOWED_LIMIT, @@ -111,7 +111,7 @@ pub(in crate::accountant) mod visibility_restricted_module { #[cfg(test)] mod tests { use super::visibility_restricted_module::check_query_is_within_tech_limits; - use crate::accountant::database_access_objects::dao_utils::CustomQuery; + use crate::accountant::db_access_objects::dao_utils::CustomQuery; use crate::accountant::financials::fits_in_0_to_i64max_for_u64; use masq_lib::constants::VALUE_EXCEEDS_ALLOWED_LIMIT; use masq_lib::messages::TopRecordsOrdering::Age; diff --git a/node/src/accountant/mod.rs b/node/src/accountant/mod.rs index 444f497c7..34d966697 100644 --- a/node/src/accountant/mod.rs +++ b/node/src/accountant/mod.rs @@ -1,7 +1,7 @@ // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. -pub mod big_int_processing; -pub mod database_access_objects; +pub mod db_access_objects; +pub mod db_big_integer; pub mod financials; pub mod scanners; @@ -18,16 +18,14 @@ use masq_lib::messages::{ }; use masq_lib::ui_gateway::{MessageBody, MessagePath}; -use crate::accountant::database_access_objects::dao_utils::{ +use crate::accountant::db_access_objects::dao_utils::{ remap_payable_accounts, remap_receivable_accounts, CustomQuery, DaoFactoryReal, }; -use crate::accountant::database_access_objects::payable_dao::{ +use crate::accountant::db_access_objects::payable_dao::{ PayableAccount, PayableDao, PayableDaoError, }; -use crate::accountant::database_access_objects::pending_payable_dao::PendingPayableDao; -use crate::accountant::database_access_objects::receivable_dao::{ - ReceivableDao, ReceivableDaoError, -}; +use crate::accountant::db_access_objects::pending_payable_dao::PendingPayableDao; +use crate::accountant::db_access_objects::receivable_dao::{ReceivableDao, ReceivableDaoError}; use crate::accountant::financials::visibility_restricted_module::{ check_query_is_within_tech_limits, financials_entry_check, }; @@ -1003,13 +1001,13 @@ pub mod check_sqlite_fns { #[cfg(test)] mod tests { use super::*; - use crate::accountant::database_access_objects::dao_utils::from_time_t; - use crate::accountant::database_access_objects::dao_utils::{to_time_t, CustomQuery}; - use crate::accountant::database_access_objects::payable_dao::{ + use crate::accountant::db_access_objects::dao_utils::from_time_t; + use crate::accountant::db_access_objects::dao_utils::{to_time_t, CustomQuery}; + use crate::accountant::db_access_objects::payable_dao::{ PayableAccount, PayableDaoError, PayableDaoFactory, PendingPayable, }; - use crate::accountant::database_access_objects::pending_payable_dao::PendingPayableDaoError; - use crate::accountant::database_access_objects::receivable_dao::ReceivableAccount; + use crate::accountant::db_access_objects::pending_payable_dao::PendingPayableDaoError; + use crate::accountant::db_access_objects::receivable_dao::ReceivableAccount; use crate::accountant::scanners::{BeginScanError, NullScanner, ScannerMock}; use crate::accountant::test_utils::DaoWithDestination::{ ForAccountantBody, ForPayableScanner, ForPendingPayableScanner, ForReceivableScanner, diff --git a/node/src/accountant/scanners/mod.rs b/node/src/accountant/scanners/mod.rs index bbf62709d..4484e7516 100644 --- a/node/src/accountant/scanners/mod.rs +++ b/node/src/accountant/scanners/mod.rs @@ -2,9 +2,9 @@ pub mod scanners_utils; -use crate::accountant::database_access_objects::payable_dao::{PayableAccount, PayableDao, PendingPayable}; -use crate::accountant::database_access_objects::pending_payable_dao::PendingPayableDao; -use crate::accountant::database_access_objects::receivable_dao::ReceivableDao; +use crate::accountant::db_access_objects::payable_dao::{PayableAccount, PayableDao, PendingPayable}; +use crate::accountant::db_access_objects::pending_payable_dao::PendingPayableDao; +use crate::accountant::db_access_objects::receivable_dao::ReceivableDao; use crate::accountant::scanners::scanners_utils::payable_scanner_utils::PayableTransactingErrorEnum::{ LocallyCausedError, RemotelyCausedErrors, }; @@ -26,7 +26,7 @@ use crate::accountant::{ ReportTransactionReceipts, RequestTransactionReceipts, ResponseSkeleton, ScanForPayables, ScanForPendingPayables, ScanForReceivables, SentPayables, }; -use crate::accountant::database_access_objects::banned_dao::BannedDao; +use crate::accountant::db_access_objects::banned_dao::BannedDao; use crate::blockchain::blockchain_bridge::{PendingPayableFingerprint, RetrieveTransactions}; use crate::blockchain::blockchain_interface::PayableTransactionError; use crate::sub_lib::accountant::{ @@ -1096,11 +1096,11 @@ mod tests { use std::ops::Sub; use std::panic::{catch_unwind, AssertUnwindSafe}; - use crate::accountant::database_access_objects::dao_utils::{from_time_t, to_time_t}; - use crate::accountant::database_access_objects::payable_dao::{ + use crate::accountant::db_access_objects::dao_utils::{from_time_t, to_time_t}; + use crate::accountant::db_access_objects::payable_dao::{ PayableAccount, PayableDaoError, PendingPayable, }; - use crate::accountant::database_access_objects::pending_payable_dao::PendingPayableDaoError; + use crate::accountant::db_access_objects::pending_payable_dao::PendingPayableDaoError; use crate::accountant::scanners::scanners_utils::payable_scanner_utils::PayableThresholdsGaugeReal; use crate::accountant::scanners::scanners_utils::pending_payable_scanner_utils::PendingPayableScanReport; use crate::blockchain::blockchain_interface::ProcessedPayableFallible::{Correct, Failed}; diff --git a/node/src/accountant/scanners/scanners_utils.rs b/node/src/accountant/scanners/scanners_utils.rs index ec9e3c0b1..6faf90eba 100644 --- a/node/src/accountant/scanners/scanners_utils.rs +++ b/node/src/accountant/scanners/scanners_utils.rs @@ -1,8 +1,8 @@ // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. pub mod payable_scanner_utils { - use crate::accountant::database_access_objects::dao_utils::ThresholdUtils; - use crate::accountant::database_access_objects::payable_dao::{PayableAccount, PayableDaoError, PendingPayable}; + use crate::accountant::db_access_objects::dao_utils::ThresholdUtils; + use crate::accountant::db_access_objects::payable_dao::{PayableAccount, PayableDaoError, PendingPayable}; use crate::accountant::scanners::scanners_utils::payable_scanner_utils::PayableTransactingErrorEnum::{ LocallyCausedError, RemotelyCausedErrors, }; @@ -399,7 +399,7 @@ pub mod pending_payable_scanner_utils { } pub mod receivable_scanner_utils { - use crate::accountant::database_access_objects::receivable_dao::ReceivableAccount; + use crate::accountant::db_access_objects::receivable_dao::ReceivableAccount; use crate::accountant::wei_to_gwei; use std::time::{Duration, SystemTime}; use thousands::Separable; @@ -415,9 +415,9 @@ pub mod receivable_scanner_utils { #[cfg(test)] mod tests { - use crate::accountant::database_access_objects::dao_utils::{from_time_t, to_time_t}; - use crate::accountant::database_access_objects::payable_dao::{PayableAccount, PendingPayable}; - use crate::accountant::database_access_objects::receivable_dao::ReceivableAccount; + use crate::accountant::db_access_objects::dao_utils::{from_time_t, to_time_t}; + use crate::accountant::db_access_objects::payable_dao::{PayableAccount, PendingPayable}; + use crate::accountant::db_access_objects::receivable_dao::ReceivableAccount; use crate::accountant::scanners::scanners_utils::payable_scanner_utils::PayableTransactingErrorEnum::{ LocallyCausedError, RemotelyCausedErrors, }; diff --git a/node/src/accountant/test_utils.rs b/node/src/accountant/test_utils.rs index 7ecfc125a..2bd51ccdd 100644 --- a/node/src/accountant/test_utils.rs +++ b/node/src/accountant/test_utils.rs @@ -2,15 +2,15 @@ #![cfg(test)] -use crate::accountant::database_access_objects::banned_dao::{BannedDao, BannedDaoFactory}; -use crate::accountant::database_access_objects::dao_utils::{from_time_t, to_time_t, CustomQuery}; -use crate::accountant::database_access_objects::payable_dao::{ +use crate::accountant::db_access_objects::banned_dao::{BannedDao, BannedDaoFactory}; +use crate::accountant::db_access_objects::dao_utils::{from_time_t, to_time_t, CustomQuery}; +use crate::accountant::db_access_objects::payable_dao::{ PayableAccount, PayableDao, PayableDaoError, PayableDaoFactory, }; -use crate::accountant::database_access_objects::pending_payable_dao::{ +use crate::accountant::db_access_objects::pending_payable_dao::{ PendingPayableDao, PendingPayableDaoError, PendingPayableDaoFactory, }; -use crate::accountant::database_access_objects::receivable_dao::{ +use crate::accountant::db_access_objects::receivable_dao::{ ReceivableAccount, ReceivableDao, ReceivableDaoError, ReceivableDaoFactory, }; use crate::accountant::scanners::scanners_utils::payable_scanner_utils::PayableThresholdsGauge; diff --git a/node/src/actor_system_factory.rs b/node/src/actor_system_factory.rs index 8ea9c7646..c1252b31e 100644 --- a/node/src/actor_system_factory.rs +++ b/node/src/actor_system_factory.rs @@ -10,9 +10,7 @@ use super::stream_handler_pool::StreamHandlerPool; use super::stream_handler_pool::StreamHandlerPoolSubs; use super::stream_messages::PoolBindMessage; use super::ui_gateway::UiGateway; -use crate::accountant::database_access_objects::banned_dao::{ - BannedCacheLoader, BannedCacheLoaderReal, -}; +use crate::accountant::db_access_objects::banned_dao::{BannedCacheLoader, BannedCacheLoaderReal}; use crate::blockchain::blockchain_bridge::BlockchainBridge; use crate::bootstrapper::CryptDEPair; use crate::database::db_initializer::DbInitializationConfig; @@ -1929,7 +1927,7 @@ mod tests { let file_path = current_dir.join(PathBuf::from_iter([ "src", "accountant", - "database_access_objects", + "db_access_objects", "receivable_dao.rs", ])); let file = match File::open(file_path) { diff --git a/node/src/blockchain/bip32.rs b/node/src/blockchain/bip32.rs index 1234d0d03..6b869d96b 100644 --- a/node/src/blockchain/bip32.rs +++ b/node/src/blockchain/bip32.rs @@ -11,32 +11,32 @@ use std::hash::{Hash, Hasher}; use std::num::NonZeroU32; use tiny_hderive::bip32::ExtendedPrivKey; -#[allow(clippy::upper_case_acronyms)] #[derive(Debug)] -pub struct Bip32ECKeyProvider { +#[allow(clippy::upper_case_acronyms)] +pub struct Bip32EncryptionKeyProvider { secret_raw: Vec, } #[allow(clippy::from_over_into)] -impl Into for &Bip32ECKeyProvider { +impl Into for &Bip32EncryptionKeyProvider { fn into(self) -> Secp256k1SecretKey { secp256k1secrets::key::SecretKey::from_slice(&self.secret_raw).expect("internal error") } } #[allow(clippy::from_over_into)] -impl Into for &Bip32ECKeyProvider { +impl Into for &Bip32EncryptionKeyProvider { fn into(self) -> EthsignSecretKey { EthsignSecretKey::from_raw(self.secret_raw.as_ref()).expect("internal error") } } -impl Bip32ECKeyProvider { +impl Bip32EncryptionKeyProvider { const SECRET_KEY_LENGTH: usize = 32; pub fn from_raw_secret(secret_raw: &[u8]) -> Result { Self::validate_raw_input(secret_raw)?; - Ok(Bip32ECKeyProvider { + Ok(Bip32EncryptionKeyProvider { secret_raw: secret_raw.to_vec(), }) } @@ -83,7 +83,7 @@ impl Bip32ECKeyProvider { } } -impl TryFrom<(&[u8], &str)> for Bip32ECKeyProvider { +impl TryFrom<(&[u8], &str)> for Bip32EncryptionKeyProvider { type Error = String; fn try_from(seed_path: (&[u8], &str)) -> Result { @@ -99,7 +99,7 @@ impl TryFrom<(&[u8], &str)> for Bip32ECKeyProvider { } } -impl<'de> Deserialize<'de> for Bip32ECKeyProvider { +impl<'de> Deserialize<'de> for Bip32EncryptionKeyProvider { fn deserialize(deserializer: D) -> Result>::Error> where D: Deserializer<'de>, @@ -112,7 +112,7 @@ impl<'de> Deserialize<'de> for Bip32ECKeyProvider { } } -impl Serialize for Bip32ECKeyProvider { +impl Serialize for Bip32EncryptionKeyProvider { fn serialize(&self, serializer: S) -> Result<::Ok, ::Error> where S: Serializer, @@ -128,15 +128,15 @@ impl Serialize for Bip32ECKeyProvider { } } -impl PartialEq for Bip32ECKeyProvider { - fn eq(&self, other: &Bip32ECKeyProvider) -> bool { +impl PartialEq for Bip32EncryptionKeyProvider { + fn eq(&self, other: &Bip32EncryptionKeyProvider) -> bool { self.public_key().bytes().as_ref() == other.public_key().bytes().as_ref() } } -impl Eq for Bip32ECKeyProvider {} +impl Eq for Bip32EncryptionKeyProvider {} -impl Hash for Bip32ECKeyProvider { +impl Hash for Bip32EncryptionKeyProvider { fn hash(&self, state: &mut H) { self.public_key().bytes().hash(state); } @@ -153,7 +153,7 @@ mod tests { #[test] fn constants_have_correct_values() { - assert_eq!(Bip32ECKeyProvider::SECRET_KEY_LENGTH, 32); + assert_eq!(Bip32EncryptionKeyProvider::SECRET_KEY_LENGTH, 32); } #[test] @@ -165,7 +165,7 @@ mod tests { ) .unwrap(); let seed = Seed::new(&mnemonic, "Test123!"); - let bip32eckey_provider = Bip32ECKeyProvider::try_from(( + let bip32eckey_provider = Bip32EncryptionKeyProvider::try_from(( seed.as_ref(), DEFAULT_CONSUMING_DERIVATION_PATH.as_str(), )) @@ -186,9 +186,11 @@ mod tests { ) .unwrap(); let seed = Seed::new(&mnemonic, "Test123!"); - let bip32eckey_provider = - Bip32ECKeyProvider::try_from((seed.as_ref(), DEFAULT_EARNING_DERIVATION_PATH.as_str())) - .unwrap(); + let bip32eckey_provider = Bip32EncryptionKeyProvider::try_from(( + seed.as_ref(), + DEFAULT_EARNING_DERIVATION_PATH.as_str(), + )) + .unwrap(); let address: Address = bip32eckey_provider.address(); let expected_address: Address = serde_json::from_str::
("\"0x20eF925bBbFca786bd426BaED8c6Ae45e4284e12\"") @@ -207,7 +209,7 @@ mod tests { let mnemonic = Mnemonic::from_phrase(phrase, Language::English).unwrap(); let seed = Seed::new(&mnemonic, ""); - let key_provider = Bip32ECKeyProvider::try_from(( + let key_provider = Bip32EncryptionKeyProvider::try_from(( seed.as_bytes(), DEFAULT_CONSUMING_DERIVATION_PATH.as_str(), )) @@ -248,7 +250,7 @@ mod tests { .unwrap(); let seed = Seed::new(&mnemonic, "Test123!"); assert_eq!( - Bip32ECKeyProvider::try_from((seed.as_ref(), "")).unwrap_err(), + Bip32EncryptionKeyProvider::try_from((seed.as_ref(), "")).unwrap_err(), "InvalidDerivationPath".to_string() ); } @@ -256,23 +258,26 @@ mod tests { #[test] fn bip32_try_from_errors_with_empty_seed() { assert_eq!( - Bip32ECKeyProvider::try_from(("".as_ref(), DEFAULT_CONSUMING_DERIVATION_PATH.as_str())) - .unwrap_err(), + Bip32EncryptionKeyProvider::try_from(( + "".as_ref(), + DEFAULT_CONSUMING_DERIVATION_PATH.as_str() + )) + .unwrap_err(), "Invalid Seed Length: 0".to_string() ); } - fn keypair_a() -> Bip32ECKeyProvider { + fn keypair_a() -> Bip32EncryptionKeyProvider { let numbers = (0u8..32u8).collect::>(); - Bip32ECKeyProvider::from_raw_secret(&numbers).unwrap() + Bip32EncryptionKeyProvider::from_raw_secret(&numbers).unwrap() } - fn keypair_b() -> Bip32ECKeyProvider { + fn keypair_b() -> Bip32EncryptionKeyProvider { let numbers = (1u8..33u8).collect::>(); - Bip32ECKeyProvider::from_raw_secret(&numbers).unwrap() + Bip32EncryptionKeyProvider::from_raw_secret(&numbers).unwrap() } - fn hash(keypair: &Bip32ECKeyProvider) -> u64 { + fn hash(keypair: &Bip32EncryptionKeyProvider) -> u64 { let mut hasher = DefaultHasher::new(); keypair.hash(&mut hasher); hasher.finish() @@ -304,7 +309,7 @@ mod tests { fn from_raw_secret_validates_correct_length_happy_path() { let secret_raw: Vec = (0..32u8).collect(); - let result = Bip32ECKeyProvider::from_raw_secret(secret_raw.as_slice()).unwrap(); + let result = Bip32EncryptionKeyProvider::from_raw_secret(secret_raw.as_slice()).unwrap(); assert_eq!(result.secret_raw, secret_raw) } @@ -313,7 +318,7 @@ mod tests { fn from_raw_secret_complains_about_input_too_long() { let secret_raw: Vec = (0..33u8).collect(); - let result = Bip32ECKeyProvider::from_raw_secret(secret_raw.as_slice()); + let result = Bip32EncryptionKeyProvider::from_raw_secret(secret_raw.as_slice()); assert_eq!( result, @@ -325,7 +330,7 @@ mod tests { fn from_raw_secret_complains_about_input_too_short() { let secret_raw: Vec = (0..31u8).collect(); - let result = Bip32ECKeyProvider::from_raw_secret(secret_raw.as_slice()); + let result = Bip32EncryptionKeyProvider::from_raw_secret(secret_raw.as_slice()); assert_eq!( result, diff --git a/node/src/blockchain/blockchain_bridge.rs b/node/src/blockchain/blockchain_bridge.rs index d3bb43cf4..ccae38592 100644 --- a/node/src/blockchain/blockchain_bridge.rs +++ b/node/src/blockchain/blockchain_bridge.rs @@ -495,11 +495,11 @@ struct PendingTxInfo { #[cfg(test)] mod tests { use super::*; - use crate::accountant::database_access_objects::dao_utils::from_time_t; - use crate::accountant::database_access_objects::payable_dao::{PayableAccount, PendingPayable}; + use crate::accountant::db_access_objects::dao_utils::from_time_t; + use crate::accountant::db_access_objects::payable_dao::{PayableAccount, PendingPayable}; use crate::accountant::test_utils::make_pending_payable_fingerprint; use crate::accountant::ConsumingWalletBalancesAndQualifiedPayables; - use crate::blockchain::bip32::Bip32ECKeyProvider; + use crate::blockchain::bip32::Bip32EncryptionKeyProvider; use crate::blockchain::blockchain_interface::ProcessedPayableFallible::Correct; use crate::blockchain::blockchain_interface::{ BlockchainError, BlockchainTransaction, RetrievedBlockchainTransactions, @@ -548,7 +548,8 @@ mod tests { let secret: Vec = "cc46befe8d169b89db447bd725fc2368b12542113555302598430cb5d5c74ea9" .from_hex() .unwrap(); - let consuming_wallet = Wallet::from(Bip32ECKeyProvider::from_raw_secret(&secret).unwrap()); + let consuming_wallet = + Wallet::from(Bip32EncryptionKeyProvider::from_raw_secret(&secret).unwrap()); let subject = BlockchainBridge::new( stub_bi(), Box::new(configure_default_persistent_config(ZERO)), diff --git a/node/src/blockchain/blockchain_interface.rs b/node/src/blockchain/blockchain_interface.rs index de03b40e3..d8bf0d411 100644 --- a/node/src/blockchain/blockchain_interface.rs +++ b/node/src/blockchain/blockchain_interface.rs @@ -1,7 +1,7 @@ // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. use crate::accountant::comma_joined_stringifiable; -use crate::accountant::database_access_objects::payable_dao::{PayableAccount, PendingPayable}; +use crate::accountant::db_access_objects::payable_dao::{PayableAccount, PendingPayable}; use crate::blockchain::batch_payable_tools::{BatchPayableTools, BatchPayableToolsReal}; use crate::blockchain::blockchain_bridge::PendingPayableFingerprintSeeds; use crate::blockchain::blockchain_interface::BlockchainError::{ @@ -746,12 +746,12 @@ where #[cfg(test)] mod tests { use super::*; - use crate::accountant::database_access_objects::dao_utils::from_time_t; + use crate::accountant::db_access_objects::dao_utils::from_time_t; use crate::accountant::gwei_to_wei; use crate::accountant::test_utils::{ make_payable_account, make_payable_account_with_wallet_and_balance_and_timestamp_opt, }; - use crate::blockchain::bip32::Bip32ECKeyProvider; + use crate::blockchain::bip32::Bip32EncryptionKeyProvider; use crate::blockchain::blockchain_interface::ProcessedPayableFallible::{Correct, Failed}; use crate::blockchain::test_utils::{ make_default_signed_transaction, make_fake_event_loop_handle, make_tx_hash, @@ -1512,7 +1512,7 @@ mod tests { let initiate_fingerprints_recipient = accountant.start().recipient(); let consuming_wallet_secret = b"consuming_wallet_0123456789abcde"; let secret_key = - (&Bip32ECKeyProvider::from_raw_secret(consuming_wallet_secret).unwrap()).into(); + (&Bip32EncryptionKeyProvider::from_raw_secret(consuming_wallet_secret).unwrap()).into(); let batch_wide_timestamp_expected = SystemTime::now(); let transport = TestTransport::default().initiate_reference_counter(&reference_counter_arc); let chain = Chain::EthMainnet; @@ -1626,7 +1626,8 @@ mod tests { check_web3_origin(&web3); assert_eq!( secret, - (&Bip32ECKeyProvider::from_raw_secret(&consuming_wallet_secret.keccak256()).unwrap()) + (&Bip32EncryptionKeyProvider::from_raw_secret(&consuming_wallet_secret.keccak256()) + .unwrap()) .into() ); let (second_transaction_params, web3_from_st_call, secret) = @@ -1635,7 +1636,8 @@ mod tests { check_web3_origin(&web3_from_st_call); assert_eq!( secret, - (&Bip32ECKeyProvider::from_raw_secret(&consuming_wallet_secret.keccak256()).unwrap()) + (&Bip32EncryptionKeyProvider::from_raw_secret(&consuming_wallet_secret.keccak256()) + .unwrap()) .into() ); assert!(sign_transaction_params.is_empty()); @@ -1773,8 +1775,10 @@ mod tests { assert!(transaction_params.gas <= U256::from(not_above_this_value)); assert_eq!( secret, - (&Bip32ECKeyProvider::from_raw_secret(&consuming_wallet_secret_raw_bytes.keccak256()) - .unwrap()) + (&Bip32EncryptionKeyProvider::from_raw_secret( + &consuming_wallet_secret_raw_bytes.keccak256() + ) + .unwrap()) .into() ); } @@ -1932,7 +1936,7 @@ mod tests { } fn test_consuming_wallet_with_secret() -> Wallet { - let key_pair = Bip32ECKeyProvider::from_raw_secret( + let key_pair = Bip32EncryptionKeyProvider::from_raw_secret( &decode_hex("97923d8fd8de4a00f912bfb77ef483141dec551bd73ea59343ef5c4aac965d04") .unwrap(), ) @@ -2176,7 +2180,8 @@ mod tests { .zip(constant_parts) { let secret = Wallet::from( - Bip32ECKeyProvider::from_raw_secret(&signed.private_key.0.as_ref()).unwrap(), + Bip32EncryptionKeyProvider::from_raw_secret(&signed.private_key.0.as_ref()) + .unwrap(), ) .prepare_secp256k1_secret() .unwrap(); diff --git a/node/src/blockchain/payer.rs b/node/src/blockchain/payer.rs index 3979e054e..f794ee403 100644 --- a/node/src/blockchain/payer.rs +++ b/node/src/blockchain/payer.rs @@ -1,5 +1,5 @@ // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. -use crate::accountant::database_access_objects::banned_dao::BAN_CACHE; +use crate::accountant::db_access_objects::banned_dao::BAN_CACHE; use crate::blockchain::signature::SerializableSignature; use crate::sub_lib::wallet::Wallet; use ethsign::Signature; diff --git a/node/src/blockchain/test_utils.rs b/node/src/blockchain/test_utils.rs index 23bc6a2f9..007a5b51b 100644 --- a/node/src/blockchain/test_utils.rs +++ b/node/src/blockchain/test_utils.rs @@ -20,7 +20,7 @@ use std::fmt::Debug; use std::sync::{Arc, Mutex}; use std::time::SystemTime; -use crate::accountant::database_access_objects::payable_dao::PayableAccount; +use crate::accountant::db_access_objects::payable_dao::PayableAccount; use crate::blockchain::batch_payable_tools::BatchPayableTools; use web3::transports::{Batch, EventLoopHandle, Http}; use web3::types::{Address, Bytes, SignedTransaction, TransactionParameters, U256}; diff --git a/node/src/database/db_migrations/migrations/migration_4_to_5.rs b/node/src/database/db_migrations/migrations/migration_4_to_5.rs index 208a1018f..016a49196 100644 --- a/node/src/database/db_migrations/migrations/migration_4_to_5.rs +++ b/node/src/database/db_migrations/migrations/migration_4_to_5.rs @@ -1,6 +1,6 @@ // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. -use crate::accountant::database_access_objects::dao_utils::VigilantRusqliteFlatten; +use crate::accountant::db_access_objects::dao_utils::VigilantRusqliteFlatten; use crate::database::db_migrations::db_migrator::DatabaseMigration; use crate::database::db_migrations::migrator_utils::DBMigDeclarator; @@ -76,7 +76,7 @@ impl DatabaseMigration for Migrate_4_to_5 { #[cfg(test)] mod tests { - use crate::accountant::database_access_objects::dao_utils::{from_time_t, to_time_t}; + use crate::accountant::db_access_objects::dao_utils::{from_time_t, to_time_t}; use crate::database::connection_wrapper::{ConnectionWrapper, ConnectionWrapperReal}; use crate::database::db_initializer::{ DbInitializationConfig, DbInitializer, DbInitializerReal, ExternalData, DATABASE_FILE, diff --git a/node/src/database/db_migrations/migrations/migration_6_to_7.rs b/node/src/database/db_migrations/migrations/migration_6_to_7.rs index 3a1606281..08a9a4544 100644 --- a/node/src/database/db_migrations/migrations/migration_6_to_7.rs +++ b/node/src/database/db_migrations/migrations/migration_6_to_7.rs @@ -1,7 +1,7 @@ // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. -use crate::accountant::big_int_processing::big_int_divider::BigIntDivider; -use crate::accountant::database_access_objects::dao_utils::VigilantRusqliteFlatten; +use crate::accountant::db_access_objects::dao_utils::VigilantRusqliteFlatten; +use crate::accountant::db_big_integer::big_int_divider::BigIntDivider; use crate::accountant::gwei_to_wei; use crate::database::db_migrations::db_migrator::DatabaseMigration; use crate::database::db_migrations::migrator_utils::{ diff --git a/node/src/db_config/config_dao.rs b/node/src/db_config/config_dao.rs index e19aacda6..6bd5aef9c 100644 --- a/node/src/db_config/config_dao.rs +++ b/node/src/db_config/config_dao.rs @@ -1,5 +1,5 @@ // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. -use crate::accountant::database_access_objects::dao_utils::DaoFactoryReal; +use crate::accountant::db_access_objects::dao_utils::DaoFactoryReal; use crate::database::connection_wrapper::ConnectionWrapper; use rusqlite::types::ToSql; use rusqlite::{Row, Rows, Statement}; diff --git a/node/src/db_config/persistent_configuration.rs b/node/src/db_config/persistent_configuration.rs index 3420ec688..6cdef5e7c 100644 --- a/node/src/db_config/persistent_configuration.rs +++ b/node/src/db_config/persistent_configuration.rs @@ -2,7 +2,7 @@ #[cfg(test)] use crate::arbitrary_id_stamp_in_trait; -use crate::blockchain::bip32::Bip32ECKeyProvider; +use crate::blockchain::bip32::Bip32EncryptionKeyProvider; use crate::blockchain::bip39::{Bip39, Bip39Error}; use crate::database::connection_wrapper::ConnectionWrapper; use crate::db_config::config_dao::{ConfigDao, ConfigDaoError, ConfigDaoReal, ConfigDaoRecord}; @@ -221,13 +221,15 @@ impl PersistentConfiguration for PersistentConfigurationReal { "Database corruption {:?}: consuming private key is not hex, but '{}'", e, key ), - Ok(bytes) => match Bip32ECKeyProvider::from_raw_secret(bytes.as_slice()) { - Err(e) => panic!( - "Database corruption {:?}: consuming private key is invalid", - e - ), - Ok(pair) => Wallet::from(pair), - }, + Ok(bytes) => { + match Bip32EncryptionKeyProvider::from_raw_secret(bytes.as_slice()) { + Err(e) => panic!( + "Database corruption {:?}: consuming private key is invalid", + e + ), + Ok(pair) => Wallet::from(pair), + } + } }) }) } @@ -1058,7 +1060,7 @@ mod tests { let consuming_private_key = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"; let consuming_wallet = Wallet::from( - Bip32ECKeyProvider::from_raw_secret( + Bip32EncryptionKeyProvider::from_raw_secret( consuming_private_key .from_hex::>() .unwrap() @@ -1191,7 +1193,7 @@ mod tests { let earning_private_key = ExtendedPrivKey::derive(seed_bytes.as_slice(), derivation_path.as_str()).unwrap(); let earning_key_pair = - Bip32ECKeyProvider::from_raw_secret(&earning_private_key.secret()).unwrap(); + Bip32EncryptionKeyProvider::from_raw_secret(&earning_private_key.secret()).unwrap(); let earning_wallet = Wallet::from(earning_key_pair); let earning_wallet_address = earning_wallet.to_string(); ( diff --git a/node/src/hopper/routing_service.rs b/node/src/hopper/routing_service.rs index 6335975a7..57d2a54d3 100644 --- a/node/src/hopper/routing_service.rs +++ b/node/src/hopper/routing_service.rs @@ -500,7 +500,7 @@ impl RoutingService { #[cfg(test)] mod tests { use super::*; - use crate::accountant::database_access_objects::banned_dao::BAN_CACHE; + use crate::accountant::db_access_objects::banned_dao::BAN_CACHE; use crate::bootstrapper::Bootstrapper; use crate::neighborhood::gossip::{GossipBuilder, Gossip_0v1}; use crate::node_test_utils::check_timestamp; diff --git a/node/src/node_configurator/configurator.rs b/node/src/node_configurator/configurator.rs index 7a9da5f62..391b348a9 100644 --- a/node/src/node_configurator/configurator.rs +++ b/node/src/node_configurator/configurator.rs @@ -17,7 +17,7 @@ use masq_lib::ui_gateway::{ MessageBody, MessagePath, MessageTarget, NodeFromUiMessage, NodeToUiMessage, }; -use crate::blockchain::bip32::Bip32ECKeyProvider; +use crate::blockchain::bip32::Bip32EncryptionKeyProvider; use crate::blockchain::bip39::Bip39; use crate::database::db_initializer::DbInitializationConfig; use crate::database::db_initializer::{DbInitializer, DbInitializerReal}; @@ -478,7 +478,7 @@ impl Configurator { } fn generate_wallet(seed: &Seed, derivation_path: &str) -> Result { - match Bip32ECKeyProvider::try_from((seed.as_bytes(), derivation_path)) { + match Bip32EncryptionKeyProvider::try_from((seed.as_bytes(), derivation_path)) { Err(e) => Err(( DERIVATION_PATH_ERROR, format!("Bad derivation-path syntax: {}: {}", e, derivation_path), @@ -563,7 +563,7 @@ impl Configurator { Ok(bytes) => bytes, Err(e) => panic! ("Database corruption: consuming wallet private key '{}' cannot be converted from hexadecimal: {:?}", private_key_hex, e), }; - let key_pair = match Bip32ECKeyProvider::from_raw_secret(private_key_bytes.as_slice()) { + let key_pair = match Bip32EncryptionKeyProvider::from_raw_secret(private_key_bytes.as_slice()) { Ok(pair) => pair, Err(e) => panic!("Database corruption: consuming wallet private key '{}' is invalid: {:?}", private_key_hex, e), }; @@ -827,7 +827,7 @@ mod tests { use masq_lib::test_utils::logging::{init_test_logging, TestLogHandler}; use super::*; - use crate::blockchain::bip32::Bip32ECKeyProvider; + use crate::blockchain::bip32::Bip32EncryptionKeyProvider; use crate::blockchain::bip39::Bip39; use crate::blockchain::test_utils::make_meaningless_phrase_words; use crate::database::db_initializer::{DbInitializer, DbInitializerReal}; @@ -1299,7 +1299,7 @@ mod tests { ExtendedPrivKey::derive(seed.as_slice(), derivation_path(0, 4).as_str()).unwrap(); let consuming_private_key = consuming_epk.secret().to_hex::().to_uppercase(); let consuming_wallet = Wallet::from( - Bip32ECKeyProvider::try_from((seed.as_slice(), derivation_path(0, 4).as_str())) + Bip32EncryptionKeyProvider::try_from((seed.as_slice(), derivation_path(0, 4).as_str())) .unwrap(), ); assert_eq!( @@ -1315,7 +1315,7 @@ mod tests { .unwrap() ); let earning_wallet = Wallet::from( - Bip32ECKeyProvider::try_from((seed.as_slice(), derivation_path(0, 5).as_str())) + Bip32EncryptionKeyProvider::try_from((seed.as_slice(), derivation_path(0, 5).as_str())) .unwrap(), ); assert_eq!( @@ -1693,7 +1693,7 @@ mod tests { ) .unwrap(); let earning_keypair = - Bip32ECKeyProvider::from_raw_secret(&earning_private_key.secret()).unwrap(); + Bip32EncryptionKeyProvider::from_raw_secret(&earning_private_key.secret()).unwrap(); let earning_wallet = Wallet::from(earning_keypair); let set_wallet_info_params = set_wallet_info_params_arc.lock().unwrap(); assert_eq!( @@ -2311,7 +2311,7 @@ mod tests { "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF".to_string(); let consuming_wallet_address = format!( "{:?}", - Bip32ECKeyProvider::from_raw_secret( + Bip32EncryptionKeyProvider::from_raw_secret( consuming_wallet_private_key .from_hex::>() .unwrap() diff --git a/node/src/node_configurator/node_configurator_standard.rs b/node/src/node_configurator/node_configurator_standard.rs index 1094f7f18..ad870caee 100644 --- a/node/src/node_configurator/node_configurator_standard.rs +++ b/node/src/node_configurator/node_configurator_standard.rs @@ -286,7 +286,7 @@ fn configure_database( #[cfg(test)] mod tests { use super::*; - use crate::blockchain::bip32::Bip32ECKeyProvider; + use crate::blockchain::bip32::Bip32EncryptionKeyProvider; use crate::bootstrapper::{BootstrapperConfig, RealUser}; use crate::database::db_initializer::{DbInitializer, DbInitializerReal}; use crate::db_config::config_dao::ConfigDaoReal; @@ -536,7 +536,8 @@ mod tests { let consuming_private_key_bytes: Vec = consuming_private_key.from_hex().unwrap(); let consuming_keypair = - Bip32ECKeyProvider::from_raw_secret(consuming_private_key_bytes.as_ref()).unwrap(); + Bip32EncryptionKeyProvider::from_raw_secret(consuming_private_key_bytes.as_ref()) + .unwrap(); assert_eq!( bootstrapper_config.consuming_wallet_opt, Some(Wallet::from(consuming_keypair)), diff --git a/node/src/node_configurator/unprivileged_parse_args_configuration.rs b/node/src/node_configurator/unprivileged_parse_args_configuration.rs index 2d86fb1ad..d522ff782 100644 --- a/node/src/node_configurator/unprivileged_parse_args_configuration.rs +++ b/node/src/node_configurator/unprivileged_parse_args_configuration.rs @@ -1,7 +1,7 @@ // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. use crate::accountant::DEFAULT_PENDING_TOO_LONG_SEC; -use crate::blockchain::bip32::Bip32ECKeyProvider; +use crate::blockchain::bip32::Bip32EncryptionKeyProvider; use crate::bootstrapper::BootstrapperConfig; use crate::db_config::persistent_configuration::{PersistentConfigError, PersistentConfiguration}; use crate::sub_lib::accountant::{PaymentThresholds, ScanIntervals, DEFAULT_EARNING_WALLET}; @@ -173,8 +173,8 @@ pub fn get_wallets( consuming_private_key ) }); - let key_pair = - Bip32ECKeyProvider::from_raw_secret(key_bytes.as_slice()).unwrap_or_else(|_| { + let key_pair = Bip32EncryptionKeyProvider::from_raw_secret(key_bytes.as_slice()) + .unwrap_or_else(|_| { panic!( "Wallet corruption: consuming wallet private key in invalid format: {:?}", key_bytes @@ -623,9 +623,9 @@ fn is_user_specified(multi_config: &MultiConfig, parameter: &str) -> bool { #[cfg(test)] mod tests { use super::*; - use crate::accountant::database_access_objects::dao_utils::ThresholdUtils; + use crate::accountant::db_access_objects::dao_utils::ThresholdUtils; use crate::apps::app_node; - use crate::blockchain::bip32::Bip32ECKeyProvider; + use crate::blockchain::bip32::Bip32EncryptionKeyProvider; use crate::database::db_initializer::DbInitializationConfig; use crate::database::db_initializer::{DbInitializer, DbInitializerReal}; use crate::db_config::config_dao::{ConfigDao, ConfigDaoReal}; @@ -1558,7 +1558,8 @@ mod tests { assert_eq!( config.consuming_wallet_opt, Some(Wallet::from( - Bip32ECKeyProvider::from_raw_secret(consuming_private_key.as_slice()).unwrap() + Bip32EncryptionKeyProvider::from_raw_secret(consuming_private_key.as_slice()) + .unwrap() )), ); assert_eq!( diff --git a/node/src/sub_lib/accountant.rs b/node/src/sub_lib/accountant.rs index dc0f12c7e..1ca2c3319 100644 --- a/node/src/sub_lib/accountant.rs +++ b/node/src/sub_lib/accountant.rs @@ -1,8 +1,8 @@ // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. -use crate::accountant::database_access_objects::banned_dao::BannedDaoFactory; -use crate::accountant::database_access_objects::payable_dao::PayableDaoFactory; -use crate::accountant::database_access_objects::pending_payable_dao::PendingPayableDaoFactory; -use crate::accountant::database_access_objects::receivable_dao::ReceivableDaoFactory; +use crate::accountant::db_access_objects::banned_dao::BannedDaoFactory; +use crate::accountant::db_access_objects::payable_dao::PayableDaoFactory; +use crate::accountant::db_access_objects::pending_payable_dao::PendingPayableDaoFactory; +use crate::accountant::db_access_objects::receivable_dao::ReceivableDaoFactory; use crate::accountant::{ checked_conversion, Accountant, ConsumingWalletBalancesAndQualifiedPayables, ReceivedPayments, ReportTransactionReceipts, ScanError, SentPayables, diff --git a/node/src/sub_lib/blockchain_bridge.rs b/node/src/sub_lib/blockchain_bridge.rs index 513d23835..be55eb7de 100644 --- a/node/src/sub_lib/blockchain_bridge.rs +++ b/node/src/sub_lib/blockchain_bridge.rs @@ -1,6 +1,6 @@ // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. -use crate::accountant::database_access_objects::payable_dao::PayableAccount; +use crate::accountant::db_access_objects::payable_dao::PayableAccount; use crate::accountant::{RequestTransactionReceipts, ResponseSkeleton, SkeletonOptHolder}; use crate::blockchain::blockchain_bridge::RetrieveTransactions; use crate::sub_lib::peer_actors::BindMessage; diff --git a/node/src/sub_lib/wallet.rs b/node/src/sub_lib/wallet.rs index 59898ee44..bf925cc72 100644 --- a/node/src/sub_lib/wallet.rs +++ b/node/src/sub_lib/wallet.rs @@ -1,5 +1,5 @@ // Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved. -use crate::blockchain::bip32::Bip32ECKeyProvider; +use crate::blockchain::bip32::Bip32EncryptionKeyProvider; use crate::blockchain::payer::Payer; use crate::sub_lib::cryptde; use crate::sub_lib::cryptde::PublicKey as CryptdePublicKey; @@ -38,7 +38,7 @@ impl Display for WalletError { #[derive(Debug)] pub enum WalletKind { Address(Address), - SecretKey(Bip32ECKeyProvider), + SecretKey(Bip32EncryptionKeyProvider), PublicKey(PublicKey), Uninitialized, } @@ -48,7 +48,7 @@ impl Clone for WalletKind { match self { WalletKind::Address(address) => WalletKind::Address(H160(address.0)), WalletKind::SecretKey(keypair) => WalletKind::SecretKey( - Bip32ECKeyProvider::from_raw_secret(keypair.clone_secret().as_ref()) + Bip32EncryptionKeyProvider::from_raw_secret(keypair.clone_secret().as_ref()) .expect("failed to clone once checked secret"), ), WalletKind::PublicKey(public) => WalletKind::PublicKey( @@ -233,8 +233,8 @@ impl From for Wallet { } } -impl From for Wallet { - fn from(keypair: Bip32ECKeyProvider) -> Self { +impl From for Wallet { + fn from(keypair: Bip32EncryptionKeyProvider) -> Self { Self { kind: WalletKind::SecretKey(keypair), } @@ -265,10 +265,10 @@ impl FromSql for Wallet { } } -impl TryInto for Wallet { +impl TryInto for Wallet { type Error = String; - fn try_into(self) -> Result { + fn try_into(self) -> Result { match self.kind { WalletKind::SecretKey(keypair) => Ok(keypair), _ => Err("Wallet contains no secret key: can't convert to Bip32KeyPair".to_string()), @@ -493,8 +493,11 @@ mod tests { let derivation_path = derivation_path(0, 5); let expected_seed = make_meaningless_seed(); let wallet = Wallet::from( - Bip32ECKeyProvider::try_from((expected_seed.as_bytes(), derivation_path.as_str())) - .unwrap(), + Bip32EncryptionKeyProvider::try_from(( + expected_seed.as_bytes(), + derivation_path.as_str(), + )) + .unwrap(), ); let result = wallet.string_address_from_keypair(); @@ -529,7 +532,7 @@ mod tests { ) .unwrap(); let seed = Seed::new(&mnemonic, "Test123!"); - let keypair = Bip32ECKeyProvider::try_from(( + let keypair = Bip32EncryptionKeyProvider::try_from(( seed.as_ref(), DEFAULT_CONSUMING_DERIVATION_PATH.as_str(), )) @@ -552,7 +555,7 @@ mod tests { ) .unwrap(); let seed = Seed::new(&mnemonic, "Test123!"); - let keypair = Bip32ECKeyProvider::try_from(( + let keypair = Bip32EncryptionKeyProvider::try_from(( seed.as_ref(), DEFAULT_CONSUMING_DERIVATION_PATH.as_str(), )) @@ -647,15 +650,17 @@ mod tests { #[test] fn can_convert_to_keypair_if_came_from_keypair() { let secret_key_text = "0000000000000000000000003f69f9efd4f2592fd70be8c32ecd9dce71c472fc"; - let keypair = - Bip32ECKeyProvider::from_raw_secret(&secret_key_text.from_hex::>().unwrap()) - .unwrap(); - let expected_keypair = - Bip32ECKeyProvider::from_raw_secret(&secret_key_text.from_hex::>().unwrap()) - .unwrap(); + let keypair = Bip32EncryptionKeyProvider::from_raw_secret( + &secret_key_text.from_hex::>().unwrap(), + ) + .unwrap(); + let expected_keypair = Bip32EncryptionKeyProvider::from_raw_secret( + &secret_key_text.from_hex::>().unwrap(), + ) + .unwrap(); let subject = Wallet::from(keypair); - let result: Bip32ECKeyProvider = subject.try_into().unwrap(); + let result: Bip32EncryptionKeyProvider = subject.try_into().unwrap(); assert_eq!(result, expected_keypair); } @@ -664,7 +669,7 @@ mod tests { fn cant_convert_to_keypair_if_didnt_come_from_keypair() { let subject = Wallet::from_str("0x3f69f9efd4f2592fd70be8c32ecd9dce71c472fc").unwrap(); - let result: Result = subject.try_into(); + let result: Result = subject.try_into(); assert_eq!( result, @@ -698,14 +703,14 @@ mod tests { } } - fn keypair_a() -> Bip32ECKeyProvider { + fn keypair_a() -> Bip32EncryptionKeyProvider { let numbers = (0u8..32u8).collect::>(); - Bip32ECKeyProvider::from_raw_secret(&numbers).unwrap() + Bip32EncryptionKeyProvider::from_raw_secret(&numbers).unwrap() } - fn keypair_b() -> Bip32ECKeyProvider { + fn keypair_b() -> Bip32EncryptionKeyProvider { let numbers = (1u8..33u8).collect::>(); - Bip32ECKeyProvider::from_raw_secret(&numbers).unwrap() + Bip32EncryptionKeyProvider::from_raw_secret(&numbers).unwrap() } fn hash(wallet: &Wallet) -> u64 { diff --git a/node/src/test_utils/database_utils.rs b/node/src/test_utils/database_utils.rs index 9672eefd4..1fe8b94f3 100644 --- a/node/src/test_utils/database_utils.rs +++ b/node/src/test_utils/database_utils.rs @@ -2,7 +2,7 @@ #![cfg(test)] -use crate::accountant::database_access_objects::dao_utils::VigilantRusqliteFlatten; +use crate::accountant::db_access_objects::dao_utils::VigilantRusqliteFlatten; use crate::database::connection_wrapper::ConnectionWrapper; use crate::database::db_initializer::ExternalData; diff --git a/node/src/test_utils/mod.rs b/node/src/test_utils/mod.rs index 3dfd8839e..340c9b5e7 100644 --- a/node/src/test_utils/mod.rs +++ b/node/src/test_utils/mod.rs @@ -15,7 +15,7 @@ pub mod recorder_stop_conditions; pub mod stream_connector_mock; pub mod tcp_wrapper_mocks; pub mod tokio_wrapper_mocks; -use crate::blockchain::bip32::Bip32ECKeyProvider; +use crate::blockchain::bip32::Bip32EncryptionKeyProvider; use crate::blockchain::payer::Payer; use crate::bootstrapper::CryptDEPair; use crate::sub_lib::cryptde::CryptDE; @@ -511,7 +511,8 @@ pub fn make_payer(secret: &[u8], public_key: &PublicKey) -> Payer { pub fn make_paying_wallet(secret: &[u8]) -> Wallet { let digest = secret.keccak256(); Wallet::from( - Bip32ECKeyProvider::from_raw_secret(&digest).expect("Invalid Secret for Bip32ECKeyPair"), + Bip32EncryptionKeyProvider::from_raw_secret(&digest) + .expect("Invalid Secret for Bip32ECKeyPair"), ) } diff --git a/node/tests/financials_test.rs b/node/tests/financials_test.rs index 981c81ebb..49ae24186 100644 --- a/node/tests/financials_test.rs +++ b/node/tests/financials_test.rs @@ -10,11 +10,9 @@ use masq_lib::messages::{ use masq_lib::test_utils::ui_connection::UiConnection; use masq_lib::test_utils::utils::ensure_node_home_directory_exists; use masq_lib::utils::find_free_port; -use node_lib::accountant::database_access_objects::dao_utils::{from_time_t, to_time_t}; -use node_lib::accountant::database_access_objects::payable_dao::{PayableDao, PayableDaoReal}; -use node_lib::accountant::database_access_objects::receivable_dao::{ - ReceivableDao, ReceivableDaoReal, -}; +use node_lib::accountant::db_access_objects::dao_utils::{from_time_t, to_time_t}; +use node_lib::accountant::db_access_objects::payable_dao::{PayableDao, PayableDaoReal}; +use node_lib::accountant::db_access_objects::receivable_dao::{ReceivableDao, ReceivableDaoReal}; use node_lib::accountant::gwei_to_wei; use node_lib::test_utils::make_wallet; use std::time::SystemTime;