diff --git a/src/page.h b/src/page.h index aa522cb..f11a0c2 100644 --- a/src/page.h +++ b/src/page.h @@ -2026,12 +2026,30 @@ namespace xmreg { {"key_imgs" , mstch::array{}} }; + + unique_ptr mylmdb; + + if (bf::is_directory(lmdb2_path)) + { + + mylmdb = make_unique(lmdb2_path); + } + else + { + cout << "Custom lmdb database seem does not exist at: " << lmdb2_path << endl; + } + + + + size_t no_key_images = (decoded_raw_data.size() - header_lenght) / record_lenght; //vector> signed_key_images; mstch::array& key_imgs_ctx = boost::get(context["key_imgs"]); + + for (size_t n = 0; n < no_key_images; ++n) { const char* record_ptr = decoded_raw_data.data() + header_lenght + n * record_lenght; @@ -2042,12 +2060,53 @@ namespace xmreg { crypto::signature signature = *reinterpret_cast(record_ptr + key_img_size); - key_imgs_ctx.push_back(mstch::map{ + + vector found_tx_hashes; + + if (mylmdb) + { + mylmdb->search(epee::string_tools::pod_to_hex(key_image), + found_tx_hashes, "key_images"); + } + + mstch::map key_img_info { {"key_no" , fmt::format("{:03d}", n)}, {"key_image" , REMOVE_HASH_BRAKETS(fmt::format("{:s}", key_image))}, {"signature" , fmt::format("{:s}", signature)}, - {"is_spent" , core_storage->have_tx_keyimg_as_spent(key_image)} - }); + {"is_spent" , core_storage->have_tx_keyimg_as_spent(key_image)}, + {"tx_hash_found" , !found_tx_hashes.empty()}, + {"tx_hash" , string{}}, + }; + + + if (!found_tx_hashes.empty()) + { + + string tx_hash_str = found_tx_hashes.at(0); + + key_img_info["tx_hash"] = tx_hash_str; + key_img_info["timestamp"] = "0"; + + transaction tx; + + if (mcore->get_tx(tx_hash_str, tx)) + { + crypto::hash tx_hash; + + epee::string_tools::hex_to_pod(tx_hash_str, tx_hash); + + // get timestamp of the tx's block + uint64_t blk_height = core_storage + ->get_db().get_tx_block_height(tx_hash); + + uint64_t blk_timestamp = core_storage + ->get_db().get_block_timestamp(blk_height); + + key_img_info["timestamp"] = xmreg::timestamp_to_str(blk_timestamp); + } + } + + key_imgs_ctx.push_back(key_img_info); //signed_key_images.push_back(make_pair(key_image, signature)); } diff --git a/src/templates/checkrawkeyimgs.html b/src/templates/checkrawkeyimgs.html index 4460abc..87d69e7 100644 --- a/src/templates/checkrawkeyimgs.html +++ b/src/templates/checkrawkeyimgs.html @@ -25,17 +25,27 @@
- + {{#key_imgs}} - - {{#is_spent}} - - {{/is_spent}} - {{^is_spent}} - - {{/is_spent}} + + + {{/key_imgs}}
Key no.Key imageIs spent?
Key no.Key imageTimestampIs spent?
{{key_no}}{{key_image}}{{is_spent}}{{is_spent}} + {{#tx_hash_found}} + {{key_image}} + {{/tx_hash_found}} + {{^tx_hash_found}} + {{key_image}} + {{/tx_hash_found}} + {{timestamp}} + {{#is_spent}} + {{is_spent}} + {{/is_spent}} + {{^is_spent}} + {{is_spent}} + {{/is_spent}} +