Merge pull request #1230

06b642d wallet_api: add address validation functions (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2016-10-23 19:04:01 +02:00
commit 92095104fe
No known key found for this signature in database
GPG Key ID: 55432DF31CCD4FCD
2 changed files with 22 additions and 0 deletions

View File

@ -167,6 +167,26 @@ bool Wallet::paymentIdValid(const string &paiment_id)
return false;
}
bool Wallet::addressValid(const std::string &str, bool testnet)
{
bool has_payment_id;
cryptonote::account_public_address address;
crypto::hash8 pid;
return get_account_integrated_address_from_str(address, has_payment_id, pid, testnet, str);
}
std::string Wallet::paymentIdFromAddress(const std::string &str, bool testnet)
{
bool has_payment_id;
cryptonote::account_public_address address;
crypto::hash8 pid;
if (!get_account_integrated_address_from_str(address, has_payment_id, pid, testnet, str))
return "";
if (!has_payment_id)
return "";
return epee::string_tools::pod_to_hex(pid);
}
uint64_t Wallet::maximumAllowedAmount()
{
return std::numeric_limits<uint64_t>::max();

View File

@ -280,6 +280,8 @@ struct Wallet
static uint64_t amountFromDouble(double amount);
static std::string genPaymentId();
static bool paymentIdValid(const std::string &paiment_id);
static bool addressValid(const std::string &str, bool testnet);
static std::string paymentIdFromAddress(const std::string &str, bool testnet);
static uint64_t maximumAllowedAmount();
/**