diff options
author | Russell Yanofsky <russ@yanofsky.org> | 2017-05-30 15:55:17 -0400 |
---|---|---|
committer | Russell Yanofsky <russ@yanofsky.org> | 2018-11-06 11:44:40 -0400 |
commit | 8db11dd0b182a93042899651545cc21b34bf0742 (patch) | |
tree | 8165f7a88f2f56cca4d152c5e4fc0d2e5743bc54 /src/rpc | |
parent | 7e2e62cf7c513bd7d8e784069c5534fda1c50c52 (diff) | |
download | bitcoin-8db11dd0b182a93042899651545cc21b34bf0742.tar.xz |
Pass chain and client variables where needed
This commit does not change behavior. All it does is pass new function
parameters.
It is easiest to review this change with:
git log -p -n1 -U0 --word-diff-regex=.
Diffstat (limited to 'src/rpc')
-rw-r--r-- | src/rpc/rawtransaction.cpp | 6 | ||||
-rw-r--r-- | src/rpc/rawtransaction.h | 6 | ||||
-rw-r--r-- | src/rpc/util.cpp | 2 | ||||
-rw-r--r-- | src/rpc/util.h | 6 |
4 files changed, 17 insertions, 3 deletions
diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 0f87646b08..fa886f6570 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -9,6 +9,7 @@ #include <consensus/validation.h> #include <core_io.h> #include <index/txindex.h> +#include <init.h> #include <keystore.h> #include <validation.h> #include <validationinterface.h> @@ -20,6 +21,7 @@ #include <primitives/transaction.h> #include <rpc/rawtransaction.h> #include <rpc/server.h> +#include <rpc/util.h> #include <script/script.h> #include <script/script_error.h> #include <script/sign.h> @@ -754,7 +756,7 @@ static UniValue combinerawtransaction(const JSONRPCRequest& request) return EncodeHexTx(mergedTx); } -UniValue SignTransaction(CMutableTransaction& mtx, const UniValue& prevTxsUnival, CBasicKeyStore *keystore, bool is_temp_keystore, const UniValue& hashType) +UniValue SignTransaction(interfaces::Chain& chain, CMutableTransaction& mtx, const UniValue& prevTxsUnival, CBasicKeyStore *keystore, bool is_temp_keystore, const UniValue& hashType) { // Fetch previous transactions (inputs): CCoinsView viewDummy; @@ -969,7 +971,7 @@ static UniValue signrawtransactionwithkey(const JSONRPCRequest& request) keystore.AddKey(key); } - return SignTransaction(mtx, request.params[2], &keystore, true, request.params[3]); + return SignTransaction(*g_rpc_interfaces->chain, mtx, request.params[2], &keystore, true, request.params[3]); } UniValue signrawtransaction(const JSONRPCRequest& request) diff --git a/src/rpc/rawtransaction.h b/src/rpc/rawtransaction.h index 924611ed5a..52d701d1c3 100644 --- a/src/rpc/rawtransaction.h +++ b/src/rpc/rawtransaction.h @@ -9,8 +9,12 @@ class CBasicKeyStore; struct CMutableTransaction; class UniValue; +namespace interfaces { +class Chain; +} // namespace interfaces + /** Sign a transaction with the given keystore and previous transactions */ -UniValue SignTransaction(CMutableTransaction& mtx, const UniValue& prevTxs, CBasicKeyStore *keystore, bool tempKeystore, const UniValue& hashType); +UniValue SignTransaction(interfaces::Chain& chain, CMutableTransaction& mtx, const UniValue& prevTxs, CBasicKeyStore *keystore, bool tempKeystore, const UniValue& hashType); /** Create a transaction from univalue parameters */ CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, const UniValue& rbf); diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index 8a66191a6a..ef2d14b90e 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -9,6 +9,8 @@ #include <tinyformat.h> #include <util/strencodings.h> +InitInterfaces* g_rpc_interfaces = nullptr; + // Converts a hex string to a public key if possible CPubKey HexToPubKey(const std::string& hex_in) { diff --git a/src/rpc/util.h b/src/rpc/util.h index 0a3a156e45..e21b5ba22a 100644 --- a/src/rpc/util.h +++ b/src/rpc/util.h @@ -17,6 +17,12 @@ class CKeyStore; class CPubKey; class CScript; +struct InitInterfaces; + +//! Pointers to interfaces that need to be accessible from RPC methods. Due to +//! limitations of the RPC framework, there's currently no direct way to pass in +//! state to RPC method implementations. +extern InitInterfaces* g_rpc_interfaces; CPubKey HexToPubKey(const std::string& hex_in); CPubKey AddrToPubKey(CKeyStore* const keystore, const std::string& addr_in); |