@@ -640,25 +640,22 @@ bool SignTransaction(CMutableTransaction& mtx, const SigningProvider* keystore,
640640
641641 PrecomputedTransactionData txdata;
642642 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) {
646644 CTxIn& txin = mtx.vin [i];
647645 auto coin = coins.find (txin.prevout );
648646 if (coin == coins.end () || coin->second .IsSpent ()) {
649- have_all_spent_outputs = false ;
647+ txdata.Init (txConst, /* spent_outputs */ {}, /* force */ true );
648+ break ;
650649 } 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 );
652651 }
653652 }
654- if (have_all_spent_outputs ) {
653+ if (spent_outputs. size () == mtx. vin . size () ) {
655654 txdata.Init (txConst, std::move (spent_outputs), true );
656- } else {
657- txdata.Init (txConst, {}, true );
658655 }
659656
660657 // 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 ) {
662659 CTxIn& txin = mtx.vin [i];
663660 auto coin = coins.find (txin.prevout );
664661 if (coin == coins.end () || coin->second .IsSpent ()) {
0 commit comments