Assuming wallet RPCs and node RPCs will go into different processes, signrawtransactionwithkey doesn’t need to access Coins via interfaces::Chain, it may use directly utility in node/coins.cpp
Obviously will need rebase after #15638
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
4@@ -5,6 +5,11 @@
5 #ifndef BITCOIN_RPC_RAWTRANSACTION_UTIL_H
6 #define BITCOIN_RPC_RAWTRANSACTION_UTIL_H
7
8+#include <coins.h>
You should just be able to forward declare the Coin
object and leave this include in the .cpp file if you change the coins argument into a reference.
(thanks to @ryanofsky for answering my question about this)
148@@ -149,18 +149,8 @@ static void TxInErrorToJSON(const CTxIn& txin, UniValue& vErrorsRet, const std::
149 vErrorsRet.push_back(entry);
150 }
151
152-// TODO(https://github.com/bitcoin/bitcoin/pull/10973#discussion_r267084237):
153-// The dependency on interfaces::Chain should be removed, so
154-// signrawtransactionwithkey doesn't need access to a Chain instance.
155-UniValue SignTransaction(interfaces::Chain& chain, CMutableTransaction& mtx, const UniValue& prevTxsUnival, CBasicKeyStore *keystore, bool is_temp_keystore, const UniValue& hashType)
156+UniValue SignTransaction(CMutableTransaction& mtx, const UniValue& prevTxsUnival, CBasicKeyStore* keystore, std::map<COutPoint, Coin> coins, bool is_temp_keystore, const UniValue& hashType)
coins[out] = std::move(newcoin)
L198 ?
const
coins
is modified after the call.
16@@ -17,6 +17,7 @@
17 #include <merkleblock.h>
18 #include <node/psbt.h>
19 #include <node/transaction.h>
20+#include <node/coin.h>
26+ * @param prevTxs Array of previous txns outputs that tx depends on but may not yet be in the block chain
27+ * @param keystore Temporary keystore containing signing keys
28+ * @param coins Map of unspent outputs - coins in mempool and current chain UTXO set, may be extended by previous txns outputs after call
29+ * @param tempKeystore Whether to use temporary keystore
30+ * @param hashType The signature hash type
31+ * return signed tx
@returns JSON object with details of the signed transaction
or something along that.
11 class UniValue;
12 struct CMutableTransaction;
13+class Coin;
14+class COutPoint;
15
16 namespace interfaces {
interfaces::Chain
class.
interfaces::Chain
forward declaration.
Comment SignTransaction utility
4@@ -5,16 +5,26 @@
5 #ifndef BITCOIN_RPC_RAWTRANSACTION_UTIL_H
6 #define BITCOIN_RPC_RAWTRANSACTION_UTIL_H
7
8+#include <map>
9+
10 class CBasicKeyStore;
11 class UniValue;
12 struct CMutableTransaction;
13+class Coin;
!sort
in vim)