aboutsummaryrefslogtreecommitdiff
path: root/src/base58.cpp
diff options
context:
space:
mode:
authorPieter Wuille <[email protected]>2017-08-22 18:02:33 -0700
committerPieter Wuille <[email protected]>2017-09-06 13:07:45 -0700
commit5c8ff0d448ffdc6340b195ddfa2128d5f21a839b (patch)
tree63a83a0708303a8d8382739c283bb41e07bdc5fe /src/base58.cpp
parentMerge #10596: Add vConnect to CConnman::Options (diff)
downloaddiscoin-5c8ff0d448ffdc6340b195ddfa2128d5f21a839b.tar.xz
discoin-5c8ff0d448ffdc6340b195ddfa2128d5f21a839b.zip
Introduce wrappers around CBitcoinAddress
This patch removes the need for the intermediary Base58 type CBitcoinAddress, by providing {Encode,Decode,IsValid}Destination function that directly operate on the conversion between strings and CTxDestination.
Diffstat (limited to 'src/base58.cpp')
-rw-r--r--src/base58.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/base58.cpp b/src/base58.cpp
index 3802f953f..69692c95e 100644
--- a/src/base58.cpp
+++ b/src/base58.cpp
@@ -318,3 +318,25 @@ bool CBitcoinSecret::SetString(const std::string& strSecret)
{
return SetString(strSecret.c_str());
}
+
+std::string EncodeDestination(const CTxDestination& dest)
+{
+ CBitcoinAddress addr(dest);
+ if (!addr.IsValid()) return "";
+ return addr.ToString();
+}
+
+CTxDestination DecodeDestination(const std::string& str)
+{
+ return CBitcoinAddress(str).Get();
+}
+
+bool IsValidDestinationString(const std::string& str, const CChainParams& params)
+{
+ return CBitcoinAddress(str).IsValid(params);
+}
+
+bool IsValidDestinationString(const std::string& str)
+{
+ return CBitcoinAddress(str).IsValid();
+}