diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-10-01 14:06:54 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-12-17 16:12:18 +0000 |
commit | 265290388bd2134108d689818518f7d9c830292c (patch) | |
tree | f4009e97bb83c923349cc5326b954b176ce3cd71 /src/simplewallet/simplewallet.cpp | |
parent | add multisig core test and factor multisig building blocks (diff) | |
download | monero-265290388bd2134108d689818518f7d9c830292c.tar.xz |
wallet: guard against partly initialized multisig wallet
Diffstat (limited to 'src/simplewallet/simplewallet.cpp')
-rw-r--r-- | src/simplewallet/simplewallet.cpp | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index b0aec186c..40226ec34 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -849,11 +849,17 @@ bool simple_wallet::make_multisig(const std::vector<std::string> &args) bool simple_wallet::finalize_multisig(const std::vector<std::string> &args) { - if (!m_wallet->multisig()) + bool ready; + if (!m_wallet->multisig(&ready)) { fail_msg_writer() << tr("This wallet is not multisig"); return true; } + if (ready) + { + fail_msg_writer() << tr("This wallet is already finalized"); + return true; + } const auto orig_pwd_container = get_and_verify_password(); if(orig_pwd_container == boost::none) @@ -887,11 +893,17 @@ bool simple_wallet::finalize_multisig(const std::vector<std::string> &args) bool simple_wallet::export_multisig(const std::vector<std::string> &args) { - if (!m_wallet->multisig()) + bool ready; + if (!m_wallet->multisig(&ready)) { fail_msg_writer() << tr("This wallet is not multisig"); return true; } + if (!ready) + { + fail_msg_writer() << tr("This multisig wallet is not yet finalized"); + return true; + } if (args.size() != 1) { fail_msg_writer() << tr("usage: export_multisig_info <filename>"); @@ -937,12 +949,18 @@ bool simple_wallet::export_multisig(const std::vector<std::string> &args) bool simple_wallet::import_multisig(const std::vector<std::string> &args) { + bool ready; uint32_t threshold, total; - if (!m_wallet->multisig(&threshold, &total)) + if (!m_wallet->multisig(&ready, &threshold, &total)) { fail_msg_writer() << tr("This wallet is not multisig"); return true; } + if (!ready) + { + fail_msg_writer() << tr("This multisig wallet is not yet finalized"); + return true; + } if (args.size() < threshold - 1) { fail_msg_writer() << tr("usage: import_multisig_info <filename1> [<filename2>...] - one for each other participant"); @@ -1065,11 +1083,17 @@ bool simple_wallet::accept_loaded_tx(const tools::wallet2::multisig_tx_set &txs) bool simple_wallet::sign_multisig(const std::vector<std::string> &args) { - if(!m_wallet->multisig()) + bool ready; + if(!m_wallet->multisig(&ready)) { fail_msg_writer() << tr("This is not a multisig wallet"); return true; } + if (!ready) + { + fail_msg_writer() << tr("This multisig wallet is not yet finalized"); + return true; + } if (args.size() != 1) { fail_msg_writer() << tr("usage: sign_multisig <filename>"); @@ -1103,7 +1127,7 @@ bool simple_wallet::sign_multisig(const std::vector<std::string> &args) if (txids.empty()) { uint32_t threshold; - m_wallet->multisig(&threshold); + m_wallet->multisig(NULL, &threshold); uint32_t signers_needed = threshold - signers - 1; success_msg_writer(true) << tr("Transaction successfully signed to file ") << filename << ", " << signers_needed << " more signer(s) needed"; @@ -1126,12 +1150,18 @@ bool simple_wallet::sign_multisig(const std::vector<std::string> &args) bool simple_wallet::submit_multisig(const std::vector<std::string> &args) { + bool ready; uint32_t threshold; - if (!m_wallet->multisig(&threshold)) + if (!m_wallet->multisig(&ready, &threshold)) { fail_msg_writer() << tr("This is not a multisig wallet"); return true; } + if (!ready) + { + fail_msg_writer() << tr("This multisig wallet is not yet finalized"); + return true; + } if (args.size() != 1) { fail_msg_writer() << tr("usage: submit_multisig <filename>"); @@ -2717,11 +2747,12 @@ bool simple_wallet::open_wallet(const boost::program_options::variables_map& vm) } std::string prefix; + bool ready; uint32_t threshold, total; if (m_wallet->watch_only()) prefix = tr("Opened watch-only wallet"); - else if (m_wallet->multisig(&threshold, &total)) - prefix = (boost::format(tr("Opened %u/%u multisig wallet")) % threshold % total).str(); + else if (m_wallet->multisig(&ready, &threshold, &total)) + prefix = (boost::format(tr("Opened %u/%u multisig wallet%s")) % threshold % total % (ready ? "" : " (not yet finalized)")).str(); else prefix = tr("Opened wallet"); message_writer(console_color_white, true) << |