Changeset View
Changeset View
Standalone View
Standalone View
src/bitcoin-tx.cpp
Show All 33 Lines | |||||
// | // | ||||
// This function returns either one of EXIT_ codes when it's expected to stop | // This function returns either one of EXIT_ codes when it's expected to stop | ||||
// the process or CONTINUE_EXECUTION when it's expected to continue further. | // the process or CONTINUE_EXECUTION when it's expected to continue further. | ||||
// | // | ||||
static int AppInitRawTx(int argc, char *argv[]) { | static int AppInitRawTx(int argc, char *argv[]) { | ||||
// | // | ||||
// Parameters | // Parameters | ||||
// | // | ||||
ParseParameters(argc, argv); | gArgs.ParseParameters(argc, argv); | ||||
// Check for -testnet or -regtest parameter (Params() calls are only valid | // Check for -testnet or -regtest parameter (Params() calls are only valid | ||||
// after this clause) | // after this clause) | ||||
try { | try { | ||||
SelectParams(ChainNameFromCommandLine()); | SelectParams(ChainNameFromCommandLine()); | ||||
} catch (const std::exception &e) { | } catch (const std::exception &e) { | ||||
fprintf(stderr, "Error: %s\n", e.what()); | fprintf(stderr, "Error: %s\n", e.what()); | ||||
return EXIT_FAILURE; | return EXIT_FAILURE; | ||||
} | } | ||||
fCreateBlank = GetBoolArg("-create", false); | fCreateBlank = gArgs.GetBoolArg("-create", false); | ||||
if (argc < 2 || IsArgSet("-?") || IsArgSet("-h") || IsArgSet("-help")) { | if (argc < 2 || gArgs.IsArgSet("-?") || gArgs.IsArgSet("-h") || | ||||
gArgs.IsArgSet("-help")) { | |||||
// First part of help message is specific to this utility | // First part of help message is specific to this utility | ||||
std::string strUsage = | std::string strUsage = | ||||
strprintf(_("%s bitcoin-tx utility version"), _(PACKAGE_NAME)) + | strprintf(_("%s bitcoin-tx utility version"), _(PACKAGE_NAME)) + | ||||
" " + FormatFullVersion() + "\n\n" + _("Usage:") + "\n" + | " " + FormatFullVersion() + "\n\n" + _("Usage:") + "\n" + | ||||
" bitcoin-tx [options] <hex-tx> [commands] " + | " bitcoin-tx [options] <hex-tx> [commands] " + | ||||
_("Update hex-encoded bitcoin transaction") + "\n" + | _("Update hex-encoded bitcoin transaction") + "\n" + | ||||
" bitcoin-tx [options] -create [commands] " + | " bitcoin-tx [options] -create [commands] " + | ||||
_("Create hex-encoded bitcoin transaction") + "\n" + "\n"; | _("Create hex-encoded bitcoin transaction") + "\n" + "\n"; | ||||
▲ Show 20 Lines • Show All 704 Lines • ▼ Show 20 Lines | |||||
static void OutputTxHex(const CTransaction &tx) { | static void OutputTxHex(const CTransaction &tx) { | ||||
std::string strHex = EncodeHexTx(tx); | std::string strHex = EncodeHexTx(tx); | ||||
fprintf(stdout, "%s\n", strHex.c_str()); | fprintf(stdout, "%s\n", strHex.c_str()); | ||||
} | } | ||||
static void OutputTx(const CTransaction &tx) { | static void OutputTx(const CTransaction &tx) { | ||||
if (GetBoolArg("-json", false)) { | if (gArgs.GetBoolArg("-json", false)) { | ||||
OutputTxJSON(tx); | OutputTxJSON(tx); | ||||
} else if (GetBoolArg("-txid", false)) { | } else if (gArgs.GetBoolArg("-txid", false)) { | ||||
OutputTxHash(tx); | OutputTxHash(tx); | ||||
} else { | } else { | ||||
OutputTxHex(tx); | OutputTxHex(tx); | ||||
} | } | ||||
} | } | ||||
static std::string readStdin() { | static std::string readStdin() { | ||||
char buf[4096]; | char buf[4096]; | ||||
▲ Show 20 Lines • Show All 114 Lines • Show Last 20 Lines |