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
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
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)
Just forward declaration seems to do the job without gcc complaints
Thanks. You should pass by reference anyway, otherwise this will make a copy of the entire map.
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)
Updated to pass-by-reference but I think can't be const due to coins[out] = std::move(newcoin) L198 ?
I think you're right that it can't be const
Then I think it should not pass by reference or you could comment that coins is modified after the call.
Got this on travis failure : "Please manually re-run this job by using the travis restart button or asking a bitcoin maintainer to restart. The next run should not time out because the build cache has been saved."
16 | @@ -17,6 +17,7 @@ 17 | #include <merkleblock.h> 18 | #include <node/psbt.h> 19 | #include <node/transaction.h> 20 | +#include <node/coin.h>
nit, could sorted.
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 {
Remove.
Seems I need to forward declare both Coin and COutPoint objects there ?
I mean you can remove the interfaces namespace.
promag is saying you can remove the forward declaration of the interfaces::Chain class.
utACK c98aeb00c9eaeb12623dc8f6a644ee5f0044f3fa one you've removed that unnecessary interfaces::Chain forward declaration.
Comment SignTransaction utility
99e88a3 removed unnecessary interfaces::Chain forward declaration
utACK 99e88a3726c2325e3a3a35c0a750bde25bd58ad0
utACK 99e88a3.
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;
Could sort these between CBasicKeyStore and UniValue above (I normally just pipe these lines to !sort in vim)
utACK 99e88a3726c2325e3a3a35c0a750bde25bd58ad0