Skip to content

Commit

Permalink
Merge #868: [RPC] add vout.n sequence number to decoderawtransaction
Browse files Browse the repository at this point in the history
f20b416 [RPC] add vout.n sequence number to decoderawtransaction (Cave Spectre)

Pull request description:

  ### Problem
  When looking at raw transactions in the block chain, the vout sequence number is not shown

  ### Root Cause
  Wasn't implemented

  ### Solution
  Implement it

  ### Testing
  Transactions now have a "vout.n" in vout sections, showing what the output sequence is [for use as input to raw transactions].
  ```
      {
        "type": "standard",
        "value": 345600.00000000,
        "valueSat": 34560000000000,
        "vout.n": 2,
        "scriptPubKey": {
          "asm": "OP_HASH160 4874bc3b94c4c85cf858670fef39d38fbe0d7b8b OP_EQUAL",
          "hex": "a9144874bc3b94c4c85cf858670fef39d38fbe0d7b8b87",
          "reqSigs": 1,
          "type": "scripthash",
          "addresses": [
            "38J8RGLetRUNEXycBMPg8oZqLt4bB9hCbt"
          ]
        }
  ```

Tree-SHA512: 5b333582e529adf463ad230127e7446f37738912210e90a13e8c2db1956a1710725961f136af716b72f16998fe7834d42c2a56290b37e10074b7248fa4452ea6
  • Loading branch information
