wowletify

This commit is contained in:
dsc 2023-01-12 05:07:52 +02:00
parent ab42be18f2
commit e2c99252fd
3 changed files with 38 additions and 4 deletions

View file

@ -2376,9 +2376,24 @@ bool WalletImpl::checkReserveProof(const std::string &address, const std::string
}
}
std::string WalletImpl::signMessage(const std::string &message)
std::string WalletImpl::signMessage(const std::string &message, const std::string &address)
{
return m_wallet->sign(message, tools::wallet2::sign_with_spend_key);
if (address.empty()) {
return m_wallet->sign(message, tools::wallet2::sign_with_spend_key);
}
cryptonote::address_parse_info info;
if (!cryptonote::get_account_address_from_str(info, m_wallet->nettype(), address)) {
setStatusError(tr("Failed to parse address"));
return "";
}
auto index = m_wallet->get_subaddress_index(info.address);
if (!index) {
setStatusError(tr("Address doesn't belong to the wallet"));
return "";
}
return m_wallet->sign(message, tools::wallet2::sign_with_spend_key, *index);
}
bool WalletImpl::verifySignedMessage(const std::string &message, const std::string &address, const std::string &signature) const
@ -2897,6 +2912,17 @@ void WalletImpl::deviceShowAddress(uint32_t accountIndex, uint32_t addressIndex,
m_wallet->device_show_address(accountIndex, addressIndex, payment_id_param);
}
uint64_t WalletImpl::getBytesReceived()
{
return m_wallet->get_bytes_received();
}
uint64_t WalletImpl::getBytesSent()
{
return m_wallet->get_bytes_sent();
}
} // namespace
namespace Bitmonero = Monero;

View file

@ -232,7 +232,7 @@ public:
virtual bool checkSpendProof(const std::string &txid, const std::string &message, const std::string &signature, bool &good) const override;
virtual std::string getReserveProof(bool all, uint32_t account_index, uint64_t amount, const std::string &message) const override;
virtual bool checkReserveProof(const std::string &address, const std::string &message, const std::string &signature, bool &good, uint64_t &total, uint64_t &spent) const override;
virtual std::string signMessage(const std::string &message) override;
virtual std::string signMessage(const std::string &message, const std::string &address) override;
virtual bool verifySignedMessage(const std::string &message, const std::string &address, const std::string &signature) const override;
virtual std::string signMultisigParticipant(const std::string &message) const override;
virtual bool verifyMessageWithPublicKey(const std::string &message, const std::string &publicKey, const std::string &signature) const override;
@ -257,6 +257,8 @@ public:
virtual bool isKeysFileLocked() override;
virtual uint64_t coldKeyImageSync(uint64_t &spent, uint64_t &unspent) override;
virtual void deviceShowAddress(uint32_t accountIndex, uint32_t addressIndex, const std::string &paymentId) override;
virtual uint64_t getBytesReceived() override;
virtual uint64_t getBytesSent() override;
private:
void clearStatus() const;

View file

@ -1145,7 +1145,7 @@ struct Wallet
* \param address - the address to make the signature with, defaults to primary address (optional)
* \return the signature, empty string if the address is invalid or does not belong to the wallet
*/
virtual std::string signMessage(const std::string &message) = 0;
virtual std::string signMessage(const std::string &message, const std::string &address = "") = 0;
/*!
* \brief verifySignedMessage - verify a signature matches a given message
* \param message - the message (arbitrary byte data)
@ -1237,6 +1237,12 @@ struct Wallet
//! shows address on device display
virtual void deviceShowAddress(uint32_t accountIndex, uint32_t addressIndex, const std::string &paymentId) = 0;
//! get bytes received
virtual uint64_t getBytesReceived() = 0;
//! get bytes sent
virtual uint64_t getBytesSent() = 0;
};
/**