diff --git a/src/rest_server.cpp b/src/rest_server.cpp index 5f9e877..57ef4eb 100644 --- a/src/rest_server.cpp +++ b/src/rest_server.cpp @@ -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 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); diff --git a/src/rest_server.h b/src/rest_server.h index 36dc068..9e6e33f 100644 --- a/src/rest_server.h +++ b/src/rest_server.h @@ -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 addresses, std::vector admin, db::storage disk, rpc::client client, configuration config); diff --git a/src/server_main.cpp b/src/server_main.cpp index 7e62af8..95982ce 100644 --- a/src/server_main.cpp +++ b/src/server_main.cpp @@ -79,6 +79,7 @@ namespace const command_line::arg_descriptor webhook_ssl_verification; const command_line::arg_descriptor config_file; const command_line::arg_descriptor max_subaddresses; + const command_line::arg_descriptor auto_accept_creation; static std::string get_default_zmq() { @@ -122,6 +123,7 @@ namespace , webhook_ssl_verification{"webhook-ssl-verification", "[] specify SSL verification mode for webhooks", "system_ca"} , config_file{"config-file", "Specify any option in a config file; = 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),