diff --git a/sql/openmonero.sql b/sql/openmonero.sql index dcc9909..7747cd8 100644 --- a/sql/openmonero.sql +++ b/sql/openmonero.sql @@ -3,8 +3,8 @@ -- https://www.phpmyadmin.net/ -- -- Host: localhost --- Generation Time: Jan 23, 2017 at 12:11 AM --- Server version: 10.1.20-MariaDB +-- Generation Time: Feb 12, 2017 at 04:17 AM +-- Server version: 10.1.21-MariaDB -- PHP Version: 7.1.1 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; @@ -121,35 +121,6 @@ CREATE TABLE `Transactions` ( `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Stand-in structure for view `TransactionsWithOutsAndIns` --- (See below for the actual view) --- -DROP VIEW IF EXISTS `TransactionsWithOutsAndIns`; -CREATE TABLE `TransactionsWithOutsAndIns` ( -`tx_id` bigint(20) unsigned -,`account_id` bigint(20) unsigned -,`out_pub_key` varchar(64) -,`amount` bigint(20) unsigned -,`out_index` bigint(20) unsigned -,`global_index` bigint(20) unsigned -,`tx_pub_key` varchar(64) -,`timestamp` timestamp -,`key_image` varchar(64) -,`mixin` bigint(20) unsigned -); - --- -------------------------------------------------------- - --- --- Structure for view `TransactionsWithOutsAndIns` --- -DROP TABLE IF EXISTS `TransactionsWithOutsAndIns`; - -CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `TransactionsWithOutsAndIns` AS select `Inputs`.`tx_id` AS `tx_id`,`Outputs`.`account_id` AS `account_id`,`Outputs`.`out_pub_key` AS `out_pub_key`,`Outputs`.`amount` AS `amount`,`Outputs`.`out_index` AS `out_index`,`Outputs`.`global_index` AS `global_index`,`Outputs`.`tx_pub_key` AS `tx_pub_key`,`Outputs`.`timestamp` AS `timestamp`,`Inputs`.`key_image` AS `key_image`,`Outputs`.`mixin` AS `mixin` from (`Inputs` join `Outputs` on((`Inputs`.`output_id` = `Outputs`.`id`))) ; - -- -- Indexes for dumped tables -- @@ -202,17 +173,17 @@ ALTER TABLE `Transactions` -- AUTO_INCREMENT for table `Accounts` -- ALTER TABLE `Accounts` - MODIFY `id` bigint(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; + MODIFY `id` bigint(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6; -- -- AUTO_INCREMENT for table `Inputs` -- ALTER TABLE `Inputs` - MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=117; + MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=766; -- -- AUTO_INCREMENT for table `Outputs` -- ALTER TABLE `Outputs` - MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=73; + MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=384; -- -- AUTO_INCREMENT for table `Payments` -- @@ -222,7 +193,7 @@ ALTER TABLE `Payments` -- AUTO_INCREMENT for table `Transactions` -- ALTER TABLE `Transactions` - MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=115; + MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=701; -- -- Constraints for dumped tables -- diff --git a/src/MySqlAccounts.cpp b/src/MySqlAccounts.cpp index 8a5a207..fcf27d4 100644 --- a/src/MySqlAccounts.cpp +++ b/src/MySqlAccounts.cpp @@ -13,66 +13,6 @@ namespace xmreg { -MysqlTransactionWithOutsAndIns::MysqlTransactionWithOutsAndIns(shared_ptr _conn) - : conn{_conn} -{} - -bool -MysqlTransactionWithOutsAndIns::select( - const uint64_t &address_id, - vector& txs) -{ - - Query query = conn->query(XmrTransactionWithOutsAndIns::SELECT_STMT); - query.parse(); - - try - { - query.storein(txs, address_id); - - if (!txs.empty()) - { - return true; - } - } - catch (mysqlpp::Exception &e) { - MYSQL_EXCEPTION_MSG(e); - } - catch (std::exception &e) { - MYSQL_EXCEPTION_MSG(e); - } - - return false; -} - -bool -MysqlTransactionWithOutsAndIns::select_for_tx( - const uint64_t &tx_id, - vector& txs) -{ - - Query query = conn->query(XmrTransactionWithOutsAndIns::SELECT_STMT2); - query.parse(); - - try - { - query.storein(txs, tx_id); - - if (!txs.empty()) - { - return true; - } - } - catch (mysqlpp::Exception &e) { - MYSQL_EXCEPTION_MSG(e); - } - catch (std::exception &e) { - MYSQL_EXCEPTION_MSG(e); - } - - return false; -} - MysqlInputs::MysqlInputs(shared_ptr _conn): conn {_conn} {} @@ -702,7 +642,6 @@ MySqlAccounts::MySqlAccounts() mysql_out = make_shared(conn); mysql_in = make_shared(conn); mysql_payment = make_shared(conn); - mysql_tx_inout = make_shared(conn); } @@ -946,13 +885,6 @@ MySqlAccounts::select_txs_for_account_spendability_check( } -bool -MySqlAccounts::select_txs_with_inputs_and_outputs(const uint64_t& account_id, - vector& txs) -{ - return mysql_tx_inout->select(account_id, txs); -} - bool MySqlAccounts::select_outputs(const uint64_t& account_id, vector& outs) @@ -978,11 +910,6 @@ MySqlAccounts::select_inputs(const uint64_t& account_id, vector& ins) return mysql_in->select(account_id, ins); } -bool -MySqlAccounts::select_inputs_for_tx(const uint64_t& tx_id, vector& ins) -{ - return mysql_tx_inout->select_for_tx(tx_id, ins); -} bool MySqlAccounts::select_inputs_for_tx(const uint64_t& tx_id, vector& ins) diff --git a/src/MySqlAccounts.h b/src/MySqlAccounts.h index d87799b..15f653a 100644 --- a/src/MySqlAccounts.h +++ b/src/MySqlAccounts.h @@ -33,24 +33,6 @@ class TxSearch; -class MysqlTransactionWithOutsAndIns -{ - - shared_ptr conn; - -public: - - MysqlTransactionWithOutsAndIns(shared_ptr _conn); - - bool - select(const uint64_t &address_id, vector& txs); - - bool - select_for_tx(const uint64_t &tx_id, vector& txs); -}; - - - class MysqlInputs { @@ -182,8 +164,6 @@ class MySqlAccounts shared_ptr mysql_payment; - shared_ptr mysql_tx_inout; - public: @@ -218,10 +198,6 @@ public: select_txs_for_account_spendability_check(const uint64_t& account_id, vector& txs); - bool - select_txs_with_inputs_and_outputs(const uint64_t& account_id, - vector& txs); - bool select_output_with_id(const uint64_t& out_id, XmrOutput& out); @@ -234,9 +210,6 @@ public: bool select_inputs(const uint64_t& account_id, vector& ins); - bool - select_inputs_for_tx(const uint64_t& tx_id, vector& ins); - bool select_inputs_for_tx(const uint64_t& tx_id, vector& ins); @@ -280,9 +253,6 @@ public: }; - - - } diff --git a/src/YourMoneroRequests.cpp b/src/YourMoneroRequests.cpp index e3cba0b..7c1dbfe 100644 --- a/src/YourMoneroRequests.cpp +++ b/src/YourMoneroRequests.cpp @@ -450,11 +450,6 @@ YourMoneroRequests::get_random_outs(const shared_ptr< Session > session, const B vector found_outputs; -// if (CurrentBlockchainStatus::get_random_outputs(amounts, count, found_outputs)) -// { -// -// } - if (CurrentBlockchainStatus::get_random_outputs(amounts, count, found_outputs)) { json& j_amount_outs = j_response["amount_outs"]; @@ -473,6 +468,9 @@ YourMoneroRequests::get_random_outs(const shared_ptr< Session > session, const B transaction random_output_tx; uint64_t output_idx_in_tx; + // we got random outputs, but now we need to get rct data of those + // outputs, because by default frontend created ringct txs. + if (!CurrentBlockchainStatus::get_tx_with_output( global_amount_index, outs.amount, random_output_tx, output_idx_in_tx)) @@ -507,6 +505,9 @@ YourMoneroRequests::get_random_outs(const shared_ptr< Session > session, const B } else { + // for non ringct txs, we need to take it rct amount acommitment + // and sent to the frontend. + output_data_t od = CurrentBlockchainStatus::get_output_key(outs.amount, global_amount_index); rtc_outpk = pod_to_hex(od.commitment); diff --git a/src/ssqlses.cpp b/src/ssqlses.cpp index 60b22fb..fb55020 100644 --- a/src/ssqlses.cpp +++ b/src/ssqlses.cpp @@ -135,60 +135,5 @@ ostream& operator<< (std::ostream& os, const XmrPayment& out) { }; -json -XmrTransactionWithOutsAndIns::to_json() const -{ - - json j {{"tx_id" , tx_id}, - {"account_id" , account_id}, - {"amount" , amount}, - {"tx_pub_key" , tx_pub_key}, - {"out_pub_key" , out_pub_key}, - {"global_index" , global_index}, - {"out_index" , out_index}, - {"timestamp" , timestamp}, - {"spend_key_images" , json::array()}, - {"key_image" , key_image_to_string()}, - {"mixin" , mixin} - }; - - return j; -} - -json -XmrTransactionWithOutsAndIns::spent_output() const -{ - json j {{"amount" , amount}, - {"key_image" , key_image_to_string()}, - {"tx_pub_key", tx_pub_key}, - {"out_index" , out_index}, - {"mixin" , mixin} - }; - - return j; -} - - -string -XmrTransactionWithOutsAndIns::key_image_to_string() const -{ - string key_image_str {"NULL"}; - - if (!key_image.is_null) - { - key_image_str = key_image.data; - } - - return key_image_str; -} - - - -ostream& operator<< (std::ostream& os, const XmrTransactionWithOutsAndIns& out) { - os << "XmrTransactionWithOutsAndIns: " << out.to_json().dump() << '\n'; - return os; -}; - - } \ No newline at end of file diff --git a/src/ssqlses.h b/src/ssqlses.h index d334df0..5d8eecc 100644 --- a/src/ssqlses.h +++ b/src/ssqlses.h @@ -280,49 +280,6 @@ struct XmrPayment : public Payments }; -sql_create_10(TransactionsWithOutsAndIns, 1, 2, - sql_bigint_unsigned, tx_id, - sql_bigint_unsigned, account_id, - sql_varchar , out_pub_key, - sql_bigint_unsigned, amount, - sql_bigint_unsigned, out_index, - sql_bigint_unsigned, global_index, - sql_varchar , tx_pub_key, - sql_timestamp , timestamp, - sql_varchar_null , key_image, - sql_bigint_unsigned, mixin); - -struct XmrTransactionWithOutsAndIns : public TransactionsWithOutsAndIns -{ - - static constexpr const char* SELECT_STMT = R"( - SELECT * FROM `TransactionsWithOutsAndIns` WHERE `account_id` = (%0q) - )"; - - static constexpr const char* SELECT_STMT2 = R"( - SELECT * FROM `TransactionsWithOutsAndIns` WHERE `tx_id` = (%0q) - )"; - - - using TransactionsWithOutsAndIns::TransactionsWithOutsAndIns; - - json - to_json() const; - - json - spent_output() const; - - string - key_image_to_string() const; - - friend std::ostream& operator<< (std::ostream& stream, - const XmrTransactionWithOutsAndIns& out); - -}; - - - - }