MCPcopy Create free account
hub / github.com/bcndev/bytecoin / try_adding_incoming_keyimage

Method try_adding_incoming_keyimage

src/Core/WalletStateBasic.cpp:439–466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

437}
438
439bool WalletStateBasic::try_adding_incoming_keyimage(const KeyImage &key_image, api::Output *spending_output) const {
440 bool candidate_found = false;
441 HeightGi heamgi;
442 bool ki_exists = read_by_keyimage(key_image, &heamgi);
443 if (ki_exists && read_from_unspent_index(heamgi, spending_output)) {
444 candidate_found = true;
445 }
446 std::string prefix = LOCKED_INDEX_KI_GI + DB::to_binary_key(key_image.data, sizeof(key_image.data));
447 for (DB::Cursor cur = m_db.begin(prefix); !cur.end(); cur.next()) {
448 size_t gi = common::integer_cast<size_t>(common::read_varint_sqlite4(cur.get_suffix()));
449 if (candidate_found)
450 continue;
451 BlockOrTimestamp unl = 0;
452 seria::from_binary(unl, cur.get_value_array());
453 std::string unkey =
454 LOCKED_INDEX_B_OR_T_GI_to_OUTPUT + common::write_varint_sqlite4(unl) + common::write_varint_sqlite4(gi);
455 BinaryArray output_ba;
456 invariant(m_db.get(unkey, output_ba), "");
457 api::Output output;
458 seria::from_binary(output, output_ba);
459 invariant(output.global_index == gi, "");
460 if (candidate_found && output.address != spending_output->address)
461 continue;
462 *spending_output = output;
463 candidate_found = true;
464 }
465 return candidate_found;
466}
467
468void WalletStateBasic::add_transaction(
469 Height height, const Hash &tid, const PreparedWalletTransaction &pwtx, const api::Transaction &ptx) {

Callers

nothing calls this directly

Calls 8

from_binaryFunction · 0.85
write_varint_sqlite4Function · 0.85
read_varint_sqlite4Function · 0.50
beginMethod · 0.45
endMethod · 0.45
nextMethod · 0.45
get_value_arrayMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected