/* * This file is part of the Flowee project * Copyright (C) 2009-2010 Satoshi Nakamoto * Copyright (C) 2009-2015 The Bitcoin Core developers * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * Why base-58 instead of standard base-64 encoding? * - Don't want 0OIl characters that look the same in some fonts and * could be used to create visually identical looking data. * - A string with non-alphanumeric characters is not as easily accepted as input. * - E-mail usually won't line-break if there's no punctuation to break at. * - Double-clicking selects the whole string as one word if it's all alphanumeric. */ #ifndef FLOWEE_LEGACY_ENCODINGS_H #define FLOWEE_LEGACY_ENCODINGS_H #include #include #include "script/standard.h" /** base58-encoded Bitcoin addresses. * Public-key-hash-addresses have version 0 (or 111 testnet). * The data vector contains RIPEMD160(SHA256(pubkey)), where pubkey is the serialized public key. * Script-hash-addresses have version 5 (or 196 testnet). * The data vector contains RIPEMD160(SHA256(cscript)), where cscript is the serialized redemption script. */ class CBitcoinAddress : public CBase58Data { public: bool Set(const KeyId &id); bool Set(const CScriptID &id); bool Set(const CTxDestination &dest); bool IsValid() const; CBitcoinAddress() {} CBitcoinAddress(const CTxDestination &dest) { Set(dest); } CBitcoinAddress(const std::string& strAddress) { SetString(strAddress); } CBitcoinAddress(const char* pszAddress) { SetString(pszAddress); } CTxDestination Get() const; bool GetKeyID(KeyId &keyID) const; bool GetScriptId(CScriptID &script) const; bool IsScript() const; }; /** * A base58-encoded secret key */ class CBitcoinSecret : public CBase58Data { public: void SetKey(const PrivateKey& vchSecret); PrivateKey GetKey(); bool IsValid() const; bool SetString(const char* pszSecret); bool SetString(const std::string& strSecret); CBitcoinSecret(const PrivateKey& vchSecret) { SetKey(vchSecret); } CBitcoinSecret() {} }; #endif