aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-10-16 16:52:45 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-10-16 16:52:45 +0100
commit06b642dfe4b27216615310440ecd8d37db5652a0 (patch)
tree231c514dfdcee33028d07153224309ac8cc454c6 /src/wallet
parentMerge pull request #1203 (diff)
downloadmonero-06b642dfe4b27216615310440ecd8d37db5652a0.tar.xz
wallet_api: add address validation functions
The payment id from integrated addresses is also parsed
Diffstat (limited to '')
-rw-r--r--src/wallet/api/wallet.cpp20
-rw-r--r--src/wallet/wallet2_api.h2
2 files changed, 22 insertions, 0 deletions
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp
index d1c849537..50a399e9e 100644
--- a/src/wallet/api/wallet.cpp
+++ b/src/wallet/api/wallet.cpp
@@ -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();
diff --git a/src/wallet/wallet2_api.h b/src/wallet/wallet2_api.h
index 0f622c26c..8427ba250 100644
--- a/src/wallet/wallet2_api.h
+++ b/src/wallet/wallet2_api.h
@@ -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();
/**