check if tx exisit in blockchain using blockchain_tx_id

pull/12/head
moneroexamples 7 years ago
parent 16b8c429bf
commit ba1848fd6d

@ -865,13 +865,17 @@ MySqlAccounts::select_txs_for_account_spendability_check(
// 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.
// and if its blockchain_tx_id is same as what we have in our mysql.
if (!CurrentBlockchainStatus::tx_exist(tx.hash))
uint64_t blockchain_tx_id {0};
CurrentBlockchainStatus::tx_exist(tx.hash, blockchain_tx_id);
if (blockchain_tx_id != tx.blockchain_tx_id)
{
// tx does not exist in blockchain, but it was there before.
// probably was in orphaned block. So remove it from the
// mysql database.
// tx does not exist in blockchain, or its blockchain_id changed
// for example, it was orhpaned, and then readded.
uint64_t no_row_updated = delete_tx(tx.id);
if (no_row_updated != 1)
@ -881,9 +885,15 @@ MySqlAccounts::select_txs_for_account_spendability_check(
"xmr_accounts->delete_tx(tx.id)");
}
// because txs does not exist in blockchain anymore,
// we assume its back to mempool, and it will be rescanned
// by tx search thread once added again to some block.
continue;
}
// set unlock_time field so that frontend displies it
// as a locked tx, if unlock_time is zero.
// coinbtase txs have this set already. regular tx

@ -205,6 +205,12 @@ TxSearch::search()
cout << "\nTransaction " << oi_identification.tx_hash_str
<< " already present in mysql"
<< endl;
// if tx is already present for that user,
// just move to next txs. This can happen we we
// rescan user's transactions.
continue;
}
tx_data.hash = oi_identification.tx_hash_str;
@ -390,7 +396,6 @@ TxSearch::search()
in_data.tx_id = tx_mysql_id; // set tx id now. before we made it 0
uint64_t in_mysql_id = xmr_accounts->insert_input(in_data);
}
} // if (!inputs_found.empty())

@ -184,7 +184,6 @@ YourMoneroRequests::get_address_txs(const shared_ptr< Session > session, const B
if (xmr_accounts->select_txs_for_account_spendability_check(acc.id, txs))
{
json j_txs = json::array();
for (XmrTransaction tx: txs)

Loading…
Cancel
Save