diff options
author | Kiminuo <kiminuo@protonmail.com> | 2021-10-20 08:00:44 +0200 |
---|---|---|
committer | Kiminuo <kiminuo@protonmail.com> | 2021-10-20 10:51:01 +0200 |
commit | 1bdd5f63229ebf28c24a8656f486ed8a6c8b3787 (patch) | |
tree | ab45d770bb969bf2971bef580a0959da3ce8672d | |
parent | 0ccf9b2e5594581deef2f60174c3651a57f93b64 (diff) | |
download | bitcoin-1bdd5f63229ebf28c24a8656f486ed8a6c8b3787.tar.xz |
Address review comments from #22918
* fix English in release notes
* Simplify `switch` to `if`.
-rw-r--r-- | doc/release-notes.md | 2 | ||||
-rw-r--r-- | src/core_write.cpp | 23 | ||||
-rw-r--r-- | src/rpc/blockchain.cpp | 1 |
3 files changed, 11 insertions, 15 deletions
diff --git a/doc/release-notes.md b/doc/release-notes.md index b460cd3eb2..9541aeadca 100644 --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -82,7 +82,7 @@ Updated RPCs `gettransaction verbose=true` and REST endpoints `/rest/tx`, `/rest/getutxos`, `/rest/block` no longer return the `addresses` and `reqSigs` fields, which were previously deprecated in 22.0. (#22650) -- The `getblock` RPC command now supports verbose level 3 containing transaction inputs +- The `getblock` RPC command now supports verbosity level 3 containing transaction inputs' `prevout` information. The existing `/rest/block/` REST endpoint is modified to contain this information too. Every `vin` field will contain an additional `prevout` subfield describing the spent output. `prevout` contains the following keys: diff --git a/src/core_write.cpp b/src/core_write.cpp index 468694b011..3ac7e5030c 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -208,22 +208,17 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, const CTxOut& prev_txout = prev_coin.out; amt_total_in += prev_txout.nValue; - switch (verbosity) { - case TxVerbosity::SHOW_TXID: - case TxVerbosity::SHOW_DETAILS: - break; - case TxVerbosity::SHOW_DETAILS_AND_PREVOUT: - UniValue o_script_pub_key(UniValue::VOBJ); - ScriptPubKeyToUniv(prev_txout.scriptPubKey, o_script_pub_key, /* includeHex */ true); + if (verbosity == TxVerbosity::SHOW_DETAILS_AND_PREVOUT) { + UniValue o_script_pub_key(UniValue::VOBJ); + ScriptPubKeyToUniv(prev_txout.scriptPubKey, o_script_pub_key, /*include_hex=*/ true); - UniValue p(UniValue::VOBJ); - p.pushKV("generated", bool(prev_coin.fCoinBase)); - p.pushKV("height", uint64_t(prev_coin.nHeight)); - p.pushKV("value", ValueFromAmount(prev_txout.nValue)); - p.pushKV("scriptPubKey", o_script_pub_key); - in.pushKV("prevout", p); - break; + UniValue p(UniValue::VOBJ); + p.pushKV("generated", bool(prev_coin.fCoinBase)); + p.pushKV("height", uint64_t(prev_coin.nHeight)); + p.pushKV("value", ValueFromAmount(prev_txout.nValue)); + p.pushKV("scriptPubKey", o_script_pub_key); + in.pushKV("prevout", p); } } in.pushKV("sequence", (int64_t)txin.nSequence); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index dadd82e03f..5001a9e0e0 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -229,6 +229,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIn TxToUniv(*tx, uint256(), objTx, true, RPCSerializationFlags(), txundo, verbosity); txs.push_back(objTx); } + break; } result.pushKV("tx", txs); |