diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-08-13 15:29:31 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-12-17 16:12:12 +0000 |
commit | f4eda44ce35c6e1ab77566a462470deaae5376ec (patch) | |
tree | c7705926d3794b066293c4dd440701f4c91049ca /src/gen_multisig | |
parent | multisig address generation RPC (diff) | |
download | monero-f4eda44ce35c6e1ab77566a462470deaae5376ec.tar.xz |
N-1/N multisig
Diffstat (limited to 'src/gen_multisig')
-rw-r--r-- | src/gen_multisig/gen_multisig.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/gen_multisig/gen_multisig.cpp b/src/gen_multisig/gen_multisig.cpp index 358c1e4c0..a9bc7b8fd 100644 --- a/src/gen_multisig/gen_multisig.cpp +++ b/src/gen_multisig/gen_multisig.cpp @@ -99,10 +99,15 @@ static bool generate_multisig(uint32_t threshold, uint32_t total, const std::str std::vector<crypto::public_key> pk(total); for (size_t n = 0; n < total; ++n) { - tools::wallet2::verify_multisig_info(wallets[n]->get_multisig_info(), sk[n], pk[n]); + if (!tools::wallet2::verify_multisig_info(wallets[n]->get_multisig_info(), sk[n], pk[n])) + { + tools::fail_msg_writer() << tr("Failed to verify multisig info"); + return false; + } } // make the wallets multisig + std::vector<std::string> extra_info(total); std::stringstream ss; for (size_t n = 0; n < total; ++n) { @@ -117,10 +122,33 @@ static bool generate_multisig(uint32_t threshold, uint32_t total, const std::str pkn.push_back(pk[k]); } } - wallets[n]->make_multisig(pwd_container->password(), skn, pkn, threshold); + extra_info[n] = wallets[n]->make_multisig(pwd_container->password(), skn, pkn, threshold); ss << " " << name << std::endl; } + // finalize step if needed + if (!extra_info[0].empty()) + { + std::unordered_set<crypto::public_key> pkeys; + std::vector<crypto::public_key> signers(total); + for (size_t n = 0; n < total; ++n) + { + if (!tools::wallet2::verify_extra_multisig_info(extra_info[n], pkeys, signers[n])) + { + tools::fail_msg_writer() << genms::tr("Error verifying multisig extra info"); + return false; + } + } + for (size_t n = 0; n < total; ++n) + { + if (!wallets[n]->finalize_multisig(pwd_container->password(), pkeys, signers)) + { + tools::fail_msg_writer() << genms::tr("Error finalizing multisig"); + return false; + } + } + } + std::string address = wallets[0]->get_account().get_public_address_str(wallets[0]->testnet()); tools::success_msg_writer() << genms::tr("Generated multisig wallets for address ") << address << std::endl << ss.str(); } |