Add (working draft) subaddress support (#83)

This commit is contained in:
Lee *!* Clagett
2023-12-05 20:23:50 -05:00
committed by Lee *!* Clagett
parent e09d3d57e9
commit b4426b4a74
21 changed files with 1539 additions and 88 deletions

View File

@@ -134,7 +134,8 @@ namespace
wire::field("timestamp", iso_timestamp(self.data.first.timestamp)),
wire::field("height", self.data.first.link.height),
wire::field("spend_key_images", std::cref(self.data.second)),
wire::optional_field("rct", optional_rct)
wire::optional_field("rct", optional_rct),
wire::field("recipient", std::cref(self.data.first.recipient))
);
}
@@ -192,6 +193,12 @@ namespace lws
convert_address(address, self.address);
}
void rpc::write_bytes(wire::json_writer& dest, const new_subaddrs_response& self)
{
wire::object(dest, WIRE_FIELD(new_subaddrs), WIRE_FIELD(all_subaddrs));
}
void rpc::write_bytes(wire::json_writer& dest, const transaction_spend& self)
{
wire::object(dest,
@@ -199,7 +206,8 @@ namespace lws
wire::field("key_image", std::cref(self.possible_spend.image)),
wire::field("tx_pub_key", std::cref(self.meta.tx_public)),
wire::field("out_index", self.meta.index),
wire::field("mixin", self.possible_spend.mixin_count)
wire::field("mixin", self.possible_spend.mixin_count),
wire::field("sender", std::cref(self.possible_spend.sender))
);
}
@@ -278,6 +286,11 @@ namespace lws
wire::object(dest, WIRE_FIELD(amount_outs));
}
void rpc::write_bytes(wire::json_writer& dest, const get_subaddrs_response& self)
{
wire::object(dest, WIRE_FIELD(all_subaddrs));
}
void rpc::read_bytes(wire::json_reader& source, get_unspent_outs_request& self)
{
std::string address;
@@ -331,6 +344,21 @@ namespace lws
wire::object(dest, WIRE_FIELD_COPY(new_address), WIRE_FIELD_COPY(generated_locally));
}
void rpc::read_bytes(wire::json_reader& source, provision_subaddrs_request& self)
{
std::string address;
wire::object(source,
wire::field("address", std::ref(address)),
wire::field("view_key", std::ref(unwrap(unwrap(self.creds.key)))),
WIRE_OPTIONAL_FIELD(maj_i),
WIRE_OPTIONAL_FIELD(min_i),
WIRE_OPTIONAL_FIELD(n_maj),
WIRE_OPTIONAL_FIELD(n_min),
WIRE_OPTIONAL_FIELD(get_all)
);
convert_address(address, self.creds.address);
}
void rpc::read_bytes(wire::json_reader& source, submit_raw_tx_request& self)
{
wire::object(source, WIRE_FIELD(tx));
@@ -339,4 +367,16 @@ namespace lws
{
wire::object(dest, WIRE_FIELD_COPY(status));
}
void rpc::read_bytes(wire::json_reader& source, upsert_subaddrs_request& self)
{
std::string address;
wire::object(source,
wire::field("address", std::ref(address)),
wire::field("view_key", std::ref(unwrap(unwrap(self.creds.key)))),
WIRE_FIELD(subaddrs),
WIRE_OPTIONAL_FIELD(get_all)
);
convert_address(address, self.creds.address);
}
} // lws

View File

@@ -65,6 +65,15 @@ namespace rpc
void read_bytes(wire::json_reader&, account_credentials&);
struct new_subaddrs_response
{
new_subaddrs_response() = delete;
std::vector<db::subaddress_dict> new_subaddrs;
std::vector<db::subaddress_dict> all_subaddrs;
};
void write_bytes(wire::json_writer&, const new_subaddrs_response&);
struct transaction_spend
{
transaction_spend() = delete;
@@ -164,6 +173,14 @@ namespace rpc
void write_bytes(wire::json_writer&, const get_unspent_outs_response&);
struct get_subaddrs_response
{
get_subaddrs_response() = delete;
std::vector<db::subaddress_dict> all_subaddrs;
};
void write_bytes(wire::json_writer&, const get_subaddrs_response&);
struct import_response
{
import_response() = delete;
@@ -193,6 +210,19 @@ namespace rpc
void write_bytes(wire::json_writer&, login_response);
struct provision_subaddrs_request
{
provision_subaddrs_request() = delete;
account_credentials creds;
boost::optional<std::uint32_t> maj_i;
boost::optional<std::uint32_t> min_i;
boost::optional<std::uint32_t> n_maj;
boost::optional<std::uint32_t> n_min;
boost::optional<bool> get_all;
};
void read_bytes(wire::json_reader&, provision_subaddrs_request&);
struct submit_raw_tx_request
{
submit_raw_tx_request() = delete;
@@ -206,5 +236,15 @@ namespace rpc
const char* status;
};
void write_bytes(wire::json_writer&, submit_raw_tx_response);
struct upsert_subaddrs_request
{
upsert_subaddrs_request() = delete;
account_credentials creds;
std::vector<db::subaddress_dict> subaddrs;
boost::optional<bool> get_all;
};
void read_bytes(wire::json_reader&, upsert_subaddrs_request&);
} // rpc
} // lws