diff --git a/doc/release-notes.md b/doc/release-notes.md --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -17,4 +17,7 @@ `account` fields. - Add the `-finalizationdelay` to configure the minimum amount of time to wait between a block header reception and the block finalization. Unit is seconds, - default is 7200 (2h). \ No newline at end of file + default is 7200 (2h). + - `signrawtransaction` RPC is now deprecated. The new RPCs + `signrawtransactionwithkey` and `signrawtransactionwithwallet` should + be used instead. \ No newline at end of file diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -1155,7 +1155,8 @@ "[{\"txid\":\"id\",\"vout\":n,\"scriptPubKey\":\"hex\"," "\"redeemScript\":\"hex\"},...] [\"privatekey1\",...] sighashtype " ")\n" - "\nSign inputs for raw transaction (serialized, hex-encoded).\n" + "\nDEPRECATED.Sign inputs for raw transaction (serialized, " + "hex-encoded).\n" "The second optional argument (may be null) is an array of " "previous transaction outputs that\n" "this transaction depends on but may not yet be in the block " @@ -1240,6 +1241,17 @@ HelpExampleRpc("signrawtransaction", "\"myhex\"")); } + if (!IsDeprecatedRPCEnabled(gArgs, "signrawtransaction")) { + throw JSONRPCError( + RPC_METHOD_DEPRECATED, + "signrawtransaction is deprecated and will be fully removed in " + "v0.20. " + "To use signrawtransaction in v0.19, restart bitcoind with " + "-deprecatedrpc=signrawtransaction.\n" + "Projects should transition to using signrawtransactionwithkey and " + "signrawtransactionwithwallet before upgrading to v0.20"); + } + RPCTypeCheck( request.params, {UniValue::VSTR, UniValue::VARR, UniValue::VARR, UniValue::VSTR}, true); diff --git a/test/functional/signrawtransactions.py b/test/functional/signrawtransactions.py --- a/test/functional/signrawtransactions.py +++ b/test/functional/signrawtransactions.py @@ -12,6 +12,7 @@ def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 1 + self.extra_args = [["-deprecatedrpc=signrawtransaction"]] def successful_signing_test(self): """Creates and signs a valid raw transaction with one input. @@ -40,12 +41,16 @@ rawTx, privKeys, inputs) # 1) The transaction has a complete set of signatures - assert 'complete' in rawTxSigned - assert_equal(rawTxSigned['complete'], True) + assert rawTxSigned['complete'] # 2) No script verification error occurred assert 'errors' not in rawTxSigned + # Perform the same test on signrawtransaction + rawTxSigned2 = self.nodes[0].signrawtransaction( + rawTx, inputs, privKeys) + assert_equal(rawTxSigned, rawTxSigned2) + def script_verification_error_test(self): """Creates and signs a raw transaction with valid (vin 0), invalid (vin 1) and one missing (vin 2) input script. @@ -98,8 +103,7 @@ rawTx, privKeys, scripts) # 3) The transaction has no complete set of signatures - assert 'complete' in rawTxSigned - assert_equal(rawTxSigned['complete'], False) + assert not rawTxSigned['complete'] # 4) Two script verification errors occurred assert 'errors' in rawTxSigned @@ -119,6 +123,11 @@ assert_equal(rawTxSigned['errors'][1]['txid'], inputs[2]['txid']) assert_equal(rawTxSigned['errors'][1]['vout'], inputs[2]['vout']) + # Perform same test with signrawtransaction + rawTxSigned2 = self.nodes[0].signrawtransaction( + rawTx, scripts, privKeys) + assert_equal(rawTxSigned, rawTxSigned2) + def run_test(self): self.successful_signing_test() self.script_verification_error_test()