mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
RPC: Do all wallet access through new GetWalletForJSONRPCRequest
This commit is contained in:
@@ -594,6 +594,10 @@ static void TxInErrorToJSON(const CTxIn& txin, UniValue& vErrorsRet, const std::
|
||||
|
||||
UniValue signrawtransaction(const JSONRPCRequest& request)
|
||||
{
|
||||
#ifdef ENABLE_WALLET
|
||||
CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
|
||||
#endif
|
||||
|
||||
if (request.fHelp || request.params.size() < 1 || request.params.size() > 4)
|
||||
throw runtime_error(
|
||||
"signrawtransaction \"hexstring\" ( [{\"txid\":\"id\",\"vout\":n,\"scriptPubKey\":\"hex\",\"redeemScript\":\"hex\"},...] [\"privatekey1\",...] sighashtype )\n"
|
||||
@@ -603,7 +607,7 @@ UniValue signrawtransaction(const JSONRPCRequest& request)
|
||||
"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(pwalletMain) + "\n"
|
||||
+ HelpRequiringPassphrase(pwallet) + "\n"
|
||||
#endif
|
||||
|
||||
"\nArguments:\n"
|
||||
@@ -654,7 +658,7 @@ UniValue signrawtransaction(const JSONRPCRequest& request)
|
||||
);
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL);
|
||||
LOCK2(cs_main, pwallet ? &pwallet->cs_wallet : NULL);
|
||||
#else
|
||||
LOCK(cs_main);
|
||||
#endif
|
||||
@@ -717,8 +721,8 @@ UniValue signrawtransaction(const JSONRPCRequest& request)
|
||||
}
|
||||
}
|
||||
#ifdef ENABLE_WALLET
|
||||
else if (pwalletMain)
|
||||
EnsureWalletIsUnlocked(pwalletMain);
|
||||
else if (pwallet)
|
||||
EnsureWalletIsUnlocked(pwallet);
|
||||
#endif
|
||||
|
||||
// Add previous txouts given in the RPC call:
|
||||
@@ -785,7 +789,7 @@ UniValue signrawtransaction(const JSONRPCRequest& request)
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
const CKeyStore& keystore = ((fGivenKeys || !pwalletMain) ? tempKeystore : *pwalletMain);
|
||||
const CKeyStore& keystore = ((fGivenKeys || !pwallet) ? tempKeystore : *pwallet);
|
||||
#else
|
||||
const CKeyStore& keystore = tempKeystore;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user