From 0a9abedc5dba747fa40d4ebfcbe2ab3ab4adae65 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sun, 26 Jun 2022 04:40:06 -0700 Subject: [PATCH] Return size in bytes of a tx from getrawtransaction --- src/rpc/rawtransaction.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 6c115cb67..2e82c061a 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -367,6 +367,7 @@ UniValue getrawtransaction(const UniValue& params, bool fHelp, const CPubKey& my "\nResult (if verbose > 0):\n" "{\n" " \"hex\" : \"data\", (string) The serialized, hex-encoded data for 'txid'\n" + " \"size\" : n, (numeric) The length in bytes\n" " \"txid\" : \"id\", (string) The transaction id (same as provided)\n" " \"version\" : n, (numeric) The version\n" " \"locktime\" : ttt, (numeric) The lock time\n" @@ -453,6 +454,7 @@ UniValue getrawtransaction(const UniValue& params, bool fHelp, const CPubKey& my UniValue result(UniValue::VOBJ); result.push_back(Pair("hex", strHex)); + result.push_back(Pair("size", GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION) )); TxToJSONExpanded(tx, hashBlock, result, nHeight, nConfirmations, nBlockTime); return result; }