Skip to content

Commit 2456a83

Browse files
author
MarcoFalke
committed
Merge #9520: Deprecate non-txindex getrawtransaction and better warning
db904db Deprecate non-txindex getrawtransaction and better warning (Pieter Wuille)
2 parents 9ec1330 + db904db commit 2456a83

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/rpc/rawtransaction.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,11 @@ UniValue getrawtransaction(const JSONRPCRequest& request)
128128
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
129129
throw runtime_error(
130130
"getrawtransaction \"txid\" ( verbose )\n"
131-
"\nNOTE: By default this function only works sometimes. This is when the tx is in the mempool\n"
132-
"or there is an unspent output in the utxo for this transaction. To make it always work,\n"
133-
"you need to maintain a transaction index, using the -txindex command line option.\n"
131+
132+
"\nNOTE: By default this function only works for mempool transactions. If the -txindex option is\n"
133+
"enabled, it also works for blockchain transactions.\n"
134+
"DEPRECATED: for now, it also works for transactions with unspent outputs.\n"
135+
134136
"\nReturn the raw transaction data.\n"
135137
"\nIf verbose is 'true', returns an Object with information about 'txid'.\n"
136138
"If verbose is 'false' or omitted, returns a string that is serialized, hex-encoded data for 'txid'.\n"
@@ -218,7 +220,9 @@ UniValue getrawtransaction(const JSONRPCRequest& request)
218220
CTransactionRef tx;
219221
uint256 hashBlock;
220222
if (!GetTransaction(hash, tx, Params().GetConsensus(), hashBlock, true))
221-
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available about transaction");
223+
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string(fTxIndex ? "No such mempool or blockchain transaction"
224+
: "No such mempool transaction. Use -txindex to enable blockchain transaction queries") +
225+
". Use gettransaction for wallet transactions.");
222226

223227
string strHex = EncodeHexTx(*tx, RPCSerializationFlags());
224228

0 commit comments

Comments
 (0)