diff --git a/CMakeLists.txt b/CMakeLists.txt index 5afd98e..f86a6be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ set(MONERO_HEADERS_DIR include_directories( ${MONERO_HEADERS_DIR}/src ${MONERO_HEADERS_DIR}/external + ${MONERO_HEADERS_DIR}/external/easylogging++ ${MONERO_HEADERS_DIR}/contrib/epee/include ${MONERO_HEADERS_DIR}/external/db_drivers/liblmdb) @@ -60,6 +61,10 @@ add_library(mnemonics STATIC IMPORTED) set_property(TARGET mnemonics PROPERTY IMPORTED_LOCATION ${MONERO_LIBS_DIR}/libmnemonics.a) +add_library(epee STATIC IMPORTED) +set_property(TARGET epee + PROPERTY IMPORTED_LOCATION ${MONERO_LIBS_DIR}/libepee.a) + add_library(blockchain_db STATIC IMPORTED) set_property(TARGET blockchain_db PROPERTY IMPORTED_LOCATION ${MONERO_LIBS_DIR}/libblockchain_db.a) @@ -110,6 +115,7 @@ target_link_libraries(restbed_xmr ringct common mnemonics + epee mysqlpp mysqlclient ${Boost_LIBRARIES} diff --git a/src/CurrentBlockchainStatus.cpp b/src/CurrentBlockchainStatus.cpp index d5d1bd6..61255fb 100644 --- a/src/CurrentBlockchainStatus.cpp +++ b/src/CurrentBlockchainStatus.cpp @@ -154,7 +154,28 @@ CurrentBlockchainStatus::get_block_txs(const block &blk, list &blk return true; } + bool +CurrentBlockchainStatus::tx_exist(const crypto::hash& tx_hash) +{ + return core_storage->have_tx(tx_hash); +} + +bool +CurrentBlockchainStatus::tx_exist(const string& tx_hash_str) +{ + crypto::hash tx_hash; + + if (hex_to_pod(tx_hash_str, tx_hash)) + { + return tx_exist(tx_hash); + } + + throw runtime_error("(hex_to_pod(tx_hash_str, tx_hash) failed!"); +} + + + bool CurrentBlockchainStatus::get_output_keys(const uint64_t& amount, const vector& absolute_offsets, vector& outputs) diff --git a/src/CurrentBlockchainStatus.h b/src/CurrentBlockchainStatus.h index f1d6797..8336b48 100644 --- a/src/CurrentBlockchainStatus.h +++ b/src/CurrentBlockchainStatus.h @@ -97,6 +97,12 @@ struct CurrentBlockchainStatus static bool get_block_txs(const block &blk, list &blk_txs); + static bool + tx_exist(const crypto::hash& tx_hash); + + static bool + tx_exist(const string& tx_hash_str); + static bool get_output_keys(const uint64_t& amount, const vector& absolute_offsets, diff --git a/src/YourMoneroRequests.cpp b/src/YourMoneroRequests.cpp index 4a221b2..3fc1c89 100644 --- a/src/YourMoneroRequests.cpp +++ b/src/YourMoneroRequests.cpp @@ -180,10 +180,22 @@ YourMoneroRequests::get_address_txs(const shared_ptr< Session > session, const B for (XmrTransaction tx: txs) { + + // first we check if txs stored in db are already spendable + // it means if they are older than 10 blocks. If yes, + // we mark them as spendable, as we assumet that blocks + // older than 10 blocks are permanent, i.e, they wont get + // orphaned. + if (bool {tx.spendable} == false) { if (CurrentBlockchainStatus::is_tx_unlocked(tx.height)) { + + // this tx was before marked as unspendable, but now + // it is spendable. Meaning, that its older than 10 blocks. + // so mark it as spendable, so that its permanet. + uint64_t no_row_updated = xmr_accounts->mark_tx_spendable(tx.id); if (no_row_updated != 1) @@ -193,6 +205,15 @@ YourMoneroRequests::get_address_txs(const shared_ptr< Session > session, const B tx.spendable = true; } + else + { + // tx was marked as non-spendable, i.e., youger than 10 blocks + // so we still are going to use this txs, but we need to double + // check if its still valid, i.e., it's block did not get orphaned. + // we do this by checking if txs still exists in the blockchain + // and if its in the same block as noted in the database. + + } } // get inputs associated with a given diff --git a/src/tools.h b/src/tools.h index 0c375b2..a5d5422 100644 --- a/src/tools.h +++ b/src/tools.h @@ -163,8 +163,8 @@ get_payment_id(const transaction& tx, inline void enable_monero_log() { uint32_t log_level = 0; - epee::log_space::get_set_log_detalisation_level(true, log_level); - epee::log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL); + log_space::log_singletone::get_set_log_detalisation_level(true, log_level); + log_space::log_singletone::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL); }