You don’t actually need a template here; all existing uses of TransactionSignatureCreator
become more efficient to rewrite using MutableTransactionSignatureCreator
(intuitively this makes sense - you can’t add a signature to an immutable transaction):
0diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
1index 2a2f8b5b20..c2b1915b11 100644
2--- a/src/wallet/wallet.cpp
3+++ b/src/wallet/wallet.cpp
4@@ -2608,7 +2608,6 @@ bool CWallet::SignTransaction(CMutableTransaction &tx)
5 AssertLockHeld(cs_wallet); // mapWallet
6
7 // sign the new tx
8- CTransaction txNewConst(tx);
9 int nIn = 0;
10 for (const auto& input : tx.vin) {
11 std::map<uint256, CWalletTx>::const_iterator mi = mapWallet.find(input.prevout.hash);
12@@ -2618,7 +2617,7 @@ bool CWallet::SignTransaction(CMutableTransaction &tx)
13 const CScript& scriptPubKey = mi->second.tx->vout[input.prevout.n].scriptPubKey;
14 const CAmount& amount = mi->second.tx->vout[input.prevout.n].nValue;
15 SignatureData sigdata;
16- if (!ProduceSignature(*this, TransactionSignatureCreator(&txNewConst, nIn, amount, SIGHASH_ALL), scriptPubKey, sigdata)) {
17+ if (!ProduceSignature(*this, MutableTransactionSignatureCreator(&tx, nIn, amount, SIGHASH_ALL), scriptPubKey, sigdata)) {
18 return false;
19 }
20 UpdateTransaction(tx, nIn, sigdata);
21@@ -3040,14 +3039,13 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
22
23 if (sign)
24 {
25- CTransaction txNewConst(txNew);
26 int nIn = 0;
27 for (const auto& coin : selected_coins)
28 {
29 const CScript& scriptPubKey = coin.txout.scriptPubKey;
30 SignatureData sigdata;
31
32- if (!ProduceSignature(*this, TransactionSignatureCreator(&txNewConst, nIn, coin.txout.nValue, SIGHASH_ALL), scriptPubKey, sigdata))
33+ if (!ProduceSignature(*this, MutableTransactionSignatureCreator(&txNew, nIn, coin.txout.nValue, SIGHASH_ALL), scriptPubKey, sigdata))
34 {
35 strFailReason = _("Signing transaction failed");
36 return false;