aboutsummaryrefslogtreecommitdiff
path: root/src/script/sign.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2021-06-17 17:25:07 -0700
committerPieter Wuille <pieter@wuille.net>2021-08-20 14:29:23 -0400
commitc7048aae9545afd8d522e200ecadcf69f22399a0 (patch)
treea8f12594d62f7b4eda6d96c8be56b99e5c519394 /src/script/sign.cpp
parentaddb9b5a71ff96bdb1a4c15bc9345de0d7f2c98c (diff)
Simplify SignTransaction precomputation loop
Diffstat (limited to 'src/script/sign.cpp')
-rw-r--r--src/script/sign.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/script/sign.cpp b/src/script/sign.cpp
index 2a1c99e387..4714d0ef11 100644
--- a/src/script/sign.cpp
+++ b/src/script/sign.cpp
@@ -640,25 +640,22 @@ bool SignTransaction(CMutableTransaction& mtx, const SigningProvider* keystore,
PrecomputedTransactionData txdata;
std::vector<CTxOut> spent_outputs;
- spent_outputs.resize(mtx.vin.size());
- bool have_all_spent_outputs = true;
- for (unsigned int i = 0; i < mtx.vin.size(); i++) {
+ for (unsigned int i = 0; i < mtx.vin.size(); ++i) {
CTxIn& txin = mtx.vin[i];
auto coin = coins.find(txin.prevout);
if (coin == coins.end() || coin->second.IsSpent()) {
- have_all_spent_outputs = false;
+ txdata.Init(txConst, /* spent_outputs */ {}, /* force */ true);
+ break;
} else {
- spent_outputs[i] = CTxOut(coin->second.out.nValue, coin->second.out.scriptPubKey);
+ spent_outputs.emplace_back(coin->second.out.nValue, coin->second.out.scriptPubKey);
}
}
- if (have_all_spent_outputs) {
+ if (spent_outputs.size() == mtx.vin.size()) {
txdata.Init(txConst, std::move(spent_outputs), true);
- } else {
- txdata.Init(txConst, {}, true);
}
// Sign what we can:
- for (unsigned int i = 0; i < mtx.vin.size(); i++) {
+ for (unsigned int i = 0; i < mtx.vin.size(); ++i) {
CTxIn& txin = mtx.vin[i];
auto coin = coins.find(txin.prevout);
if (coin == coins.end() || coin->second.IsSpent()) {