mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-27 05:13:25 +01:00
Merge pull request #1954
110b6831
Resolve #92 add ability to create wallets thru RPC (Howard Chu)
This commit is contained in:
commit
f65d739c41
@ -498,6 +498,12 @@ std::pair<std::unique_ptr<wallet2>, password_container> wallet2::make_new(const
|
||||
return {make_basic(vm, opts), std::move(*pwd)};
|
||||
}
|
||||
|
||||
std::unique_ptr<wallet2> wallet2::make_dummy(const boost::program_options::variables_map& vm)
|
||||
{
|
||||
const options opts{};
|
||||
return make_basic(vm, opts);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool wallet2::init(std::string daemon_address, boost::optional<epee::net_utils::http::login> daemon_login, uint64_t upper_transaction_size_limit)
|
||||
{
|
||||
|
@ -126,6 +126,9 @@ namespace tools
|
||||
//! Uses stdin and stdout. Returns a wallet2 and password for wallet with no file if no errors.
|
||||
static std::pair<std::unique_ptr<wallet2>, password_container> make_new(const boost::program_options::variables_map& vm);
|
||||
|
||||
//! Just parses variables.
|
||||
static std::unique_ptr<wallet2> make_dummy(const boost::program_options::variables_map& vm);
|
||||
|
||||
wallet2(bool testnet = false, bool restricted = false) : m_run(true), m_callback(0), m_testnet(testnet), m_always_confirm_transfers(true), m_print_ring_members(false), m_store_tx_info(true), m_default_mixin(0), m_default_priority(0), m_refresh_type(RefreshOptimizeCoinbase), m_auto_refresh(true), m_refresh_from_block_height(0), m_confirm_missing_payment_id(true), m_ask_password(true), m_min_output_count(0), m_min_output_value(0), m_merge_destinations(false), m_restricted(restricted), is_old_file_format(false), m_node_rpc_proxy(m_http_client, m_daemon_rpc_mutex) {}
|
||||
|
||||
struct transfer_details
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -52,11 +52,14 @@ namespace tools
|
||||
|
||||
static const char* tr(const char* str);
|
||||
|
||||
wallet_rpc_server(wallet2& cr);
|
||||
wallet_rpc_server();
|
||||
~wallet_rpc_server();
|
||||
|
||||
bool init(const boost::program_options::variables_map& vm);
|
||||
bool init(const boost::program_options::variables_map *vm);
|
||||
bool run();
|
||||
void stop();
|
||||
void set_wallet(wallet2 *cr);
|
||||
|
||||
private:
|
||||
|
||||
CHAIN_HTTP_TO_MAP2(connection_context); //forward http requests to uri map
|
||||
@ -95,6 +98,9 @@ namespace tools
|
||||
MAP_JON_RPC_WE("rescan_spent", on_rescan_spent, wallet_rpc::COMMAND_RPC_RESCAN_SPENT)
|
||||
MAP_JON_RPC_WE("start_mining", on_start_mining, wallet_rpc::COMMAND_RPC_START_MINING)
|
||||
MAP_JON_RPC_WE("stop_mining", on_stop_mining, wallet_rpc::COMMAND_RPC_STOP_MINING)
|
||||
MAP_JON_RPC_WE("get_languages", on_get_languages, wallet_rpc::COMMAND_RPC_GET_LANGUAGES)
|
||||
MAP_JON_RPC_WE("create_wallet", on_create_wallet, wallet_rpc::COMMAND_RPC_CREATE_WALLET)
|
||||
MAP_JON_RPC_WE("open_wallet", on_open_wallet, wallet_rpc::COMMAND_RPC_OPEN_WALLET)
|
||||
END_JSON_RPC_MAP()
|
||||
END_URI_MAP2()
|
||||
|
||||
@ -131,6 +137,9 @@ namespace tools
|
||||
bool on_rescan_spent(const wallet_rpc::COMMAND_RPC_RESCAN_SPENT::request& req, wallet_rpc::COMMAND_RPC_RESCAN_SPENT::response& res, epee::json_rpc::error& er);
|
||||
bool on_start_mining(const wallet_rpc::COMMAND_RPC_START_MINING::request& req, wallet_rpc::COMMAND_RPC_START_MINING::response& res, epee::json_rpc::error& er);
|
||||
bool on_stop_mining(const wallet_rpc::COMMAND_RPC_STOP_MINING::request& req, wallet_rpc::COMMAND_RPC_STOP_MINING::response& res, epee::json_rpc::error& er);
|
||||
bool on_get_languages(const wallet_rpc::COMMAND_RPC_GET_LANGUAGES::request& req, wallet_rpc::COMMAND_RPC_GET_LANGUAGES::response& res, epee::json_rpc::error& er);
|
||||
bool on_create_wallet(const wallet_rpc::COMMAND_RPC_CREATE_WALLET::request& req, wallet_rpc::COMMAND_RPC_CREATE_WALLET::response& res, epee::json_rpc::error& er);
|
||||
bool on_open_wallet(const wallet_rpc::COMMAND_RPC_OPEN_WALLET::request& req, wallet_rpc::COMMAND_RPC_OPEN_WALLET::response& res, epee::json_rpc::error& er);
|
||||
|
||||
//json rpc v2
|
||||
bool on_query_key(const wallet_rpc::COMMAND_RPC_QUERY_KEY::request& req, wallet_rpc::COMMAND_RPC_QUERY_KEY::response& res, epee::json_rpc::error& er);
|
||||
@ -140,11 +149,14 @@ namespace tools
|
||||
void fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &txid, const tools::wallet2::confirmed_transfer_details &pd);
|
||||
void fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &txid, const tools::wallet2::unconfirmed_transfer_details &pd);
|
||||
void fill_transfer_entry(tools::wallet_rpc::transfer_entry &entry, const crypto::hash &payment_id, const tools::wallet2::payment_details &pd);
|
||||
bool not_open(epee::json_rpc::error& er);
|
||||
|
||||
wallet2& m_wallet;
|
||||
wallet2 *m_wallet;
|
||||
std::string m_wallet_dir;
|
||||
std::string rpc_login_filename;
|
||||
std::atomic<bool> m_stop;
|
||||
bool m_trusted_daemon;
|
||||
epee::net_utils::http::http_simple_client m_http_client;
|
||||
const boost::program_options::variables_map *m_vm;
|
||||
};
|
||||
}
|
||||
|
@ -909,5 +909,61 @@ namespace wallet_rpc
|
||||
};
|
||||
};
|
||||
|
||||
struct COMMAND_RPC_GET_LANGUAGES
|
||||
{
|
||||
struct request
|
||||
{
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
struct response
|
||||
{
|
||||
std::vector<std::string> languages;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(languages)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
};
|
||||
|
||||
struct COMMAND_RPC_CREATE_WALLET
|
||||
{
|
||||
struct request
|
||||
{
|
||||
std::string filename;
|
||||
std::string password;
|
||||
std::string language;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(filename)
|
||||
KV_SERIALIZE(password)
|
||||
KV_SERIALIZE(language)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
struct response
|
||||
{
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
};
|
||||
|
||||
struct COMMAND_RPC_OPEN_WALLET
|
||||
{
|
||||
struct request
|
||||
{
|
||||
std::string filename;
|
||||
std::string password;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(filename)
|
||||
KV_SERIALIZE(password)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
struct response
|
||||
{
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -43,3 +43,4 @@
|
||||
#define WALLET_RPC_ERROR_CODE_WRONG_KEY_IMAGE -10
|
||||
#define WALLET_RPC_ERROR_CODE_WRONG_URI -11
|
||||
#define WALLET_RPC_ERROR_CODE_WRONG_INDEX -12
|
||||
#define WALLET_RPC_ERROR_CODE_NOT_OPEN -13
|
||||
|
Loading…
Reference in New Issue
Block a user