|
| 1 | +/** |
| 2 | + * Copyright (c) 2011-2019 libbitcoin developers (see AUTHORS) |
| 3 | + * |
| 4 | + * This file is part of libbitcoin. |
| 5 | + * |
| 6 | + * This program is free software: you can redistribute it and/or modify |
| 7 | + * it under the terms of the GNU Affero General Public License as published by |
| 8 | + * the Free Software Foundation, either version 3 of the License, or |
| 9 | + * (at your option) any later version. |
| 10 | + * |
| 11 | + * This program is distributed in the hope that it will be useful, |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | + * GNU Affero General Public License for more details. |
| 15 | + * |
| 16 | + * You should have received a copy of the GNU Affero General Public License |
| 17 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | + */ |
| 19 | +#ifndef BX_CHECKED_DECODE_HPP |
| 20 | +#define BX_CHECKED_DECODE_HPP |
| 21 | + |
| 22 | +#include <cstdint> |
| 23 | +#include <iostream> |
| 24 | +#include <string> |
| 25 | +#include <vector> |
| 26 | +#include <boost/program_options.hpp> |
| 27 | +#include <bitcoin/system.hpp> |
| 28 | +#include <bitcoin/explorer/command.hpp> |
| 29 | +#include <bitcoin/explorer/define.hpp> |
| 30 | +#include <bitcoin/explorer/generated.hpp> |
| 31 | +#include <bitcoin/explorer/config/address.hpp> |
| 32 | +#include <bitcoin/explorer/config/algorithm.hpp> |
| 33 | +#include <bitcoin/explorer/config/btc.hpp> |
| 34 | +#include <bitcoin/explorer/config/byte.hpp> |
| 35 | +#include <bitcoin/explorer/config/bytes.hpp> |
| 36 | +#include <bitcoin/explorer/config/electrum.hpp> |
| 37 | +#include <bitcoin/explorer/config/encoding.hpp> |
| 38 | +#include <bitcoin/explorer/config/endorsement.hpp> |
| 39 | +#include <bitcoin/explorer/config/hd_key.hpp> |
| 40 | +#include <bitcoin/explorer/config/language.hpp> |
| 41 | +#include <bitcoin/explorer/config/sighash.hpp> |
| 42 | +#include <bitcoin/explorer/config/signature.hpp> |
| 43 | +#include <bitcoin/explorer/config/witness.hpp> |
| 44 | +#include <bitcoin/explorer/config/wrapper.hpp> |
| 45 | +#include <bitcoin/explorer/utility.hpp> |
| 46 | + |
| 47 | +/********* GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY **********/ |
| 48 | + |
| 49 | +namespace libbitcoin { |
| 50 | +namespace explorer { |
| 51 | +namespace commands { |
| 52 | + |
| 53 | +/** |
| 54 | + * Class to implement the checked-decode command. |
| 55 | + */ |
| 56 | +class BCX_API checked_decode |
| 57 | + : public command |
| 58 | +{ |
| 59 | +public: |
| 60 | + |
| 61 | + /** |
| 62 | + * The symbolic (not localizable) command name, lower case. |
| 63 | + */ |
| 64 | + static const char* symbol() |
| 65 | + { |
| 66 | + return "checked-decode"; |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * The symbolic (not localizable) former command name, lower case. |
| 71 | + */ |
| 72 | + static const char* formerly() |
| 73 | + { |
| 74 | + return "wrap-decode"; |
| 75 | + } |
| 76 | + |
| 77 | + /** |
| 78 | + * Destructor. |
| 79 | + */ |
| 80 | + virtual ~checked_decode() |
| 81 | + { |
| 82 | + } |
| 83 | + |
| 84 | + /** |
| 85 | + * The member symbolic (not localizable) command name, lower case. |
| 86 | + */ |
| 87 | + virtual const char* name() |
| 88 | + { |
| 89 | + return checked_decode::symbol(); |
| 90 | + } |
| 91 | + |
| 92 | + /** |
| 93 | + * The localizable command category name, upper case. |
| 94 | + */ |
| 95 | + virtual const char* category() |
| 96 | + { |
| 97 | + return "ENCODING"; |
| 98 | + } |
| 99 | + |
| 100 | + /** |
| 101 | + * The localizable command description. |
| 102 | + */ |
| 103 | + virtual const char* description() |
| 104 | + { |
| 105 | + return "Validate the checksum of checked Base16 data and recover its version and payload."; |
| 106 | + } |
| 107 | + |
| 108 | + /** |
| 109 | + * Load program argument definitions. |
| 110 | + * A value of -1 indicates that the number of instances is unlimited. |
| 111 | + * @return The loaded program argument definitions. |
| 112 | + */ |
| 113 | + virtual system::arguments_metadata& load_arguments() |
| 114 | + { |
| 115 | + return get_argument_metadata() |
| 116 | + .add("WRAPPED", 1); |
| 117 | + } |
| 118 | + |
| 119 | + /** |
| 120 | + * Load parameter fallbacks from file or input as appropriate. |
| 121 | + * @param[in] input The input stream for loading the parameters. |
| 122 | + * @param[in] The loaded variables. |
| 123 | + */ |
| 124 | + virtual void load_fallbacks(std::istream& input, |
| 125 | + po::variables_map& variables) |
| 126 | + { |
| 127 | + const auto raw = requires_raw_input(); |
| 128 | + load_input(get_wrapped_argument(), "WRAPPED", variables, input, raw); |
| 129 | + } |
| 130 | + |
| 131 | + /** |
| 132 | + * Load program option definitions. |
| 133 | + * BUGBUG: see boost bug/fix: svn.boost.org/trac/boost/ticket/8009 |
| 134 | + * @return The loaded program option definitions. |
| 135 | + */ |
| 136 | + virtual system::options_metadata& load_options() |
| 137 | + { |
| 138 | + using namespace po; |
| 139 | + options_description& options = get_option_metadata(); |
| 140 | + options.add_options() |
| 141 | + ( |
| 142 | + BX_HELP_VARIABLE ",h", |
| 143 | + value<bool>()->zero_tokens(), |
| 144 | + "Get a description and instructions for this command." |
| 145 | + ) |
| 146 | + ( |
| 147 | + BX_CONFIG_VARIABLE ",c", |
| 148 | + value<boost::filesystem::path>(), |
| 149 | + "The path to the configuration settings file." |
| 150 | + ) |
| 151 | + ( |
| 152 | + "format,f", |
| 153 | + value<explorer::config::encoding>(&option_.format), |
| 154 | + "The output format. Options are 'info', 'json' and 'xml', defaults to 'info'." |
| 155 | + ) |
| 156 | + ( |
| 157 | + "WRAPPED", |
| 158 | + value<explorer::config::wrapper>(&argument_.wrapped), |
| 159 | + "The Base16 data to decode. If not specified the value is read from STDIN." |
| 160 | + ); |
| 161 | + |
| 162 | + return options; |
| 163 | + } |
| 164 | + |
| 165 | + /** |
| 166 | + * Set variable defaults from configuration variable values. |
| 167 | + * @param[in] variables The loaded variables. |
| 168 | + */ |
| 169 | + virtual void set_defaults_from_config(po::variables_map& variables) |
| 170 | + { |
| 171 | + } |
| 172 | + |
| 173 | + /** |
| 174 | + * Invoke the command. |
| 175 | + * @param[out] output The input stream for the command execution. |
| 176 | + * @param[out] error The input stream for the command execution. |
| 177 | + * @return The appropriate console return code { -1, 0, 1 }. |
| 178 | + */ |
| 179 | + virtual system::console_result invoke(std::ostream& output, |
| 180 | + std::ostream& cerr); |
| 181 | + |
| 182 | + /* Properties */ |
| 183 | + |
| 184 | + /** |
| 185 | + * Get the value of the WRAPPED argument. |
| 186 | + */ |
| 187 | + virtual explorer::config::wrapper& get_wrapped_argument() |
| 188 | + { |
| 189 | + return argument_.wrapped; |
| 190 | + } |
| 191 | + |
| 192 | + /** |
| 193 | + * Set the value of the WRAPPED argument. |
| 194 | + */ |
| 195 | + virtual void set_wrapped_argument( |
| 196 | + const explorer::config::wrapper& value) |
| 197 | + { |
| 198 | + argument_.wrapped = value; |
| 199 | + } |
| 200 | + |
| 201 | + /** |
| 202 | + * Get the value of the format option. |
| 203 | + */ |
| 204 | + virtual explorer::config::encoding& get_format_option() |
| 205 | + { |
| 206 | + return option_.format; |
| 207 | + } |
| 208 | + |
| 209 | + /** |
| 210 | + * Set the value of the format option. |
| 211 | + */ |
| 212 | + virtual void set_format_option( |
| 213 | + const explorer::config::encoding& value) |
| 214 | + { |
| 215 | + option_.format = value; |
| 216 | + } |
| 217 | + |
| 218 | +private: |
| 219 | + |
| 220 | + /** |
| 221 | + * Command line argument bound variables. |
| 222 | + * Uses cross-compiler safe constructor-based zeroize. |
| 223 | + * Zeroize for unit test consistency with program_options initialization. |
| 224 | + */ |
| 225 | + struct argument |
| 226 | + { |
| 227 | + argument() |
| 228 | + : wrapped() |
| 229 | + { |
| 230 | + } |
| 231 | + |
| 232 | + explorer::config::wrapper wrapped; |
| 233 | + } argument_; |
| 234 | + |
| 235 | + /** |
| 236 | + * Command line option bound variables. |
| 237 | + * Uses cross-compiler safe constructor-based zeroize. |
| 238 | + * Zeroize for unit test consistency with program_options initialization. |
| 239 | + */ |
| 240 | + struct option |
| 241 | + { |
| 242 | + option() |
| 243 | + : format() |
| 244 | + { |
| 245 | + } |
| 246 | + |
| 247 | + explorer::config::encoding format; |
| 248 | + } option_; |
| 249 | +}; |
| 250 | + |
| 251 | +} // namespace commands |
| 252 | +} // namespace explorer |
| 253 | +} // namespace libbitcoin |
| 254 | + |
| 255 | +#endif |
0 commit comments