Skip to content

Commit

Permalink
Expose a transaction's weight via RPC
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt committed Apr 13, 2018
1 parent 5f2a399 commit 2874709
Show file tree
Hide file tree
Showing 26 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core_write.cpp
Expand Up @@ -161,6 +161,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
entry.pushKV("version", tx.nVersion);
entry.pushKV("size", (int)::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION));
entry.pushKV("vsize", (GetTransactionWeight(tx) + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR);
entry.pushKV("weight", GetTransactionWeight(tx));
entry.pushKV("locktime", (int64_t)tx.nLockTime);

UniValue vin(UniValue::VARR);
Expand Down
2 changes: 2 additions & 0 deletions src/rpc/rawtransaction.cpp
Expand Up @@ -94,6 +94,7 @@ UniValue getrawtransaction(const JSONRPCRequest& request)
" \"hash\" : \"id\", (string) The transaction hash (differs from txid for witness transactions)\n"
" \"size\" : n, (numeric) The serialized transaction size\n"
" \"vsize\" : n, (numeric) The virtual transaction size (differs from size for witness transactions)\n"
" \"weight\" : n, (numeric) The transaction's weight (between vsize*4-3 and vsize*4)\n"
" \"version\" : n, (numeric) The version\n"
" \"locktime\" : ttt, (numeric) The lock time\n"
" \"vin\" : [ (array of json objects)\n"
Expand Down Expand Up @@ -494,6 +495,7 @@ UniValue decoderawtransaction(const JSONRPCRequest& request)
" \"hash\" : \"id\", (string) The transaction hash (differs from txid for witness transactions)\n"
" \"size\" : n, (numeric) The transaction size\n"
" \"vsize\" : n, (numeric) The virtual transaction size (differs from size for witness transactions)\n"
" \"weight\" : n, (numeric) The transaction's weight (between vsize*4 - 3 and vsize*4)\n"
" \"version\" : n, (numeric) The version\n"
" \"locktime\" : ttt, (numeric) The lock time\n"
" \"vin\" : [ (array of json objects)\n"
Expand Down
1 change: 1 addition & 0 deletions test/util/data/blanktxv1.json
Expand Up @@ -4,6 +4,7 @@
"version": 1,
"size": 10,
"vsize": 10,
"weight": 40,
"locktime": 0,
"vin": [
],
Expand Down
1 change: 1 addition & 0 deletions test/util/data/blanktxv2.json
Expand Up @@ -4,6 +4,7 @@
"version": 2,
"size": 10,
"vsize": 10,
"weight": 40,
"locktime": 0,
"vin": [
],
Expand Down
1 change: 1 addition & 0 deletions test/util/data/tt-delin1-out.json
Expand Up @@ -4,6 +4,7 @@
"version": 1,
"size": 3040,
"vsize": 3040,
"weight": 12160,
"locktime": 0,
"vin": [
{
Expand Down
1 change: 1 addition & 0 deletions test/util/data/tt-delout1-out.json
Expand Up @@ -4,6 +4,7 @@
"version": 1,
"size": 3155,
"vsize": 3155,
"weight": 12620,
"locktime": 0,
"vin": [
{
Expand Down
1 change: 1 addition & 0 deletions test/util/data/tt-locktime317000-out.json
Expand Up @@ -4,6 +4,7 @@
"version": 1,
"size": 3189,
"vsize": 3189,
"weight": 12756,
"locktime": 317000,
"vin": [
{
Expand Down
1 change: 1 addition & 0 deletions test/util/data/txcreate1.json
Expand Up @@ -4,6 +4,7 @@
"version": 2,
"size": 201,
"vsize": 201,
"weight": 804,
"locktime": 0,
"vin": [
{
Expand Down
1 change: 1 addition & 0 deletions test/util/data/txcreate2.json
Expand Up @@ -4,6 +4,7 @@
"version": 2,
"size": 19,
"vsize": 19,
"weight": 76,
"locktime": 0,
"vin": [
],
Expand Down
1 change: 1 addition & 0 deletions test/util/data/txcreatedata1.json
Expand Up @@ -4,6 +4,7 @@
"version": 1,
"size": 176,
"vsize": 176,
"weight": 704,
"locktime": 0,
"vin": [
{
Expand Down
1 change: 1 addition & 0 deletions test/util/data/txcreatedata2.json
Expand Up @@ -4,6 +4,7 @@
"version": 2,
"size": 176,
"vsize": 176,
"weight": 704,
"locktime": 0,
"vin": [
{
Expand Down
1 change: 1 addition & 0 deletions test/util/data/txcreatedata_seq0.json
Expand Up @@ -4,6 +4,7 @@
"version": 2,
"size": 85,
"vsize": 85,
"weight": 340,
"locktime": 0,
"vin": [
{
Expand Down
1 change: 1 addition & 0 deletions test/util/data/txcreatedata_seq1.json
Expand Up @@ -4,6 +4,7 @@
"version": 1,
"size": 126,
"vsize": 126,
"weight": 504,
"locktime": 0,
"vin": [
{
Expand Down
1 change: 1 addition & 0 deletions test/util/data/txcreatemultisig1.json
Expand Up @@ -4,6 +4,7 @@
"version": 1,
"size": 124,
"vsize": 124,
"weight": 496,
"locktime": 0,
"vin": [
],
Expand Down
1 change: 1 addition & 0 deletions test/util/data/txcreatemultisig2.json
Expand Up @@ -4,6 +4,7 @@
"version": 1,
"size": 42,
"vsize": 42,
"weight": 168,
"locktime": 0,
"vin": [
],
Expand Down
1 change: 1 addition & 0 deletions test/util/data/txcreatemultisig3.json
Expand Up @@ -4,6 +4,7 @@
"version": 1,
"size": 53,
"vsize": 53,
"weight": 212,
"locktime": 0,
"vin": [
],
Expand Down
1 change: 1 addition & 0 deletions test/util/data/txcreatemultisig4.json
Expand Up @@ -4,6 +4,7 @@
"version": 1,
"size": 42,
"vsize": 42,
"weight": 168,
"locktime": 0,
"vin": [
],
Expand Down
1 change: 1 addition & 0 deletions test/util/data/txcreatemultisig5.json
Expand Up @@ -4,6 +4,7 @@
"version": 2,
"size": 42,
"vsize": 42,
"weight": 168,
"locktime": 0,
"vin": [
],
Expand Down
1 change: 1 addition & 0 deletions test/util/data/txcreateoutpubkey1.json
Expand Up @@ -4,6 +4,7 @@
"version": 1,
"size": 54,
"vsize": 54,
"weight": 216,
"locktime": 0,
"vin": [
],
Expand Down
1 change: 1 addition & 0 deletions test/util/data/txcreateoutpubkey2.json
Expand Up @@ -4,6 +4,7 @@
"version": 1,
"size": 41,
"vsize": 41,
"weight": 164,
"locktime": 0,
"vin": [
],
Expand Down
1 change: 1 addition & 0 deletions test/util/data/txcreateoutpubkey3.json
Expand Up @@ -4,6 +4,7 @@
"version": 1,
"size": 42,
"vsize": 42,
"weight": 168,
"locktime": 0,
"vin": [
],
Expand Down
1 change: 1 addition & 0 deletions test/util/data/txcreatescript1.json
Expand Up @@ -4,6 +4,7 @@
"version": 1,
"size": 20,
"vsize": 20,
"weight": 80,
"locktime": 0,
"vin": [
],
Expand Down
1 change: 1 addition & 0 deletions test/util/data/txcreatescript2.json
Expand Up @@ -4,6 +4,7 @@
"version": 1,
"size": 42,
"vsize": 42,
"weight": 168,
"locktime": 0,
"vin": [
],
Expand Down
1 change: 1 addition & 0 deletions test/util/data/txcreatescript3.json
Expand Up @@ -4,6 +4,7 @@
"version": 1,
"size": 53,
"vsize": 53,
"weight": 212,
"locktime": 0,
"vin": [
],
Expand Down
1 change: 1 addition & 0 deletions test/util/data/txcreatescript4.json
Expand Up @@ -4,6 +4,7 @@
"version": 1,
"size": 42,
"vsize": 42,
"weight": 168,
"locktime": 0,
"vin": [
],
Expand Down
1 change: 1 addition & 0 deletions test/util/data/txcreatesignv1.json
Expand Up @@ -4,6 +4,7 @@
"version": 1,
"size": 224,
"vsize": 224,
"weight": 896,
"locktime": 0,
"vin": [
{
Expand Down

0 comments on commit 2874709

Please sign in to comment.