From 9afc331a512e34cb01d569e401662e2fe3e08076 Mon Sep 17 00:00:00 2001 From: woodser Date: Fri, 21 Aug 2020 18:53:16 -0400 Subject: [PATCH] supprt is_multisig(), throw error if relay=true on multisig create_txs() --- src/wallet/monero_wallet.h | 11 +++++++++-- src/wallet/monero_wallet_core.cpp | 3 ++- src/wallet/monero_wallet_core.h | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/wallet/monero_wallet.h b/src/wallet/monero_wallet.h index e6df15c..7b207e3 100644 --- a/src/wallet/monero_wallet.h +++ b/src/wallet/monero_wallet.h @@ -1196,14 +1196,21 @@ namespace monero { throw std::runtime_error("is_multisig_import_needed() not supported"); } - // TODO: bool is_multisig() + /** + * Indicates if this wallet is a multisig wallet. + * + * @return true if this is a multisig wallet, false otherwise + */ + virtual bool is_multisig() const { + return get_multisig_info().m_is_multisig; + } /** * Get multisig info about this wallet. * * @return multisig info about this wallet */ - virtual monero_multisig_info get_multisig_info() { + virtual monero_multisig_info get_multisig_info() const { throw std::runtime_error("get_multisig_info() not supported"); } diff --git a/src/wallet/monero_wallet_core.cpp b/src/wallet/monero_wallet_core.cpp index d0c7564..d174782 100644 --- a/src/wallet/monero_wallet_core.cpp +++ b/src/wallet/monero_wallet_core.cpp @@ -1735,6 +1735,7 @@ namespace monero { bool get_tx_hex = true; bool get_tx_metadata = true; bool relay = config.m_relay != boost::none && config.m_relay.get(); + if (config.m_relay != boost::none && config.m_relay.get() == true && is_multisig()) throw std::runtime_error("Cannot relay multisig trasaction until co-signed"); // commit txs (if relaying) and get response using wallet rpc's fill_response() std::list tx_keys; @@ -2922,7 +2923,7 @@ namespace monero { return m_w2->multisig() && m_w2->has_multisig_partial_key_images(); } - monero_multisig_info monero_wallet_core::get_multisig_info() { + monero_multisig_info monero_wallet_core::get_multisig_info() const { monero_multisig_info info; info.m_is_multisig = m_w2->multisig(&info.m_is_ready, &info.m_threshold, &info.m_num_participants); return info; diff --git a/src/wallet/monero_wallet_core.h b/src/wallet/monero_wallet_core.h index eb07edc..a160591 100644 --- a/src/wallet/monero_wallet_core.h +++ b/src/wallet/monero_wallet_core.h @@ -263,7 +263,7 @@ namespace monero { void stop_mining() override; uint64_t wait_for_next_block() override; bool is_multisig_import_needed() const override; - monero_multisig_info get_multisig_info() override; + monero_multisig_info get_multisig_info() const override; std::string prepare_multisig() override; monero_multisig_init_result make_multisig(const std::vector& multisig_hexes, int threshold, const std::string& password) override; monero_multisig_init_result exchange_multisig_keys(const std::vector& mutisig_hexes, const std::string& password) override;