From 7b1e9ca29801d1e380291371e40c8c37ac43d18d Mon Sep 17 00:00:00 2001 From: woodser <13068859+woodser@users.noreply.github.com> Date: Wed, 8 Apr 2026 13:54:22 -0400 Subject: multisig: add flag to skip refresh after multisig import --- src/wallet/wallet2.cpp | 6 +++--- src/wallet/wallet2.h | 4 +++- src/wallet/wallet_rpc_server.cpp | 23 +++++++++++++---------- src/wallet/wallet_rpc_server_commands_defs.h | 4 +++- 4 files changed, 22 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index af1f03d2c..00157cb3e 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -15398,7 +15398,7 @@ void wallet2::update_multisig_rescan_info(const std::vector blobs) +size_t wallet2::import_multisig(std::vector 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 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 info); + size_t import_multisig(std::vector 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 0cf75a1c4..b86ab9e5a 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -4424,7 +4424,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) { @@ -4433,21 +4433,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..5d8a1ce4d 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 @@ -2437,9 +2437,11 @@ namespace wallet_rpc struct request_t { std::vector 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; -- cgit v1.2.3