mirror of
https://github.com/wownero/wownero-cpp.git
synced 2026-10-19 08:08:39 +02:00
implemented getAddressIndex()
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user