Add option to auto-accept new account creation (#86)

This commit is contained in:
Lee *!* Clagett 2023-12-15 18:19:55 -05:00 committed by Lee *!* Clagett
parent b4426b4a74
commit 6ea656d7aa
3 changed files with 16 additions and 2 deletions

View file

@ -40,6 +40,7 @@
#include "cryptonote_config.h" // monero/src
#include "db/data.h"
#include "db/storage.h"
#include "db/string.h"
#include "error.h"
#include "lmdb/util.h" // monero/src
#include "net/http_base.h" // monero/contrib/epee/include
@ -144,6 +145,7 @@ namespace lws
std::uint32_t max_subaddresses;
epee::net_utils::ssl_verification_t webhook_verify;
bool disable_admin_auth;
bool auto_accept_creation;
};
struct get_address_info
@ -648,6 +650,13 @@ namespace lws
if (!hooks)
return hooks.error();
if (options.auto_accept_creation)
{
const auto accepted = disk.accept_requests(db::request::create, {std::addressof(req.creds.address), 1});
if (!accepted)
MERROR("Failed to move account " << db::address_string(req.creds.address) << " to available state: " << accepted.error());
}
if (!hooks->empty())
{
expect<rpc::client> client = gclient.clone();
@ -1146,7 +1155,7 @@ namespace lws
};
bool any_ssl = false;
const runtime_options options{config.max_subaddresses, config.webhook_verify, config.disable_admin_auth};
const runtime_options options{config.max_subaddresses, config.webhook_verify, config.disable_admin_auth, config.auto_accept_creation};
for (const std::string& address : addresses)
{
ports_.emplace_back(io_service_, disk.clone(), MONERO_UNWRAP(client.clone()), options);

View file

@ -57,6 +57,7 @@ namespace lws
epee::net_utils::ssl_verification_t webhook_verify;
bool allow_external;
bool disable_admin_auth;
bool auto_accept_creation;
};
explicit rest_server(epee::span<const std::string> addresses, std::vector<std::string> admin, db::storage disk, rpc::client client, configuration config);

View file

@ -79,6 +79,7 @@ namespace
const command_line::arg_descriptor<std::string> webhook_ssl_verification;
const command_line::arg_descriptor<std::string> config_file;
const command_line::arg_descriptor<std::uint32_t> max_subaddresses;
const command_line::arg_descriptor<bool> auto_accept_creation;
static std::string get_default_zmq()
{
@ -122,6 +123,7 @@ namespace
, webhook_ssl_verification{"webhook-ssl-verification", "[<none|system_ca>] specify SSL verification mode for webhooks", "system_ca"}
, config_file{"config-file", "Specify any option in a config file; <name>=<value> on separate lines"}
, max_subaddresses{"max-subaddresses", "Maximum number of subaddresses per primary account (defaults to 0)", 0}
, auto_accept_creation{"auto-accept-creation", "New account creation requests are automatically accepted", false}
{}
void prepare(boost::program_options::options_description& description) const
@ -153,6 +155,7 @@ namespace
command_line::add_arg(description, webhook_ssl_verification);
command_line::add_arg(description, config_file);
command_line::add_arg(description, max_subaddresses);
command_line::add_arg(description, auto_accept_creation);
}
};
@ -236,7 +239,8 @@ namespace
command_line::get_arg(args, opts.max_subaddresses),
webhook_verify,
command_line::get_arg(args, opts.external_bind),
command_line::get_arg(args, opts.disable_admin_auth)
command_line::get_arg(args, opts.disable_admin_auth),
command_line::get_arg(args, opts.auto_accept_creation)
},
command_line::get_arg(args, opts.daemon_rpc),
command_line::get_arg(args, opts.daemon_sub),