From e5bfc2f6ad4f61f27cf537483ccfc509ffc1f816 Mon Sep 17 00:00:00 2001 From: Some Random Crypto Guy Date: Tue, 7 Oct 2025 13:32:15 +0100 Subject: [PATCH] wallet API additions for better Carrot support --- src/wallet/api/wallet.cpp | 34 +++++++++++++++++++++++++++++++++- src/wallet/api/wallet.h | 4 ++++ src/wallet/api/wallet2_api.h | 24 ++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index 977241402..60085177d 100644 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -893,21 +893,33 @@ std::string WalletImpl::integratedAddress(const std::string &payment_id, bool ca std::string WalletImpl::secretViewKey() const { + uint32_t hf_version = m_wallet->estimate_current_hard_fork(); + if (hf_version >= HF_VERSION_CARROT) + return epee::string_tools::pod_to_hex(unwrap(unwrap(m_wallet->get_account().get_keys().k_view_incoming))); + else return epee::string_tools::pod_to_hex(unwrap(unwrap(m_wallet->get_account().get_keys().m_view_secret_key))); } std::string WalletImpl::publicViewKey() const { + uint32_t hf_version = m_wallet->estimate_current_hard_fork(); + if (hf_version >= HF_VERSION_CARROT) + return epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_carrot_account_address.m_view_public_key); + else return epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_account_address.m_view_public_key); } std::string WalletImpl::secretSpendKey() const { - return epee::string_tools::pod_to_hex(unwrap(unwrap(m_wallet->get_account().get_keys().m_spend_secret_key))); + return epee::string_tools::pod_to_hex(unwrap(unwrap(m_wallet->get_account().get_keys().m_spend_secret_key))); } std::string WalletImpl::publicSpendKey() const { + uint32_t hf_version = m_wallet->estimate_current_hard_fork(); + if (hf_version >= HF_VERSION_CARROT) + return epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_carrot_account_address.m_spend_public_key); + else return epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_account_address.m_spend_public_key); } @@ -921,6 +933,26 @@ std::string WalletImpl::publicMultisigSignerKey() const } } +std::string WalletImpl::secretViewBalance() const +{ + return epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().s_view_balance; +} + +std::string WalletImpl::secretProveSpend() const +{ + return epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().k_prove_spend; +} + +std::string WalletImpl::secretGenerateAddress() const +{ + return epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().s_generate_address; +} + +std::string WalletImpl::secretGenerateImage() const +{ + return epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().k_generate_image; +} + std::string WalletImpl::path() const { return m_wallet->path(); diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h index f4289ec62..ef1dca257 100644 --- a/src/wallet/api/wallet.h +++ b/src/wallet/api/wallet.h @@ -100,6 +100,10 @@ public: std::string secretSpendKey() const override; std::string publicSpendKey() const override; std::string publicMultisigSignerKey() const override; + std::string secretViewBalance() const override; + std::string secretProveSpend() const override; + std::string secretGenerateAddress() const override; + std::string secretGenerateImage() const override; std::string path() const override; void stop() override; bool store(const std::string &path) override; diff --git a/src/wallet/api/wallet2_api.h b/src/wallet/api/wallet2_api.h index 1a6cab849..c21cc5779 100644 --- a/src/wallet/api/wallet2_api.h +++ b/src/wallet/api/wallet2_api.h @@ -565,6 +565,30 @@ struct Wallet */ virtual std::string publicMultisigSignerKey() const = 0; + /*! + * \brief secretViewBalance - returns Carrot "view balance" secret + * \return - Carrot s_vb + */ + virtual std::string secretViewBalance() const = 0; + + /*! + * \brief secretProveSpend - returns Carrot "prove spend" secret + * \return - Carrot secret k_ps + */ + virtual std::string secretProveSpend() const = 0; + + /*! + * \brief secretGenerateAddress - returns Carrot "generate address" secret + * \return - Carrot secret s_ga + */ + virtual std::string secretGenerateAddress() const = 0; + + /*! + * \brief secretGenerateImage - returns Carrot "generate key image" secret + * \return - Carrot secret k_gi + */ + virtual std::string secretGenerateImage() const = 0; + /*! * \brief stop - interrupts wallet refresh() loop once (doesn't stop background refresh thread) */