Add CashAddr Address Format
Ported from Bitcoin Unlimited, Bitcoin ABC
This commit is contained in:
33
src/dstencode.cpp
Normal file
33
src/dstencode.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) 2017 The Bitcoin developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
#include "dstencode.h"
|
||||
#include "base58.h"
|
||||
#include "cashaddrenc.h"
|
||||
#include "chainparams.h"
|
||||
#include "config.h"
|
||||
#include "script/standard.h"
|
||||
|
||||
std::string EncodeDestination(const CTxDestination &dst, const CChainParams ¶ms, const Config &cfg)
|
||||
{
|
||||
return cfg.UseCashAddrEncoding() ? EncodeCashAddr(dst, params) : EncodeLegacyAddr(dst, params);
|
||||
}
|
||||
|
||||
CTxDestination DecodeDestination(const std::string &addr, const CChainParams ¶ms)
|
||||
{
|
||||
CTxDestination dst = DecodeCashAddr(addr, params);
|
||||
if (IsValidDestination(dst))
|
||||
{
|
||||
return dst;
|
||||
}
|
||||
return DecodeLegacyAddr(addr, params);
|
||||
}
|
||||
|
||||
bool IsValidDestinationString(const std::string &addr, const CChainParams ¶ms)
|
||||
{
|
||||
return IsValidDestination(DecodeDestination(addr, params));
|
||||
}
|
||||
|
||||
std::string EncodeDestination(const CTxDestination &dst) { return EncodeDestination(dst, Params(), GetConfig()); }
|
||||
CTxDestination DecodeDestination(const std::string &addr) { return DecodeDestination(addr, Params()); }
|
||||
bool IsValidDestinationString(const std::string &addr) { return IsValidDestinationString(addr, Params()); }
|
||||
Reference in New Issue
Block a user