Merge pull request #33 from j-berman/hf-15

Add support for view tags (+ epee misc util re-located)
This commit is contained in:
Lee *!* Clagett 2022-05-24 14:29:57 -04:00 committed by GitHub
commit 5081062c7c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 6 deletions

View file

@ -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));
@ -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"}
)

View file

@ -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"

View file

@ -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)
@ -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),

View file

@ -69,4 +69,9 @@ namespace wire
struct is_blob<rct::key>
: std::true_type
{};
template<>
struct is_blob<crypto::view_tag>
: std::true_type
{};
}