From 4b0785f1c9a6c6d960749938d64420403d70d8c2 Mon Sep 17 00:00:00 2001 From: koe Date: Sat, 14 May 2022 17:07:47 -0500 Subject: add an option to force-update multisig key exchange under some circumstances --- src/simplewallet/simplewallet.cpp | 28 +++++++++++++++++----------- src/simplewallet/simplewallet.h | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) (limited to 'src/simplewallet') diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index a8f4e5a07..db5be4dc2 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -244,7 +244,7 @@ namespace const char* USAGE_IMPORT_OUTPUTS("import_outputs "); const char* USAGE_SHOW_TRANSFER("show_transfer "); const char* USAGE_MAKE_MULTISIG("make_multisig [...]"); - const char* USAGE_EXCHANGE_MULTISIG_KEYS("exchange_multisig_keys [...]"); + const char* USAGE_EXCHANGE_MULTISIG_KEYS("exchange_multisig_keys [force-update-use-with-caution] [...]"); const char* USAGE_EXPORT_MULTISIG_INFO("export_multisig_info "); const char* USAGE_IMPORT_MULTISIG_INFO("import_multisig_info [...]"); const char* USAGE_SIGN_MULTISIG("sign_multisig "); @@ -1139,11 +1139,22 @@ bool simple_wallet::make_multisig_main(const std::vector &args, boo bool simple_wallet::exchange_multisig_keys(const std::vector &args) { CHECK_MULTISIG_ENABLED(); - exchange_multisig_keys_main(args, false); + bool force_update_use_with_caution = false; + + auto local_args = args; + if (args.size() >= 1 && local_args[0] == "force-update-use-with-caution") + { + force_update_use_with_caution = true; + local_args.erase(local_args.begin()); + } + + exchange_multisig_keys_main(local_args, force_update_use_with_caution, false); return true; } -bool simple_wallet::exchange_multisig_keys_main(const std::vector &args, bool called_by_mms) { +bool simple_wallet::exchange_multisig_keys_main(const std::vector &args, + const bool force_update_use_with_caution, + const bool called_by_mms) { CHECK_MULTISIG_ENABLED(); bool ready; if (m_wallet->key_on_device()) @@ -1169,15 +1180,9 @@ bool simple_wallet::exchange_multisig_keys_main(const std::vector & return false; } - if (args.size() < 1) - { - PRINT_USAGE(USAGE_EXCHANGE_MULTISIG_KEYS); - return false; - } - try { - std::string multisig_extra_info = m_wallet->exchange_multisig_keys(orig_pwd_container->password(), args); + std::string multisig_extra_info = m_wallet->exchange_multisig_keys(orig_pwd_container->password(), args, force_update_use_with_caution); bool ready; m_wallet->multisig(&ready); if (!ready) @@ -11157,7 +11162,8 @@ void simple_wallet::mms_next(const std::vector &args) mms::message m = ms.get_message_by_id(data.message_ids[i]); sig_args[i] = m.content; } - command_successful = exchange_multisig_keys_main(sig_args, true); + // todo: update mms to enable 'key exchange force updating' + command_successful = exchange_multisig_keys_main(sig_args, false, true); break; } diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index 6a9fa149d..1b67d9754 100644 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -235,7 +235,7 @@ namespace cryptonote bool make_multisig(const std::vector& args); bool make_multisig_main(const std::vector& args, bool called_by_mms); bool exchange_multisig_keys(const std::vector &args); - bool exchange_multisig_keys_main(const std::vector &args, bool called_by_mms); + bool exchange_multisig_keys_main(const std::vector &args, const bool force_update_use_with_caution, const bool called_by_mms); bool export_multisig(const std::vector& args); bool export_multisig_main(const std::vector& args, bool called_by_mms); bool import_multisig(const std::vector& args); -- cgit v1.2.3