aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet_rpc_server.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet/wallet_rpc_server.cpp')
-rw-r--r--src/wallet/wallet_rpc_server.cpp73
1 files changed, 41 insertions, 32 deletions
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index d7aa80e0a..da02e1e83 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -65,7 +65,7 @@ using namespace epee;
#define CHECK_MULTISIG_ENABLED() \
do \
{ \
- if (m_wallet->multisig() && !m_wallet->is_multisig_enabled()) \
+ if (m_wallet->get_multisig_status().multisig_is_active && !m_wallet->is_multisig_enabled()) \
{ \
er.code = WALLET_RPC_ERROR_CODE_DISABLED; \
er.message = "This wallet is multisig, and multisig is disabled. Multisig is an experimental feature and may have bugs. Things that could go wrong include: funds sent to a multisig wallet can't be spent at all, can only be spent with the participation of a malicious group member, or can be stolen by a malicious group member. You can enable it by running this once in monero-wallet-cli: set enable-multisig-experimental 1"; \
@@ -459,7 +459,7 @@ namespace tools
{
res.balance = req.all_accounts ? m_wallet->balance_all(req.strict) : m_wallet->balance(req.account_index, req.strict);
res.unlocked_balance = req.all_accounts ? m_wallet->unlocked_balance_all(req.strict, &res.blocks_to_unlock, &res.time_to_unlock) : m_wallet->unlocked_balance(req.account_index, req.strict, &res.blocks_to_unlock, &res.time_to_unlock);
- res.multisig_import_needed = m_wallet->multisig() && m_wallet->has_multisig_partial_key_images();
+ res.multisig_import_needed = m_wallet->get_multisig_status().multisig_is_active && m_wallet->has_multisig_partial_key_images();
std::map<uint32_t, std::map<uint32_t, uint64_t>> balance_per_subaddress_per_account;
std::map<uint32_t, std::map<uint32_t, std::pair<uint64_t, std::pair<uint64_t, uint64_t>>>> unlocked_balance_per_subaddress_per_account;
if (req.all_accounts)
@@ -1024,7 +1024,7 @@ namespace tools
fill(spent_key_images, key_image_list);
}
- if (m_wallet->multisig())
+ if (m_wallet->get_multisig_status().multisig_is_active)
{
multisig_txset = epee::string_tools::buff_to_hex_nodelimer(m_wallet->save_multisig_tx(ptx_vector));
if (multisig_txset.empty())
@@ -2066,10 +2066,11 @@ namespace tools
if (req.key_type.compare("mnemonic") == 0)
{
epee::wipeable_string seed;
- bool ready;
- if (m_wallet->multisig(&ready))
+ const multisig::multisig_account_status ms_status{m_wallet->get_multisig_status()};
+
+ if (ms_status.multisig_is_active)
{
- if (!ready)
+ if (!ms_status.is_ready)
{
er.code = WALLET_RPC_ERROR_CODE_NOT_MULTISIG;
er.message = "This wallet is multisig, but not yet finalized";
@@ -3979,7 +3980,14 @@ 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, const connection_context *ctx)
{
if (!m_wallet) return not_open(er);
- res.multisig = m_wallet->multisig(&res.ready, &res.threshold, &res.total);
+ const multisig::multisig_account_status ms_status{m_wallet->get_multisig_status()};
+
+ res.multisig = ms_status.multisig_is_active;
+ res.kex_is_done = ms_status.kex_is_done;
+ res.ready = ms_status.is_ready;
+ res.threshold = ms_status.threshold;
+ res.total = ms_status.total;
+
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
@@ -3992,7 +4000,7 @@ namespace tools
er.message = "Command unavailable in restricted mode.";
return false;
}
- if (m_wallet->multisig())
+ if (m_wallet->get_multisig_status().multisig_is_active)
{
er.code = WALLET_RPC_ERROR_CODE_ALREADY_MULTISIG;
er.message = "This wallet is already multisig";
@@ -4021,7 +4029,7 @@ namespace tools
er.message = "Command unavailable in restricted mode.";
return false;
}
- if (m_wallet->multisig())
+ if (m_wallet->get_multisig_status().multisig_is_active)
{
er.code = WALLET_RPC_ERROR_CODE_ALREADY_MULTISIG;
er.message = "This wallet is already multisig";
@@ -4059,14 +4067,15 @@ namespace tools
er.message = "Command unavailable in restricted mode.";
return false;
}
- bool ready;
- if (!m_wallet->multisig(&ready))
+ const multisig::multisig_account_status ms_status{m_wallet->get_multisig_status()};
+
+ if (!ms_status.multisig_is_active)
{
er.code = WALLET_RPC_ERROR_CODE_NOT_MULTISIG;
er.message = "This wallet is not multisig";
return false;
}
- if (!ready)
+ if (!ms_status.is_ready)
{
er.code = WALLET_RPC_ERROR_CODE_NOT_MULTISIG;
er.message = "This wallet is multisig, but not yet finalized";
@@ -4100,15 +4109,15 @@ namespace tools
er.message = "Command unavailable in restricted mode.";
return false;
}
- bool ready;
- uint32_t threshold, total;
- if (!m_wallet->multisig(&ready, &threshold, &total))
+ const multisig::multisig_account_status ms_status{m_wallet->get_multisig_status()};
+
+ if (!ms_status.multisig_is_active)
{
er.code = WALLET_RPC_ERROR_CODE_NOT_MULTISIG;
er.message = "This wallet is not multisig";
return false;
}
- if (!ready)
+ if (!ms_status.is_ready)
{
er.code = WALLET_RPC_ERROR_CODE_NOT_MULTISIG;
er.message = "This wallet is multisig, but not yet finalized";
@@ -4116,7 +4125,7 @@ namespace tools
}
CHECK_MULTISIG_ENABLED();
- if (req.info.size() < threshold - 1)
+ if (req.info.size() + 1 < ms_status.threshold)
{
er.code = WALLET_RPC_ERROR_CODE_THRESHOLD_NOT_REACHED;
er.message = "Needs multisig export info from more participants";
@@ -4180,9 +4189,9 @@ namespace tools
er.message = "Command unavailable in restricted mode.";
return false;
}
- bool ready;
- uint32_t threshold, total;
- if (!m_wallet->multisig(&ready, &threshold, &total))
+ multisig::multisig_account_status ms_status{m_wallet->get_multisig_status()};
+
+ if (!ms_status.multisig_is_active)
{
er.code = WALLET_RPC_ERROR_CODE_NOT_MULTISIG;
er.message = "This wallet is not multisig";
@@ -4190,7 +4199,7 @@ namespace tools
}
CHECK_MULTISIG_ENABLED();
- if (req.multisig_info.size() + 1 < total)
+ if (req.multisig_info.size() + 1 < ms_status.total)
{
er.code = WALLET_RPC_ERROR_CODE_THRESHOLD_NOT_REACHED;
er.message = "Needs multisig info from more participants";
@@ -4200,8 +4209,8 @@ namespace tools
try
{
res.multisig_info = m_wallet->exchange_multisig_keys(req.password, req.multisig_info, req.force_update_use_with_caution);
- m_wallet->multisig(&ready);
- if (ready)
+ ms_status = m_wallet->get_multisig_status();
+ if (ms_status.is_ready)
{
res.address = m_wallet->get_account().get_public_address_str(m_wallet->nettype());
}
@@ -4224,15 +4233,15 @@ namespace tools
er.message = "Command unavailable in restricted mode.";
return false;
}
- bool ready;
- uint32_t threshold, total;
- if (!m_wallet->multisig(&ready, &threshold, &total))
+ const multisig::multisig_account_status ms_status{m_wallet->get_multisig_status()};
+
+ if (!ms_status.multisig_is_active)
{
er.code = WALLET_RPC_ERROR_CODE_NOT_MULTISIG;
er.message = "This wallet is not multisig";
return false;
}
- if (!ready)
+ if (!ms_status.is_ready)
{
er.code = WALLET_RPC_ERROR_CODE_NOT_MULTISIG;
er.message = "This wallet is multisig, but not yet finalized";
@@ -4294,15 +4303,15 @@ namespace tools
er.message = "Command unavailable in restricted mode.";
return false;
}
- bool ready;
- uint32_t threshold, total;
- if (!m_wallet->multisig(&ready, &threshold, &total))
+ const multisig::multisig_account_status ms_status{m_wallet->get_multisig_status()};
+
+ if (!ms_status.multisig_is_active)
{
er.code = WALLET_RPC_ERROR_CODE_NOT_MULTISIG;
er.message = "This wallet is not multisig";
return false;
}
- if (!ready)
+ if (!ms_status.is_ready)
{
er.code = WALLET_RPC_ERROR_CODE_NOT_MULTISIG;
er.message = "This wallet is multisig, but not yet finalized";
@@ -4327,7 +4336,7 @@ namespace tools
return false;
}
- if (txs.m_signers.size() < threshold)
+ if (txs.m_signers.size() < ms_status.threshold)
{
er.code = WALLET_RPC_ERROR_CODE_THRESHOLD_NOT_REACHED;
er.message = "Not enough signers signed this transaction.";