aboutsummaryrefslogtreecommitdiff
path: root/src/bitcoin-tx.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2018-04-13 16:50:48 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2018-04-13 17:15:15 +0200
commite625548e7cae119ce555783a7a546f0039fc431b (patch)
tree65be40307d293d182a014ded039a39e3cc0ae8b1 /src/bitcoin-tx.cpp
parent94deb093499ca72154b794b3005d5cdaa6d97de9 (diff)
parentfa72f34c644da681bd55ebb8097a32fe5ce35510 (diff)
Merge #12950: bitcoin-tx: Flatten for loop over one element
fa72f34 bitcoin-tx: Remove unused for loop (MarcoFalke) Pull request description: This flattens out a for loop and gets rid of the then unused vector `txVariants`. Tree-SHA512: 68081b313d846ce235a97a642c9d0097c3641350e819d6254001f332b053e41fa63ce49faca68120f5aaf5d5f4bfda104662eae781e2956d76a8915770344045
Diffstat (limited to 'src/bitcoin-tx.cpp')
-rw-r--r--src/bitcoin-tx.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp
index eb41e9a416..07ad09ea7b 100644
--- a/src/bitcoin-tx.cpp
+++ b/src/bitcoin-tx.cpp
@@ -545,12 +545,10 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
if (!findSighashFlags(nHashType, flagStr))
throw std::runtime_error("unknown sighash flag/sign option");
- std::vector<CTransaction> txVariants;
- txVariants.push_back(tx);
-
// mergedTx will end up with all the signatures; it
// starts as a clone of the raw tx:
- CMutableTransaction mergedTx(txVariants[0]);
+ CMutableTransaction mergedTx{tx};
+ const CTransaction txv{tx};
CCoinsView viewDummy;
CCoinsViewCache view(&viewDummy);
@@ -633,7 +631,7 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
// Sign what we can:
for (unsigned int i = 0; i < mergedTx.vin.size(); i++) {
- CTxIn& txin = mergedTx.vin[i];
+ const CTxIn& txin = mergedTx.vin[i];
const Coin& coin = view.AccessCoin(txin.prevout);
if (coin.IsSpent()) {
continue;
@@ -647,8 +645,7 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
ProduceSignature(keystore, MutableTransactionSignatureCreator(&mergedTx, i, amount, nHashType), prevPubKey, sigdata);
// ... and merge in other signatures:
- for (const CTransaction& txv : txVariants)
- sigdata = CombineSignatures(prevPubKey, MutableTransactionSignatureChecker(&mergedTx, i, amount), sigdata, DataFromTransaction(txv, i));
+ sigdata = CombineSignatures(prevPubKey, MutableTransactionSignatureChecker(&mergedTx, i, amount), sigdata, DataFromTransaction(txv, i));
UpdateTransaction(mergedTx, i, sigdata);
}