| 437 | } |
| 438 | |
| 439 | bool 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 | |
| 468 | void WalletStateBasic::add_transaction( |
| 469 | Height height, const Hash &tid, const PreparedWalletTransaction &pwtx, const api::Transaction &ptx) { |
nothing calls this directly
no test coverage detected