implemented getAddressIndex()

This commit is contained in:
woodser
2019-06-02 21:23:04 -04:00
parent f3b51a9e4f
commit 6850b64f79
2 changed files with 28 additions and 9 deletions
+20 -1
View File
@@ -208,7 +208,26 @@ namespace monero {
return wallet2->get_subaddress_as_str({accountIdx, subaddressIdx});
}
// get address index
MoneroSubaddress MoneroWallet::getAddressIndex(const string& address) const {
cout << "getAddressIndex(" << address << ")" << endl;
// validate address
cryptonote::address_parse_info info;
if (!get_account_address_from_str(info, wallet2->nettype(), address)) {
throw runtime_error("Invalid address");
}
// get index of address in wallet
auto index = wallet2->get_subaddress_index(info.address);
if (!index) throw runtime_error("Address doesn't belong to the wallet");
// return indices in subaddress
MoneroSubaddress subaddress;
cryptonote::subaddress_index cnIndex = *index;
subaddress.accountIndex = cnIndex.major;
subaddress.index = cnIndex.minor;
return subaddress;
}
string MoneroWallet::getMnemonic() const {
epee::wipeable_string wipeablePassword;
+8 -8
View File
@@ -309,14 +309,14 @@ namespace monero {
*/
string getAddress(const uint32_t accountIdx, const uint32_t subaddressIdx) const;
// /**
// * Get the account and subaddress index of the given address.
// *
// * @param address is the address to get the account and subaddress index from
// * @return the account and subaddress indices
// * @throws exception if address is not a wallet address
// */
// public MoneroSubaddress getAddressIndex(String address);
/**
* Get the account and subaddress index of the given address.
*
* @param address is the address to get the account and subaddress index from
* @return the account and subaddress indices
* @throws exception if address is not a wallet address
*/
MoneroSubaddress getAddressIndex(const string& address) const;
// /**
// * Get an integrated address based on this wallet's primary address and the