searching for tx coitaining given key image or public key added

master
moneroexamples 9 years ago
parent 22e6a1d508
commit 87c3232551

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

@ -18,6 +18,7 @@
#include "MicroCore.h" #include "MicroCore.h"
#include "tools.h" #include "tools.h"
#include "rpccalls.h" #include "rpccalls.h"
#include "mylmdb.h"
#include <algorithm> #include <algorithm>
#include <limits> #include <limits>
@ -594,7 +595,7 @@ namespace xmreg {
if (!xmreg::parse_str_secret_key(_blk_hash, blk_hash)) if (!xmreg::parse_str_secret_key(_blk_hash, blk_hash))
{ {
cerr << "Cant parse blk hash: " << blk_hash << endl; 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; uint64_t blk_height;
@ -606,12 +607,12 @@ namespace xmreg {
catch (const BLOCK_DNE& e) catch (const BLOCK_DNE& e)
{ {
cerr << "Block does not exist: " << blk_hash << endl; 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) catch (const std::exception& e)
{ {
cerr << "Cant get block: " << blk_hash << endl; 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); return show_block(blk_height);
@ -931,13 +932,29 @@ namespace xmreg {
return result_html; 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; return result_html;
} }
tx_hashes = mylmdb.search(search_text, "public_keys");
private: if (tx_hashes.size() == 1)
{
result_html = show_tx(tx_hashes.at(0));
return result_html;
}
return result_html;
}
private:
tx_details tx_details
get_tx_details(const transaction& tx, bool coinbase = false) get_tx_details(const transaction& tx, bool coinbase = false)

@ -86,7 +86,8 @@
<div class="center"> <div class="center">
<form action="/search" method="get" style="width:100%; margin-top:10px" class="style-1"> <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"> <input type="submit" value="Search">
</form> </form>
</div> </div>

Loading…
Cancel
Save