Skip to content

Commit

Permalink
Add support for view tags when scanning
Browse files Browse the repository at this point in the history
- monero-project/monero#8061
- also update import location for epee::misc_utils::get_gmt_time
  • Loading branch information
j-berman committed Apr 27, 2022
1 parent 6706aad commit 3aa0a9e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/rpc/daemon_zmq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ namespace cryptonote
{
wire::object(source, WIRE_FIELD(hash));
}
static void read_bytes(wire::json_reader& source, txout_to_tagged_key& self)
{
wire::object(source, WIRE_FIELD(key), WIRE_FIELD(view_tag));
}
static void read_bytes(wire::json_reader& source, txout_to_key& self)
{
wire::object(source, WIRE_FIELD(key));
Expand All @@ -103,6 +107,7 @@ namespace cryptonote
WIRE_FIELD(amount),
wire::variant_field("transaction output variant", std::ref(self.target),
wire::option<txout_to_key>{"to_key"},
wire::option<txout_to_tagged_key>{"to_tagged_key"},
wire::option<txout_to_script>{"to_script"},
wire::option<txout_to_scripthash>{"to_scripthash"}
)
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/light_wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

#include "db/string.h"
#include "error.h"
#include "misc_os_dependent.h" // monero/contrib/epee/include
#include "time_helper.h" // monero/contrib/epee/include
#include "ringct/rctOps.h" // monero/src
#include "span.h" // monero/contrib/epee/include
#include "util/random_outputs.h"
Expand Down
14 changes: 9 additions & 5 deletions src/scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,18 @@ namespace lws
{
++index;

cryptonote::txout_to_key const* const out_data =
boost::get<cryptonote::txout_to_key>(std::addressof(out.target));
if (!out_data)
crypto::public_key out_pub_key;
if (!cryptonote::get_output_public_key(out, out_pub_key))
continue; // to next output

boost::optional<crypto::view_tag> view_tag_opt =
cryptonote::get_output_view_tag(out);
if (!cryptonote::out_can_be_to_acc(view_tag_opt, derived, index))
continue; // to next output

crypto::public_key derived_pub;
const bool received =
crypto::wallet::derive_subaddress_public_key(out_data->key, derived, index, derived_pub) &&
crypto::wallet::derive_subaddress_public_key(out_pub_key, derived, index, derived_pub) &&
derived_pub == user.spend_public();

if (!received)
Expand Down Expand Up @@ -300,7 +304,7 @@ namespace lws
timestamp,
tx.unlock_time,
*prefix_hash,
out_data->key,
out_pub_key,
mask,
{0, 0, 0, 0, 0, 0, 0}, // reserved bytes
db::pack(ext, payment_id.first),
Expand Down
5 changes: 5 additions & 0 deletions src/wire/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,9 @@ namespace wire
struct is_blob<rct::key>
: std::true_type
{};

template<>
struct is_blob<crypto::view_tag>
: std::true_type
{};
}

0 comments on commit 3aa0a9e

Please sign in to comment.