diff --git a/CMakeLists.txt b/CMakeLists.txt index fe8804e..52e5063 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -221,6 +221,10 @@ set_target_properties(multisig PROPERTIES IMPORTED_LOCATION add_library(version STATIC IMPORTED) set_target_properties(version PROPERTIES IMPORTED_LOCATION ${EXTERNAL_LIBS_DIR}/monero-core/libversion.a) + +add_library(randomx STATIC IMPORTED) +set_target_properties(randomx PROPERTIES IMPORTED_LOCATION + ${EXTERNAL_LIBS_DIR}/monero-core/librandomx.a) ######################## # Build c++ library @@ -278,6 +282,7 @@ target_link_libraries(monero-cpp device_trezor multisig version + randomx ${EXTRA_LIBRARIES} ) @@ -335,6 +340,7 @@ target_link_libraries(sample_code device_trezor multisig version + randomx ${EXTRA_LIBRARIES} ) @@ -394,6 +400,7 @@ target_link_libraries(scratchpad device_trezor multisig version + randomx ${EXTRA_LIBRARIES} ) diff --git a/src/utils/monero_utils.cpp b/src/utils/monero_utils.cpp index e977182..b1fc298 100644 --- a/src/utils/monero_utils.cpp +++ b/src/utils/monero_utils.cpp @@ -290,7 +290,7 @@ void monero_utils::binary_blocks_to_json(const std::string &bin, std::string &js boost::property_tree::ptree txsNode; for (int txIdx = 0; txIdx < resp_struct.blocks[blockIdx].txs.size(); txIdx++) { cryptonote::transaction tx; - if (cryptonote::parse_and_validate_tx_from_blob(resp_struct.blocks[blockIdx].txs[txIdx], tx)) { + if (cryptonote::parse_and_validate_tx_from_blob(resp_struct.blocks[blockIdx].txs[txIdx].blob, tx)) { // add tx node to txs node boost::property_tree::ptree txNode; diff --git a/src/wallet/monero_wallet.cpp b/src/wallet/monero_wallet.cpp index b7e99a9..91a223f 100644 --- a/src/wallet/monero_wallet.cpp +++ b/src/wallet/monero_wallet.cpp @@ -78,6 +78,7 @@ namespace monero { static const int DEFAULT_SYNC_INTERVAL_MILLIS = 1000 * 10; // default refresh interval 10 sec static const int DEFAULT_CONNECTION_TIMEOUT_MILLIS = 1000 * 30; // default connection timeout 30 sec + static const bool STRICT = false; // relies exclusively on blockchain data if true, includes local wallet data if false TODO: good use case to expose externally? // ----------------------- INTERNAL PRIVATE HELPERS ----------------------- @@ -1249,29 +1250,29 @@ namespace monero { // isMultisigImportNeeded uint64_t monero_wallet::get_balance() const { - return m_w2->balance_all(); + return m_w2->balance_all(STRICT); } uint64_t monero_wallet::get_balance(uint32_t account_idx) const { - return m_w2->balance(account_idx); + return m_w2->balance(account_idx, STRICT); } uint64_t monero_wallet::get_balance(uint32_t account_idx, uint32_t subaddress_idx) const { - map balance_per_subaddress = m_w2->balance_per_subaddress(account_idx); + map balance_per_subaddress = m_w2->balance_per_subaddress(account_idx, STRICT); auto iter = balance_per_subaddress.find(subaddress_idx); return iter == balance_per_subaddress.end() ? 0 : iter->second; } uint64_t monero_wallet::get_unlocked_balance() const { - return m_w2->unlocked_balance_all(); + return m_w2->unlocked_balance_all(STRICT); } uint64_t monero_wallet::get_unlocked_balance(uint32_t account_idx) const { - return m_w2->unlocked_balance(account_idx); + return m_w2->unlocked_balance(account_idx, STRICT); } uint64_t monero_wallet::get_unlocked_balance(uint32_t account_idx, uint32_t subaddress_idx) const { - map> unlocked_balance_per_subaddress = m_w2->unlocked_balance_per_subaddress(account_idx); + map> unlocked_balance_per_subaddress = m_w2->unlocked_balance_per_subaddress(account_idx, STRICT); auto iter = unlocked_balance_per_subaddress.find(subaddress_idx); return iter == unlocked_balance_per_subaddress.end() ? 0 : iter->second.first; } @@ -1304,8 +1305,8 @@ namespace monero { monero_account account; account.m_index = account_idx; account.m_primary_address = get_address(account_idx, 0); - account.m_balance = m_w2->balance(account_idx); - account.m_unlocked_balance = m_w2->unlocked_balance(account_idx); + account.m_balance = m_w2->balance(account_idx, STRICT); + account.m_unlocked_balance = m_w2->unlocked_balance(account_idx, STRICT); if (include_subaddresses) account.m_subaddresses = get_subaddresses_aux(account_idx, vector(), transfers); accounts.push_back(account); } @@ -1328,8 +1329,8 @@ namespace monero { monero_account account; account.m_index = account_idx; account.m_primary_address = get_address(account_idx, 0); - account.m_balance = m_w2->balance(account_idx); - account.m_unlocked_balance = m_w2->unlocked_balance(account_idx); + account.m_balance = m_w2->balance(account_idx, STRICT); + account.m_unlocked_balance = m_w2->unlocked_balance(account_idx, STRICT); if (include_subaddresses) account.m_subaddresses = get_subaddresses_aux(account_idx, vector(), transfers); return account; } @@ -1592,7 +1593,12 @@ namespace monero { // get unconfirmed incoming transfers if (is_pool) { - m_w2->update_pool_state(); // TODO monero-core: this should be encapsulated in wallet when unconfirmed transfers queried + + // update pool state TODO monero-core: this should be encapsulated in wallet when unconfirmed transfers queried + std::vector> process_txs; + m_w2->update_pool_state(process_txs); + if (!process_txs.empty()) m_w2->process_pool_state(process_txs); + std::list> payments; m_w2->get_unconfirmed_payments(payments, account_index, subaddress_indices); for (std::list>::const_iterator i = payments.begin(); i != payments.end(); ++i) { @@ -2669,8 +2675,8 @@ namespace monero { return send_request; } - string monero_wallet::get_attribute(const string& key) const { - return m_w2->get_attribute(key); + bool monero_wallet::get_attribute(const string& key, string& value) const { + return m_w2->get_attribute(key, value); } void monero_wallet::set_attribute(const string& key, const string& val) { @@ -2964,8 +2970,8 @@ namespace monero { vector subaddresses; // get balances per subaddress as maps - map balance_per_subaddress = m_w2->balance_per_subaddress(account_idx); - map> unlocked_balance_per_subaddress = m_w2->unlocked_balance_per_subaddress(account_idx); + map balance_per_subaddress = m_w2->balance_per_subaddress(account_idx, STRICT); + map> unlocked_balance_per_subaddress = m_w2->unlocked_balance_per_subaddress(account_idx, STRICT); // get all indices if no indices given vector subaddress_indices_req; diff --git a/src/wallet/monero_wallet.h b/src/wallet/monero_wallet.h index 40b7e34..2dd6928 100644 --- a/src/wallet/monero_wallet.h +++ b/src/wallet/monero_wallet.h @@ -1243,9 +1243,10 @@ namespace monero { * Get an attribute. * * @param key is the attribute to get the value of - * @return the attribute's value + * @param value is set to the key's value if set + * @return true if the key's value has been set, false otherwise */ - string get_attribute(const string& key) const; + bool get_attribute(const string& key, string& value) const; /** * Set an arbitrary attribute.