Don't terminate search thread when derivation of key fails

https://github.com/moneroexamples/openmonero/issues/128
pull/148/head
moneroexamples 5 years ago
parent 1be824a12d
commit 02d192bfdd

@ -3,7 +3,7 @@ var config = {
mainnetExplorerUrl: "https://xmrchain.com/",
testnetExplorerUrl: "https://testnet.xmrchain.com/",
stagenetExplorerUrl: "http://139.162.60.17:8082/",
nettype: 2, /* 0 - MAINNET, 1 - TESTNET, 2 - STAGENET */
nettype: 0, /* 0 - MAINNET, 1 - TESTNET, 2 - STAGENET */
coinUnitPlaces: 12,
txMinConfirms: 10, // corresponds to CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE in Monero
txCoinbaseMinConfirms: 60, // corresponds to CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW in Monero

@ -40,9 +40,14 @@ OutputInputIdentification::OutputInputIdentification(
<< "pub_tx_key: " << get_tx_pub_key_str() << " and "
<< "prv_view_key" << viewkey;;
throw OutputInputIdentificationException(
"Cant get derived key for a tx");
//throw OutputInputIdentificationException(
// "Cant get derived key for a tx");
status = INTERNAL_STATUS::CANT_DERIVE_KEY;
return;
}
status = INTERNAL_STATUS::OK;
}
uint64_t

@ -51,6 +51,11 @@ class OutputInputIdentification
public:
// quick workaround to issue: 128
// so that search threads dont terminate
// when an error of creating derived key occurs
enum class INTERNAL_STATUS {FAIL, OK, CANT_DERIVE_KEY};
// define a structure to keep information about found
// outputs that we can need in later parts.
struct output_info
@ -102,6 +107,8 @@ public:
std::shared_ptr<CurrentBlockchainStatus> current_bc_status;
INTERNAL_STATUS status = INTERNAL_STATUS::FAIL;
// default constructor. Useful for unit tests
OutputInputIdentification() = default;
@ -113,6 +120,8 @@ public:
std::shared_ptr<CurrentBlockchainStatus>
_current_bc_status);
/**
* FIRST step. search for the incoming xmr using address, viewkey and
* outputs public keys.

@ -62,6 +62,8 @@ TxSearch::operator()()
uint64_t blocks_lookahead
= current_bc_status->get_bc_setup().blocks_search_lookahead;
string address_prefix = acc->address.substr(0, 6);
// we put everything in massive catch, as there are plenty ways in which
// an exceptions can be thrown here. Mostly from mysql.
// but because this is detatch thread, we cant catch them in main thread.
@ -172,6 +174,14 @@ TxSearch::operator()()
&address, &viewkey, &tx, tx_hash,
is_coinbase, current_bc_status};
if (oi_identification.status
!= OutputInputIdentification::INTERNAL_STATUS::OK)
{
OMWARN << address_prefix << " :tx "
<< pod_to_hex(tx_hash) << " skipped.";
continue;
}
// flag indicating whether the txs in the given block are spendable.
// this is true when block number is more than 10 blocks from current
// blockchain height.
@ -669,6 +679,8 @@ TxSearch::find_txs_in_mempool(
auto local_xmr_accounts = make_shared<MySqlAccounts>(current_bc_status);
string address_prefix = acc->address.substr(0, 6);
for (auto const& mtx: mempool_txs)
{
@ -684,6 +696,14 @@ TxSearch::find_txs_in_mempool(
OutputInputIdentification oi_identification
{&address, &viewkey, &tx, tx_hash, coinbase,
current_bc_status};
if (oi_identification.status
!= OutputInputIdentification::INTERNAL_STATUS::OK)
{
OMWARN << address_prefix << ": mempool tx "
<< pod_to_hex(tx_hash) << " skipped.";
continue;
}
// FIRSt step. to search for the incoming xmr, we use address,
// viewkey and

Loading…
Cancel
Save