searching for tx coitaining given key image or public key added

This commit is contained in:
moneroexamples 2016-04-28 04:18:49 +00:00
parent 22e6a1d508
commit 87c3232551
3 changed files with 25 additions and 7 deletions

View file

@ -226,14 +226,14 @@ namespace xmreg
// set cursor the the first item
if (cr.get(key_to_find, tx_hash_val, MDB_SET))
{
cout << key_val_to_str(key_to_find, tx_hash_val) << endl;
//cout << key_val_to_str(key_to_find, tx_hash_val) << endl;
out.push_back(string(tx_hash_val.data(), tx_hash_val.size()));
// process other values for the same key
while (cr.get(key_to_find, tx_hash_val, MDB_NEXT_DUP)) {
cout << key_val_to_str(key_to_find, tx_hash_val) << endl;
//cout << key_val_to_str(key_to_find, tx_hash_val) << endl;
out.push_back(string(tx_hash_val.data(), tx_hash_val.size()));

View file

@ -18,6 +18,7 @@
#include "MicroCore.h"
#include "tools.h"
#include "rpccalls.h"
#include "mylmdb.h"
#include <algorithm>
#include <limits>
@ -594,7 +595,7 @@ namespace xmreg {
if (!xmreg::parse_str_secret_key(_blk_hash, blk_hash))
{
cerr << "Cant parse blk hash: " << blk_hash << endl;
return fmt::format("Cant parse block hash {:s}!", blk_hash);
return fmt::format("Cant get block {:s}!", blk_hash);
}
uint64_t blk_height;
@ -606,12 +607,12 @@ namespace xmreg {
catch (const BLOCK_DNE& e)
{
cerr << "Block does not exist: " << blk_hash << endl;
return fmt::format("Block of hash {:s} does not exist!", blk_hash);
return fmt::format("Cant get block {:s}!", blk_hash);
}
catch (const std::exception& e)
{
cerr << "Cant get block: " << blk_hash << endl;
return fmt::format("Block of hash {:s} not found!", blk_hash);
return fmt::format("Cant get block {:s}!", blk_hash);
}
return show_block(blk_height);
@ -931,6 +932,23 @@ namespace xmreg {
return result_html;
}
xmreg::MyLMDB mylmdb {"/home/mwo/.bitmonero/lmdb2"};
vector<string> tx_hashes = mylmdb.search(search_text, "key_images");
if (tx_hashes.size() == 1)
{
result_html = show_tx(tx_hashes.at(0));
return result_html;
}
tx_hashes = mylmdb.search(search_text, "public_keys");
if (tx_hashes.size() == 1)
{
result_html = show_tx(tx_hashes.at(0));
return result_html;
}
return result_html;
}
@ -938,7 +956,6 @@ namespace xmreg {
private:
tx_details
get_tx_details(const transaction& tx, bool coinbase = false)
{

View file

@ -86,7 +86,8 @@
<div class="center">
<form action="/search" method="get" style="width:100%; margin-top:10px" class="style-1">
<input type="text" name="value" size="100">
<input type="text" name="value" size="100"
placeholder="block height, block hash, tx hash, tx payment id, input key image or output public key ">
<input type="submit" value="Search">
</form>
</div>