aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/wallet2.cpp8
-rw-r--r--src/wallet/wallet2.h4
-rw-r--r--src/wallet/wallet_rpc_server.cpp36
-rw-r--r--src/wallet/wallet_rpc_server_commands_defs.h21
4 files changed, 50 insertions, 19 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index af1f03d2c..4a14c3b8c 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -5502,7 +5502,7 @@ bool wallet2::verify_password(const std::string& keys_file_name, const epee::wip
{
get_custom_background_key(password, key, kdf_rounds);
crypto::chacha20(keys_file_data.account_data.data(), keys_file_data.account_data.size(), key, keys_file_data.iv, &account_data[0]);
- const bool is_background_wallet = json.Parse(account_data.c_str()).HasParseError() && json.IsObject();
+ const bool is_background_wallet = !json.Parse(account_data.c_str()).HasParseError() && json.IsObject();
no_spend_key = no_spend_key || is_background_wallet;
}
}
@@ -15398,7 +15398,7 @@ void wallet2::update_multisig_rescan_info(const std::vector<std::vector<rct::key
m_key_images[td.m_key_image] = n;
}
//----------------------------------------------------------------------------------------------------
-size_t wallet2::import_multisig(std::vector<cryptonote::blobdata> blobs)
+size_t wallet2::import_multisig(std::vector<cryptonote::blobdata> blobs, bool refresh_after_import)
{
CHECK_AND_ASSERT_THROW_MES(m_multisig, "Wallet is not multisig");
@@ -15523,8 +15523,8 @@ size_t wallet2::import_multisig(std::vector<cryptonote::blobdata> blobs)
update_multisig_rescan_info(m_multisig_rescan_k, m_multisig_rescan_info, n);
}
-
- refresh(false);
+ if (refresh_after_import)
+ refresh(false);
return n_outputs;
}
diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h
index a765dc475..cedfecbeb 100644
--- a/src/wallet/wallet2.h
+++ b/src/wallet/wallet2.h
@@ -994,9 +994,11 @@ private:
cryptonote::blobdata export_multisig();
/*!
* Import a set of multisig info from multisig partners
+ * \param info Multisig info from other participants
+ * \param refresh_after_import Whether to refresh the wallet and rescan spent outputs after importing
* \return the number of inputs which were imported
*/
- size_t import_multisig(std::vector<cryptonote::blobdata> info);
+ size_t import_multisig(std::vector<cryptonote::blobdata> info, bool refresh_after_import = true);
/*!
* \brief Rewrites to the wallet file for wallet upgrade (doesn't generate key, assumes it's already there)
* \param wallet_name Name of wallet file (should exist)
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index b264564a8..bca2d975f 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -1519,7 +1519,7 @@ namespace tools
for (size_t n = 0; n < tx_constructions.size(); ++n)
{
const tools::wallet2::tx_construction_data &cd = tx_constructions[n];
- res.desc.push_back({0, 0, std::numeric_limits<uint32_t>::max(), 0, {}, "", 0, "", 0, 0, ""});
+ res.desc.push_back({0, 0, std::numeric_limits<uint32_t>::max(), 0, {}, {}, "", 0, "", 0, 0, ""});
wallet_rpc::COMMAND_RPC_DESCRIBE_TRANSFER::transfer_description &desc = res.desc.back();
// Clear the recipients collection ready for this loop iteration
tx_dests.clear();
@@ -1550,8 +1550,15 @@ namespace tools
for (size_t s = 0; s < cd.sources.size(); ++s)
{
- desc.amount_in += cd.sources[s].amount;
- size_t ring_size = cd.sources[s].outputs.size();
+ const cryptonote::tx_source_entry &src_in = cd.sources[s];
+ desc.sources.emplace_back();
+ wallet_rpc::COMMAND_RPC_DESCRIBE_TRANSFER::source &src_out = desc.sources.back();
+ src_out.amount = src_in.amount;
+ src_out.global_index = src_in.outputs.at(src_in.real_output_in_tx_index).first;
+ src_out.rct = src_in.rct;
+ src_out.pubkey = epee::string_tools::pod_to_hex(src_in.outputs.at(src_in.real_output_in_tx_index).second);
+ desc.amount_in += src_in.amount;
+ size_t ring_size = src_in.outputs.size();
if (ring_size < desc.ring_size)
desc.ring_size = ring_size;
}
@@ -4397,7 +4404,7 @@ namespace tools
try
{
- res.n_outputs = m_wallet->import_multisig(info);
+ res.n_outputs = m_wallet->import_multisig(info, req.refresh_after_import);
}
catch (const std::exception &e)
{
@@ -4406,21 +4413,24 @@ namespace tools
return false;
}
- if (m_wallet->is_trusted_daemon())
+ if (req.refresh_after_import)
{
- try
+ if (m_wallet->is_trusted_daemon())
{
- m_wallet->rescan_spent();
+ try
+ {
+ m_wallet->rescan_spent();
+ }
+ catch (const std::exception &e)
+ {
+ er.message = std::string("Success, but failed to update spent status after import multisig info: ") + e.what();
+ }
}
- catch (const std::exception &e)
+ else
{
- er.message = std::string("Success, but failed to update spent status after import multisig info: ") + e.what();
+ er.message = "Success, but cannot update spent status after import multisig info as daemon is untrusted";
}
}
- else
- {
- er.message = "Success, but cannot update spent status after import multisig info as daemon is untrusted";
- }
return true;
}
diff --git a/src/wallet/wallet_rpc_server_commands_defs.h b/src/wallet/wallet_rpc_server_commands_defs.h
index ebcd1135c..26a1e2ab4 100644
--- a/src/wallet/wallet_rpc_server_commands_defs.h
+++ b/src/wallet/wallet_rpc_server_commands_defs.h
@@ -47,7 +47,7 @@
// advance which version they will stop working with
// Don't go over 32767 for any of these
#define WALLET_RPC_VERSION_MAJOR 1
-#define WALLET_RPC_VERSION_MINOR 29
+#define WALLET_RPC_VERSION_MINOR 30
#define MAKE_WALLET_RPC_VERSION(major,minor) (((major)<<16)|(minor))
#define WALLET_RPC_VERSION MAKE_WALLET_RPC_VERSION(WALLET_RPC_VERSION_MAJOR, WALLET_RPC_VERSION_MINOR)
namespace tools
@@ -698,6 +698,21 @@ namespace wallet_rpc
struct COMMAND_RPC_DESCRIBE_TRANSFER
{
+ struct source
+ {
+ uint64_t amount;
+ uint64_t global_index;
+ bool rct;
+ std::string pubkey;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(amount)
+ KV_SERIALIZE(global_index)
+ KV_SERIALIZE(rct)
+ KV_SERIALIZE(pubkey)
+ END_KV_SERIALIZE_MAP()
+ };
+
struct recipient
{
std::string address;
@@ -715,6 +730,7 @@ namespace wallet_rpc
uint64_t amount_out;
uint32_t ring_size;
uint64_t unlock_time;
+ std::list<source> sources;
std::list<recipient> recipients;
std::string payment_id;
uint64_t change_amount;
@@ -728,6 +744,7 @@ namespace wallet_rpc
KV_SERIALIZE(amount_out)
KV_SERIALIZE(ring_size)
KV_SERIALIZE(unlock_time)
+ KV_SERIALIZE(sources)
KV_SERIALIZE(recipients)
KV_SERIALIZE(payment_id)
KV_SERIALIZE(change_amount)
@@ -2437,9 +2454,11 @@ namespace wallet_rpc
struct request_t
{
std::vector<std::string> info;
+ bool refresh_after_import;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(info)
+ KV_SERIALIZE_OPT(refresh_after_import, true)
END_KV_SERIALIZE_MAP()
};
typedef epee::misc_utils::struct_init<request_t> request;