diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-12-05 11:23:20 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-12-05 11:24:39 +0100 |
commit | 7d42644dda33c1e1ab0c63730517f4005742f0e1 (patch) | |
tree | 0875f0749310d596bdc621d4ecd494c8a9370a42 /src/bitcoin-tx.cpp | |
parent | c78a18087f76ae53ac421261f9704f5f666d484e (diff) | |
parent | 84877904c0f4c4d403e2c768f437c81226c1e137 (diff) |
Merge pull request #5207
8487790 bitcoin-tx: Add the "-txid" option. Also add the hex-encoded transaction to the JSON output as the "hex" property. (mruddy)
Diffstat (limited to 'src/bitcoin-tx.cpp')
-rw-r--r-- | src/bitcoin-tx.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp index 1cceab3188..23eaebed64 100644 --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -57,6 +57,7 @@ static bool AppInitRawTx(int argc, char* argv[]) strUsage += " -? " + _("This help message") + "\n"; strUsage += " -create " + _("Create new, empty TX.") + "\n"; strUsage += " -json " + _("Select JSON output") + "\n"; + strUsage += " -txid " + _("Output only the hex-encoded transaction id of the resultant transaction.") + "\n"; strUsage += " -regtest " + _("Enter regression test mode, which uses a special chain in which blocks can be solved instantly.") + "\n"; strUsage += " -testnet " + _("Use the test network") + "\n"; strUsage += "\n"; @@ -488,6 +489,13 @@ static void OutputTxJSON(const CTransaction& tx) fprintf(stdout, "%s\n", jsonOutput.c_str()); } +static void OutputTxHash(const CTransaction& tx) +{ + string strHexHash = tx.GetHash().GetHex(); // the hex-encoded transaction hash (aka the transaction id) + + fprintf(stdout, "%s\n", strHexHash.c_str()); +} + static void OutputTxHex(const CTransaction& tx) { string strHex = EncodeHexTx(tx); @@ -499,6 +507,8 @@ static void OutputTx(const CTransaction& tx) { if (GetBoolArg("-json", false)) OutputTxJSON(tx); + else if (GetBoolArg("-txid", false)) + OutputTxHash(tx); else OutputTxHex(tx); } |