@@ -640,25 +640,22 @@ bool SignTransaction(CMutableTransaction& mtx, const SigningProvider* keystore,
640
640
641
641
PrecomputedTransactionData txdata;
642
642
std::vector<CTxOut> spent_outputs;
643
- spent_outputs.resize (mtx.vin .size ());
644
- bool have_all_spent_outputs = true ;
645
- for (unsigned int i = 0 ; i < mtx.vin .size (); i++) {
643
+ for (unsigned int i = 0 ; i < mtx.vin .size (); ++i) {
646
644
CTxIn& txin = mtx.vin [i];
647
645
auto coin = coins.find (txin.prevout );
648
646
if (coin == coins.end () || coin->second .IsSpent ()) {
649
- have_all_spent_outputs = false ;
647
+ txdata.Init (txConst, /* spent_outputs */ {}, /* force */ true );
648
+ break ;
650
649
} else {
651
- spent_outputs[i] = CTxOut (coin->second .out .nValue , coin->second .out .scriptPubKey );
650
+ spent_outputs. emplace_back (coin->second .out .nValue , coin->second .out .scriptPubKey );
652
651
}
653
652
}
654
- if (have_all_spent_outputs ) {
653
+ if (spent_outputs. size () == mtx. vin . size () ) {
655
654
txdata.Init (txConst, std::move (spent_outputs), true );
656
- } else {
657
- txdata.Init (txConst, {}, true );
658
655
}
659
656
660
657
// Sign what we can:
661
- for (unsigned int i = 0 ; i < mtx.vin .size (); i++ ) {
658
+ for (unsigned int i = 0 ; i < mtx.vin .size (); ++i ) {
662
659
CTxIn& txin = mtx.vin [i];
663
660
auto coin = coins.find (txin.prevout );
664
661
if (coin == coins.end () || coin->second .IsSpent ()) {
0 commit comments