mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-30 06:43:28 +01:00
wallet_api: add address validation functions
The payment id from integrated addresses is also parsed
This commit is contained in:
parent
34fcfcd7cc
commit
06b642dfe4
@ -162,6 +162,26 @@ bool Wallet::paymentIdValid(const string &paiment_id)
|
||||
return tools::wallet2::parse_short_payment_id(paiment_id, pid);
|
||||
}
|
||||
|
||||
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();
|
||||
|
@ -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();
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user