Add normalized transaction hash

This commit is contained in:
janko33bd
2018-01-16 21:58:20 +01:00
parent 6484a9e9b2
commit 65e7103954
3 changed files with 24 additions and 0 deletions

View File

@@ -676,6 +676,21 @@ static void TxInErrorToJSON(const CTxIn& txin, UniValue& vErrorsRet, const std::
vErrorsRet.push_back(entry);
}
UniValue getnormalizedtxid(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"getnormalizedtxid <hex string>\n"
"Return the normalized transaction ID.");
// parse hex string from parameter
CTransaction tx;
if (!DecodeHexTx(tx, params[0].get_str()))
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
uint256 hashNormalized = CMutableTransaction(tx).GetNormalizedHash();
return hashNormalized.GetHex();
}
UniValue signrawtransaction(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 4)
@@ -1003,6 +1018,7 @@ static const CRPCCommand commands[] =
{ "rawtransactions", "decodescript", &decodescript, true },
{ "rawtransactions", "sendrawtransaction", &sendrawtransaction, false },
{ "rawtransactions", "signrawtransaction", &signrawtransaction, false }, /* uses wallet if enabled */
{ "rawtransactions", "getnormalizedtxid", &getnormalizedtxid, true },
{ "blockchain", "gettxoutproof", &gettxoutproof, true },
{ "blockchain", "verifytxoutproof", &verifytxoutproof, true },