aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-10-01 14:06:54 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-12-17 16:12:18 +0000
commit265290388bd2134108d689818518f7d9c830292c (patch)
treef4009e97bb83c923349cc5326b954b176ce3cd71 /src/wallet
parentadd multisig core test and factor multisig building blocks (diff)
downloadmonero-265290388bd2134108d689818518f7d9c830292c.tar.xz
wallet: guard against partly initialized multisig wallet
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/wallet2.cpp4
-rw-r--r--src/wallet/wallet2.h2
-rw-r--r--src/wallet/wallet_rpc_server.cpp29
-rw-r--r--src/wallet/wallet_rpc_server_commands_defs.h2
4 files changed, 31 insertions, 6 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 2bba6f9e1..9c2587f25 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -3039,7 +3039,7 @@ bool wallet2::verify_extra_multisig_info(const std::string &data, std::unordered
return true;
}
-bool wallet2::multisig(uint32_t *threshold, uint32_t *total) const
+bool wallet2::multisig(bool *ready, uint32_t *threshold, uint32_t *total) const
{
if (!m_multisig)
return false;
@@ -3047,6 +3047,8 @@ bool wallet2::multisig(uint32_t *threshold, uint32_t *total) const
*threshold = m_multisig_threshold;
if (total)
*total = m_multisig_signers.size();
+ if (ready)
+ *ready = !(get_account().get_keys().m_account_address.m_spend_public_key == rct::rct2pk(rct::identity()));
return true;
}
diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h
index 8abc42ff3..79199a30c 100644
--- a/src/wallet/wallet2.h
+++ b/src/wallet/wallet2.h
@@ -598,7 +598,7 @@ namespace tools
bool testnet() const { return m_testnet; }
bool restricted() const { return m_restricted; }
bool watch_only() const { return m_watch_only; }
- bool multisig(uint32_t *threshold = NULL, uint32_t *total = NULL) const;
+ bool multisig(bool *ready = NULL, uint32_t *threshold = NULL, uint32_t *total = NULL) const;
bool has_multisig_partial_key_images() const;
// locked & unlocked balance of given or current subaddress account
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index ac991d861..043890fd1 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -2342,7 +2342,7 @@ namespace tools
bool wallet_rpc_server::on_is_multisig(const wallet_rpc::COMMAND_RPC_IS_MULTISIG::request& req, wallet_rpc::COMMAND_RPC_IS_MULTISIG::response& res, epee::json_rpc::error& er)
{
if (!m_wallet) return not_open(er);
- res.multisig = m_wallet->multisig(&res.threshold, &res.total);
+ res.multisig = m_wallet->multisig(&res.ready, &res.threshold, &res.total);
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
@@ -2468,12 +2468,19 @@ namespace tools
er.message = "Command unavailable in restricted mode.";
return false;
}
- if (!m_wallet->multisig())
+ bool ready;
+ if (!m_wallet->multisig(&ready))
{
er.code = WALLET_RPC_ERROR_CODE_NOT_MULTISIG;
er.message = "This wallet is not multisig";
return false;
}
+ if (!ready)
+ {
+ er.code = WALLET_RPC_ERROR_CODE_NOT_MULTISIG;
+ er.message = "This wallet is multisig, but not yet finalized";
+ return false;
+ }
std::vector<tools::wallet2::multisig_info> info;
try
@@ -2514,13 +2521,20 @@ namespace tools
er.message = "Command unavailable in restricted mode.";
return false;
}
+ bool ready;
uint32_t threshold, total;
- if (!m_wallet->multisig(&threshold, &total))
+ if (!m_wallet->multisig(&ready, &threshold, &total))
{
er.code = WALLET_RPC_ERROR_CODE_NOT_MULTISIG;
er.message = "This wallet is not multisig";
return false;
}
+ if (!ready)
+ {
+ er.code = WALLET_RPC_ERROR_CODE_NOT_MULTISIG;
+ er.message = "This wallet is multisig, but not yet finalized";
+ return false;
+ }
if (req.info.size() < threshold - 1)
{
@@ -2607,13 +2621,20 @@ namespace tools
er.message = "Command unavailable in restricted mode.";
return false;
}
+ bool ready;
uint32_t threshold, total;
- if (!m_wallet->multisig(&threshold, &total))
+ if (!m_wallet->multisig(&ready, &threshold, &total))
{
er.code = WALLET_RPC_ERROR_CODE_NOT_MULTISIG;
er.message = "This wallet is not multisig";
return false;
}
+ if (ready)
+ {
+ er.code = WALLET_RPC_ERROR_CODE_ALREADY_MULTISIG;
+ er.message = "This wallet is multisig, and already finalized";
+ return false;
+ }
if (req.multisig_info.size() < threshold - 1)
{
diff --git a/src/wallet/wallet_rpc_server_commands_defs.h b/src/wallet/wallet_rpc_server_commands_defs.h
index d17af9980..bff4fdd7c 100644
--- a/src/wallet/wallet_rpc_server_commands_defs.h
+++ b/src/wallet/wallet_rpc_server_commands_defs.h
@@ -1499,11 +1499,13 @@ namespace wallet_rpc
struct response
{
bool multisig;
+ bool ready;
uint32_t threshold;
uint32_t total;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(multisig)
+ KV_SERIALIZE(ready)
KV_SERIALIZE(threshold)
KV_SERIALIZE(total)
END_KV_SERIALIZE_MAP()