/* * This file is part of the Flowee project * Copyright (C) 2017 Pieter Wuille * Copyright (C) 2017 The Bitcoin developers * Copyright (C) 2020-2021 Tom Zander * * 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 . */ #ifndef CASHADDR_H #define CASHADDR_H // Cashaddr is an address format based on bech32. #include #include #include #include namespace CashAddress { /** * Encode a cashaddr string. Returns the empty string in case of failure. */ std::string encode(const std::string &prefix, const std::vector &values); /** * Decode a cashaddr string. Returns (prefix, data). Empty prefix means failure. */ std::pair> decode(const std::string &str, const std::string &default_prefix); enum AddressType : uint8_t { PUBKEY_TYPE = 0, SCRIPT_TYPE = 1 }; struct Content { AddressType type; std::vector hash; }; std::string encodeCashAddr(const std::string &prefix, const Content &content); Content decodeCashAddrContent(const std::string &addr, const std::string &prefix); std::vector packCashAddrContent(const Content &content); /** * create a default script for the type and has the output-script * to get a unique ID for the entire out-script. * * \param content the previously parsed content. * \return the sha256 hash */ Streaming::ConstBuffer createHashedOutputScript(const Content &content); } // namespace CashAddress #endif