@ -27,9 +27,6 @@
# include <txmempool.h>
# include <uint256.h>
# include <utilstrencodings.h>
# ifdef ENABLE_WALLET
# include <wallet/rpcwallet.h>
# endif
# include <future>
# include <stdint.h>
@ -824,8 +821,7 @@ UniValue SignTransaction(CMutableTransaction& mtx, const UniValue& prevTxsUnival
view . AddCoin ( out , std : : move ( newcoin ) , true ) ;
}
// if redeemScript given and not using the local wallet (private keys
// given), add redeemScript to the keystore so it can be signed:
// if redeemScript and private keys were given, add redeemScript to the keystore so it can be signed
if ( is_temp_keystore & & ( scriptPubKey . IsPayToScriptHash ( ) | | scriptPubKey . IsPayToWitnessScriptHash ( ) ) ) {
RPCTypeCheckObj ( prevOut ,
{
@ -980,102 +976,10 @@ static UniValue signrawtransactionwithkey(const JSONRPCRequest& request)
UniValue signrawtransaction ( const JSONRPCRequest & request )
{
# ifdef ENABLE_WALLET
std : : shared_ptr < CWallet > const wallet = GetWalletForJSONRPCRequest ( request ) ;
CWallet * const pwallet = wallet . get ( ) ;
# endif
if ( request . fHelp | | request . params . size ( ) < 1 | | request . params . size ( ) > 4 )
throw std : : runtime_error (
" signrawtransaction \" hexstring \" ( [{ \" txid \" : \" id \" , \" vout \" :n, \" scriptPubKey \" : \" hex \" , \" redeemScript \" : \" hex \" },...] [ \" privatekey1 \" ,...] sighashtype ) \n "
" \n DEPRECATED. 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 chain. \n "
" The third optional argument (may be null) is an array of base58-encoded private \n "
" keys that, if given, will be the only keys used to sign the transaction. \n "
# ifdef ENABLE_WALLET
+ HelpRequiringPassphrase ( pwallet ) + " \n "
# endif
" \n Arguments: \n "
" 1. \" hexstring \" (string, required) The transaction hex string \n "
" 2. \" prevtxs \" (string, optional) An json array of previous dependent transaction outputs \n "
" [ (json array of json objects, or 'null' if none provided) \n "
" { \n "
" \" txid \" : \" id \" , (string, required) The transaction id \n "
" \" vout \" :n, (numeric, required) The output number \n "
" \" scriptPubKey \" : \" hex \" , (string, required) script key \n "
" \" redeemScript \" : \" hex \" , (string, required for P2SH or P2WSH) redeem script \n "
" \" amount \" : value (numeric, required) The amount spent \n "
" } \n "
" ,... \n "
" ] \n "
" 3. \" privkeys \" (string, optional) A json array of base58-encoded private keys for signing \n "
" [ (json array of strings, or 'null' if none provided) \n "
" \" privatekey \" (string) private key in base58-encoding \n "
" ,... \n "
" ] \n "
" 4. \" sighashtype \" (string, optional, default=ALL) The signature hash type. Must be one of \n "
" \" ALL \" \n "
" \" NONE \" \n "
" \" SINGLE \" \n "
" \" ALL|ANYONECANPAY \" \n "
" \" NONE|ANYONECANPAY \" \n "
" \" SINGLE|ANYONECANPAY \" \n "
" \n Result: \n "
" { \n "
" \" hex \" : \" value \" , (string) The hex-encoded raw transaction with signature(s) \n "
" \" complete \" : true|false, (boolean) If the transaction has a complete set of signatures \n "
" \" errors \" : [ (json array of objects) Script verification errors (if there are any) \n "
" { \n "
" \" txid \" : \" hash \" , (string) The hash of the referenced, previous transaction \n "
" \" vout \" : n, (numeric) The index of the output to spent and used as input \n "
" \" scriptSig \" : \" hex \" , (string) The hex-encoded signature script \n "
" \" sequence \" : n, (numeric) Script sequence number \n "
" \" error \" : \" text \" (string) Verification or signing error related to the input \n "
" } \n "
" ,... \n "
" ] \n "
" } \n "
" \n Examples: \n "
+ HelpExampleCli ( " signrawtransaction " , " \" myhex \" " )
+ HelpExampleRpc ( " signrawtransaction " , " \" myhex \" " )
) ;
if ( ! IsDeprecatedRPCEnabled ( " signrawtransaction " ) ) {
throw JSONRPCError ( RPC_METHOD_DEPRECATED , " signrawtransaction is deprecated and will be fully removed in v0.18. "
" To use signrawtransaction in v0.17, restart bitcoind with -deprecatedrpc=signrawtransaction. \n "
" Projects should transition to using signrawtransactionwithkey and signrawtransactionwithwallet before upgrading to v0.18 " ) ;
}
RPCTypeCheck ( request . params , { UniValue : : VSTR , UniValue : : VARR , UniValue : : VARR , UniValue : : VSTR } , true ) ;
// Make a JSONRPCRequest to pass on to the right signrawtransaction* command
JSONRPCRequest new_request ;
new_request . id = request . id ;
new_request . params . setArray ( ) ;
// For signing with private keys
if ( ! request . params [ 2 ] . isNull ( ) ) {
new_request . params . push_back ( request . params [ 0 ] ) ;
// Note: the prevtxs and privkeys are reversed for signrawtransactionwithkey
new_request . params . push_back ( request . params [ 2 ] ) ;
new_request . params . push_back ( request . params [ 1 ] ) ;
new_request . params . push_back ( request . params [ 3 ] ) ;
return signrawtransactionwithkey ( new_request ) ;
} else {
# ifdef ENABLE_WALLET
// Otherwise sign with the wallet which does not take a privkeys parameter
new_request . params . push_back ( request . params [ 0 ] ) ;
new_request . params . push_back ( request . params [ 1 ] ) ;
new_request . params . push_back ( request . params [ 3 ] ) ;
return signrawtransactionwithwallet ( new_request ) ;
# else
// If we have made it this far, then wallet is disabled and no private keys were given, so fail here.
throw JSONRPCError ( RPC_INVALID_PARAMETER , " No private keys available. " ) ;
# endif
}
// This method should be removed entirely in V0.19, along with the entries in the
// CRPCCommand table and rpc/client.cpp.
throw JSONRPCError ( RPC_METHOD_DEPRECATED , " signrawtransaction was removed in v0.18. \n "
" Clients should transition to using signrawtransactionwithkey and signrawtransactionwithwallet " ) ;
}
static UniValue sendrawtransaction ( const JSONRPCRequest & request )
@ -1084,7 +988,7 @@ static UniValue sendrawtransaction(const JSONRPCRequest& request)
throw std : : runtime_error (
" sendrawtransaction \" hexstring \" ( allowhighfees ) \n "
" \n Submits raw transaction (serialized, hex-encoded) to local node and network. \n "
" \n Also see createrawtransaction and signrawtransaction calls.\n "
" \n Also see createrawtransaction and signrawtransaction withkey calls.\n "
" \n Arguments: \n "
" 1. \" hexstring \" (string, required) The hex string of the raw transaction) \n "
" 2. allowhighfees (boolean, optional, default=false) Allow high fees \n "
@ -1094,7 +998,7 @@ static UniValue sendrawtransaction(const JSONRPCRequest& request)
" \n Create a transaction \n "
+ HelpExampleCli ( " createrawtransaction " , " \" [{ \\ \" txid \\ \" : \\ \" mytxid \\ \" , \\ \" vout \\ \" :0}] \" \" { \\ \" myaddress \\ \" :0.01} \" " ) +
" Sign the transaction, and get back the hex \n "
+ HelpExampleCli ( " signrawtransaction " , " \" myhex \" " ) +
+ HelpExampleCli ( " signrawtransaction withwallet " , " \" myhex \" " ) +
" \n Send the transaction (signed hex) \n "
+ HelpExampleCli ( " sendrawtransaction " , " \" signedhex \" " ) +
" \n As a json rpc call \n "
@ -1199,7 +1103,7 @@ static UniValue testmempoolaccept(const JSONRPCRequest& request)
" \n Create a transaction \n "
+ HelpExampleCli ( " createrawtransaction " , " \" [{ \\ \" txid \\ \" : \\ \" mytxid \\ \" , \\ \" vout \\ \" :0}] \" \" { \\ \" myaddress \\ \" :0.01} \" " ) +
" Sign the transaction, and get back the hex \n "
+ HelpExampleCli ( " signrawtransaction " , " \" myhex \" " ) +
+ HelpExampleCli ( " signrawtransaction withwallet " , " \" myhex \" " ) +
" \n Test acceptance of the transaction (signed hex) \n "
+ HelpExampleCli ( " testmempoolaccept " , " \" signedhex \" " ) +
" \n As a json rpc call \n "
@ -1800,7 +1704,7 @@ static const CRPCCommand commands[] =
{ " rawtransactions " , " decodescript " , & decodescript , { " hexstring " } } ,
{ " rawtransactions " , " sendrawtransaction " , & sendrawtransaction , { " hexstring " , " allowhighfees " } } ,
{ " rawtransactions " , " combinerawtransaction " , & combinerawtransaction , { " txs " } } ,
{ " rawtransactions" , " signrawtransaction " , & signrawtransaction , { " hexstring " , " prevtxs " , " privkeys " , " sighashtype " } } , /* uses wallet if enabled */
{ " hidden" , " signrawtransaction " , & signrawtransaction , { " hexstring " , " prevtxs " , " privkeys " , " sighashtype " } } ,
{ " rawtransactions " , " signrawtransactionwithkey " , & signrawtransactionwithkey , { " hexstring " , " privkeys " , " prevtxs " , " sighashtype " } } ,
{ " rawtransactions " , " testmempoolaccept " , & testmempoolaccept , { " rawtxs " , " allowhighfees " } } ,
{ " rawtransactions " , " decodepsbt " , & decodepsbt , { " psbt " } } ,