codeofalltrades committed Nov 9, 2020
2 parents 8bed093 + f20b416 commit 08c6a26
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 26 deletions.
4 changes: 4 additions & 0 deletions src/core_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ void OutputToJSON(uint256 &txid, int i,
CTxOutStandard *s = (CTxOutStandard*) baseOut;
entry.pushKV("value", ValueFromAmount(s->nValue));
entry.pushKV("valueSat", s->nValue);
entry.pushKV("vout.n", i);
UniValue o(UniValue::VOBJ);
ScriptPubKeyToUniv(s->scriptPubKey, o, true);
entry.pushKV("scriptPubKey", o);
Expand All @@ -180,6 +181,7 @@ void OutputToJSON(uint256 &txid, int i,
CTxOutData *s = (CTxOutData*) baseOut;
entry.pushKV("type", "data");
entry.pushKV("data_hex", HexStr(s->vData.begin(), s->vData.end()));
entry.pushKV("vout.n", i);
CAmount nValue;
if (s->GetCTFee(nValue))
entry.pushKV("ct_fee", ValueFromAmount(nValue));
Expand All @@ -190,6 +192,7 @@ void OutputToJSON(uint256 &txid, int i,
CTxOutCT *s = (CTxOutCT*) baseOut;
entry.pushKV("type", "blind");
entry.pushKV("valueCommitment", HexStr(&s->commitment.data[0], &s->commitment.data[0]+33));
entry.pushKV("vout.n", i);
UniValue o(UniValue::VOBJ);
ScriptPubKeyToUniv(s->scriptPubKey, o, true);
entry.pushKV("scriptPubKey", o);
Expand All @@ -202,6 +205,7 @@ void OutputToJSON(uint256 &txid, int i,
{
CTxOutRingCT *s = (CTxOutRingCT*) baseOut;
entry.pushKV("type", "ringct");
entry.pushKV("vout.n", i);
entry.pushKV("pubkey", HexStr(s->pk.begin(), s->pk.end()));
entry.pushKV("valueCommitment", HexStr(&s->commitment.data[0], &s->commitment.data[0]+33));
entry.pushKV("data_hex", HexStr(s->vData.begin(), s->vData.end()));
Expand Down
54 changes: 28 additions & 26 deletions src/rpc/rawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,22 @@ static UniValue getrawtransaction(const JSONRPCRequest& request)

"\nResult (if verbose is set to true):\n"
"{\n"
" \"in_active_chain\": b, (bool) Whether specified block is in the active chain or not (only present with explicit \"blockhash\" argument)\n"
" \"hex\" : \"data\", (string) The serialized, hex-encoded data for 'txid'\n"
" \"txid\" : \"id\", (string) The transaction id (same as provided)\n"
" \"hash\" : \"id\", (string) The transaction hash (differs from txid for witness transactions)\n"
" \"in_active_chain\": (bool) Whether specified block is in the active chain or not (only present with explicit \"blockhash\" argument)\n"
" \"hex\" : \"data\", (string) The serialized, hex-encoded data for 'txid'\n"
" \"txid\" : \"id\", (string) The transaction id (same as provided)\n"
" \"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"
" {\n"
" \"txid\": \"id\", (string) The transaction id\n"
" \"txid\": \"id\", (string) The transaction id\n"
" \"vout\": n, (numeric) \n"
" \"scriptSig\": { (json object) The script\n"
" \"asm\": \"asm\", (string) asm\n"
" \"hex\": \"hex\" (string) hex\n"
" \"asm\": \"asm\", (string) asm\n"
" \"hex\": \"hex\" (string) hex\n"
" },\n"
" \"sequence\": n (numeric) The script sequence number\n"
" \"txinwitness\": [\"hex\", ...] (array of string) hex-encoded witness data (if any)\n"
Expand All @@ -118,22 +118,23 @@ static UniValue getrawtransaction(const JSONRPCRequest& request)
" ],\n"
" \"vout\" : [ (array of json objects)\n"
" {\n"
" \"value\" : x.xxx, (numeric) The value in " + CURRENCY_UNIT + "\n"
" \"n\" : n, (numeric) index\n"
" \"scriptPubKey\" : { (json object)\n"
" \"value\" : x.xxx, (numeric) The value in " + CURRENCY_UNIT + "\n"
" \"valueSat\" : x.xxx, (numeric) The sat value in " + CURRENCY_UNIT + "\n"
" \"vout.n\" : n, (numeric) index\n"
" \"scriptPubKey\" : { (json object)\n"
" \"asm\" : \"asm\", (string) the asm\n"
" \"hex\" : \"hex\", (string) the hex\n"
" \"reqSigs\" : n, (numeric) The required sigs\n"
" \"reqSigs\" : n, (numeric) The required sigs\n"
" \"type\" : \"pubkeyhash\", (string) The type, eg 'pubkeyhash'\n"
" \"addresses\" : [ (json array of string)\n"
" \"address\" (string) veil address\n"
" \"addresses\" : [ (json array of string)\n"
" \"address\" (string) veil address\n"
" ,...\n"
" ]\n"
" }\n"
" }\n"
" ,...\n"
" ],\n"
" \"blockhash\" : \"hash\", (string) the block hash\n"
" \"blockhash\" : \"hash\", (string) The block hash\n"
" \"confirmations\" : n, (numeric) The confirmations\n"
" \"time\" : ttt, (numeric) The transaction time in seconds since epoch (Jan 1 1970 GMT)\n"
" \"blocktime\" : ttt (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n"
Expand Down Expand Up @@ -519,42 +520,43 @@ static UniValue decoderawtransaction(const JSONRPCRequest& request)
"\nReturn a JSON object representing the serialized, hex-encoded transaction.\n"

"\nArguments:\n"
"1. \"hexstring\" (string, required) The transaction hex string\n"
"1. \"hexstring\" (string, required) The transaction hex string\n"
"2. iswitness (boolean, optional) Whether the transaction hex is a serialized witness transaction\n"
" If iswitness is not present, heuristic tests will be used in decoding\n"

"\nResult:\n"
"{\n"
" \"txid\" : \"id\", (string) The transaction id\n"
" \"hash\" : \"id\", (string) The transaction hash (differs from txid for witness transactions)\n"
" \"txid\" : \"id\", (string) The transaction id\n"
" \"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"
" {\n"
" \"txid\": \"id\", (string) The transaction id\n"
" \"txid\": \"id\", (string) The transaction id\n"
" \"vout\": n, (numeric) The output number\n"
" \"scriptSig\": { (json object) The script\n"
" \"asm\": \"asm\", (string) asm\n"
" \"hex\": \"hex\" (string) hex\n"
" \"asm\": \"asm\", (string) asm\n"
" \"hex\": \"hex\" (string) hex\n"
" },\n"
" \"txinwitness\": [\"hex\", ...] (array of string) hex-encoded witness data (if any)\n"
" \"sequence\": n (numeric) The script sequence number\n"
" \"sequence\": n (numeric) The script sequence number\n"
" }\n"
" ,...\n"
" ],\n"
" \"vout\" : [ (array of json objects)\n"
" {\n"
" \"value\" : x.xxx, (numeric) The value in " + CURRENCY_UNIT + "\n"
" \"n\" : n, (numeric) index\n"
" \"scriptPubKey\" : { (json object)\n"
" \"value\" : x.xxx, (numeric) The value in " + CURRENCY_UNIT + "\n"
" \"valueSat\" : x.xxx, (numeric) The sat value in " + CURRENCY_UNIT + "\n"
" \"vout.n\" : n, (numeric) index\n"
" \"scriptPubKey\" : { (json object)\n"
" \"asm\" : \"asm\", (string) the asm\n"
" \"hex\" : \"hex\", (string) the hex\n"
" \"reqSigs\" : n, (numeric) The required sigs\n"
" \"reqSigs\" : n, (numeric) The required sigs\n"
" \"type\" : \"pubkeyhash\", (string) The type, eg 'pubkeyhash'\n"
" \"addresses\" : [ (json array of string)\n"
" \"addresses\" : [ (json array of string)\n"
" \"12tvKAXCxZjSmdNbao16dKXC8tRWfcF5oc\" (string) veil address\n"
" ,...\n"
" ]\n"
Expand Down

0 comments on commit 08c6a26

Please sign in to comment.