aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-02-24 18:19:00 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-02-24 18:20:14 +0000
commitada6a8a2de62214b7d9894783b58dcd75436bdc3 (patch)
treee22b1a8a305c2bec6f9421ef2199515d921a7b7c /src/wallet
parentMerge pull request #1776 (diff)
downloadmonero-ada6a8a2de62214b7d9894783b58dcd75436bdc3.tar.xz
wallet_rpc_server: new --trusted-daemon flag
and remove trusted_daemon fields from transfer RPCs, it is much friendlier on users
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/wallet_rpc_server.cpp21
-rw-r--r--src/wallet/wallet_rpc_server.h1
-rw-r--r--src/wallet/wallet_rpc_server_commands_defs.h8
3 files changed, 17 insertions, 13 deletions
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index 4bd2394db..28606ed73 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -54,6 +54,7 @@ namespace
{
const command_line::arg_descriptor<std::string, true> arg_rpc_bind_port = {"rpc-bind-port", "Sets bind port for server"};
const command_line::arg_descriptor<bool> arg_disable_rpc_login = {"disable-rpc-login", "Disable HTTP authentication for RPC connections served by this process"};
+ const command_line::arg_descriptor<bool> arg_trusted_daemon = {"trusted-daemon", "Enable commands which rely on a trusted daemon", false};
constexpr const char default_rpc_username[] = "monero";
}
@@ -66,7 +67,7 @@ namespace tools
}
//------------------------------------------------------------------------------------------------------------------------------
- wallet_rpc_server::wallet_rpc_server(wallet2& w):m_wallet(w), rpc_login_filename(), m_stop(false)
+ wallet_rpc_server::wallet_rpc_server(wallet2& w):m_wallet(w), rpc_login_filename(), m_stop(false), m_trusted_daemon(false)
{}
//------------------------------------------------------------------------------------------------------------------------------
wallet_rpc_server::~wallet_rpc_server()
@@ -112,6 +113,15 @@ namespace tools
boost::optional<epee::net_utils::http::login> http_login{};
std::string bind_port = command_line::get_arg(vm, arg_rpc_bind_port);
const bool disable_auth = command_line::get_arg(vm, arg_disable_rpc_login);
+ m_trusted_daemon = command_line::get_arg(vm, arg_trusted_daemon);
+ if (!command_line::has_arg(vm, arg_trusted_daemon))
+ {
+ if (tools::is_local_address(m_wallet.get_daemon_address()))
+ {
+ MINFO(tr("Daemon is local, assuming trusted"));
+ m_trusted_daemon = true;
+ }
+ }
if (disable_auth)
{
@@ -381,7 +391,7 @@ namespace tools
LOG_PRINT_L1("Requested mixin " << req.mixin << " too low for hard fork 2, using 2");
mixin = 2;
}
- std::vector<wallet2::pending_tx> ptx_vector = m_wallet.create_transactions_2(dsts, mixin, req.unlock_time, req.priority, extra, req.trusted_daemon);
+ std::vector<wallet2::pending_tx> ptx_vector = m_wallet.create_transactions_2(dsts, mixin, req.unlock_time, req.priority, extra, m_trusted_daemon);
// reject proposed transactions if there are more than one. see on_transfer_split below.
if (ptx_vector.size() != 1)
@@ -451,7 +461,7 @@ namespace tools
}
std::vector<wallet2::pending_tx> ptx_vector;
LOG_PRINT_L2("on_transfer_split calling create_transactions_2");
- ptx_vector = m_wallet.create_transactions_2(dsts, mixin, req.unlock_time, req.priority, extra, req.trusted_daemon);
+ ptx_vector = m_wallet.create_transactions_2(dsts, mixin, req.unlock_time, req.priority, extra, m_trusted_daemon);
LOG_PRINT_L2("on_transfer_split called create_transactions_2");
LOG_PRINT_L2("on_transfer_split calling commit_txyy");
@@ -503,7 +513,7 @@ namespace tools
try
{
- std::vector<wallet2::pending_tx> ptx_vector = m_wallet.create_unmixable_sweep_transactions(req.trusted_daemon);
+ std::vector<wallet2::pending_tx> ptx_vector = m_wallet.create_unmixable_sweep_transactions(m_trusted_daemon);
m_wallet.commit_tx(ptx_vector);
@@ -565,7 +575,7 @@ namespace tools
try
{
- std::vector<wallet2::pending_tx> ptx_vector = m_wallet.create_transactions_all(dsts[0].addr, req.mixin, req.unlock_time, req.priority, extra, req.trusted_daemon);
+ std::vector<wallet2::pending_tx> ptx_vector = m_wallet.create_transactions_all(dsts[0].addr, req.mixin, req.unlock_time, req.priority, extra, m_trusted_daemon);
m_wallet.commit_tx(ptx_vector);
@@ -1376,6 +1386,7 @@ int main(int argc, char** argv) {
tools::wallet2::init_options(desc_params);
command_line::add_arg(desc_params, arg_rpc_bind_port);
command_line::add_arg(desc_params, arg_disable_rpc_login);
+ command_line::add_arg(desc_params, arg_trusted_daemon);
cryptonote::rpc_args::init_options(desc_params);
command_line::add_arg(desc_params, arg_wallet_file);
command_line::add_arg(desc_params, arg_from_json);
diff --git a/src/wallet/wallet_rpc_server.h b/src/wallet/wallet_rpc_server.h
index 97e3c534c..c43c595df 100644
--- a/src/wallet/wallet_rpc_server.h
+++ b/src/wallet/wallet_rpc_server.h
@@ -138,5 +138,6 @@ namespace tools
wallet2& m_wallet;
std::string rpc_login_filename;
std::atomic<bool> m_stop;
+ bool m_trusted_daemon;
};
}
diff --git a/src/wallet/wallet_rpc_server_commands_defs.h b/src/wallet/wallet_rpc_server_commands_defs.h
index aad59d409..78f896f16 100644
--- a/src/wallet/wallet_rpc_server_commands_defs.h
+++ b/src/wallet/wallet_rpc_server_commands_defs.h
@@ -119,7 +119,6 @@ namespace wallet_rpc
uint64_t unlock_time;
std::string payment_id;
bool get_tx_key;
- bool trusted_daemon;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(destinations)
@@ -128,7 +127,6 @@ namespace wallet_rpc
KV_SERIALIZE(unlock_time)
KV_SERIALIZE(payment_id)
KV_SERIALIZE(get_tx_key)
- KV_SERIALIZE(trusted_daemon)
END_KV_SERIALIZE_MAP()
};
@@ -158,7 +156,6 @@ namespace wallet_rpc
uint64_t unlock_time;
std::string payment_id;
bool get_tx_keys;
- bool trusted_daemon;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(destinations)
@@ -167,7 +164,6 @@ namespace wallet_rpc
KV_SERIALIZE(unlock_time)
KV_SERIALIZE(payment_id)
KV_SERIALIZE(get_tx_keys)
- KV_SERIALIZE(trusted_daemon)
END_KV_SERIALIZE_MAP()
};
@@ -199,11 +195,9 @@ namespace wallet_rpc
struct request
{
bool get_tx_keys;
- bool trusted_daemon;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(get_tx_keys)
- KV_SERIALIZE(trusted_daemon)
END_KV_SERIALIZE_MAP()
};
@@ -240,7 +234,6 @@ namespace wallet_rpc
uint64_t unlock_time;
std::string payment_id;
bool get_tx_keys;
- bool trusted_daemon;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(address)
@@ -249,7 +242,6 @@ namespace wallet_rpc
KV_SERIALIZE(unlock_time)
KV_SERIALIZE(payment_id)
KV_SERIALIZE(get_tx_keys)
- KV_SERIALIZE(trusted_daemon)
END_KV_SERIALIZE_MAP()
};