subaddressIndex()

This commit is contained in:
thotbot 2021-07-03 23:47:55 +02:00 committed by wowario
parent ae0ea220d5
commit 29613140f2
3 changed files with 23 additions and 0 deletions

View file

@ -890,6 +890,27 @@ std::string WalletImpl::address(uint32_t accountIndex, uint32_t addressIndex) co
return m_wallet->get_subaddress_as_str({accountIndex, addressIndex});
}
bool WalletImpl::subaddressIndex(std::string address, std::pair<uint32_t, uint32_t> &index) const
{
clearStatus();
cryptonote::address_parse_info info;
if (!cryptonote::get_account_address_from_str(info, m_wallet->nettype(), address)) {
setStatusError(tr("Failed to parse address"));
return false;
}
auto i = m_wallet->get_subaddress_index(info.address);
if (!i) {
setStatusError(tr("Address doesn't belong to the wallet"));
return false;
}
index.first = i->major;
index.second = i->minor;
return true;
}
std::string WalletImpl::integratedAddress(const std::string &payment_id) const
{
crypto::hash8 pid;

View file

@ -100,6 +100,7 @@ public:
bool setDevicePin(const std::string &password) override;
bool setDevicePassphrase(const std::string &password) override;
std::string address(uint32_t accountIndex = 0, uint32_t addressIndex = 0) const override;
bool subaddressIndex(std::string address, std::pair<uint32_t, uint32_t> &index) const override;
std::string integratedAddress(const std::string &payment_id) const override;
std::string secretViewKey() const override;
std::string publicViewKey() const override;

View file

@ -556,6 +556,7 @@ struct Wallet
virtual bool setDevicePin(const std::string &pin) { (void)pin; return false; };
virtual bool setDevicePassphrase(const std::string &passphrase) { (void)passphrase; return false; };
virtual std::string address(uint32_t accountIndex = 0, uint32_t addressIndex = 0) const = 0;
virtual bool subaddressIndex(std::string address, std::pair<uint32_t, uint32_t> &index) const = 0;
std::string mainAddress() const { return address(0, 0); }
virtual std::string path() const = 0;
virtual NetworkType nettype() const = 0;