mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
refactor TxToJSON() and ScriptPubKeyToJSON()
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "chain.h"
|
||||
#include "chainparams.h"
|
||||
#include "core_io.h"
|
||||
#include "primitives/block.h"
|
||||
#include "primitives/transaction.h"
|
||||
#include "validation.h"
|
||||
@@ -56,10 +57,6 @@ struct CCoin {
|
||||
}
|
||||
};
|
||||
|
||||
/* Defined in rawtransaction.cpp */
|
||||
void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry);
|
||||
void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex);
|
||||
|
||||
static bool RESTERR(HTTPRequest* req, enum HTTPStatusCode status, std::string message)
|
||||
{
|
||||
req->WriteHeader("Content-Type", "text/plain");
|
||||
@@ -383,7 +380,7 @@ static bool rest_tx(HTTPRequest* req, const std::string& strURIPart)
|
||||
|
||||
case RF_JSON: {
|
||||
UniValue objTx(UniValue::VOBJ);
|
||||
TxToJSON(*tx, hashBlock, objTx);
|
||||
TxToUniv(*tx, hashBlock, objTx);
|
||||
std::string strJSON = objTx.write() + "\n";
|
||||
req->WriteHeader("Content-Type", "application/json");
|
||||
req->WriteReply(HTTP_OK, strJSON);
|
||||
@@ -577,7 +574,7 @@ static bool rest_getutxos(HTTPRequest* req, const std::string& strURIPart)
|
||||
|
||||
// include the script in a json output
|
||||
UniValue o(UniValue::VOBJ);
|
||||
ScriptPubKeyToJSON(coin.out.scriptPubKey, o, true);
|
||||
ScriptPubKeyToUniv(coin.out.scriptPubKey, o, true);
|
||||
utxo.push_back(Pair("scriptPubKey", o));
|
||||
utxos.push_back(utxo);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user