@@ -52,9 +52,7 @@ int CalculateMaximumSignedInputSize(const CTxOut& txout, const CWallet* wallet,
5252TxSize CalculateMaximumSignedTxSize (const CTransaction &tx, const CWallet *wallet, const std::vector<CTxOut>& txouts, const CCoinControl* coin_control)
5353{
5454 CMutableTransaction txNew (tx);
55- if (!wallet->DummySignTx (txNew, txouts, coin_control)) {
56- return TxSize{-1 , -1 };
57- }
55+ if (!wallet->DummySignTx (txNew, txouts, coin_control)) return TxSize{-1 , -1 };
5856 CTransaction ctx (txNew);
5957 int64_t vsize = GetVirtualTransactionSize (ctx);
6058 int64_t weight = GetTransactionWeight (ctx);
@@ -72,11 +70,9 @@ TxSize CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *walle
7270 assert (input.prevout .n < mi->second .tx ->vout .size ());
7371 txouts.emplace_back (mi->second .tx ->vout .at (input.prevout .n ));
7472 } else if (coin_control) {
75- CTxOut txout;
76- if (!coin_control->GetExternalOutput (input.prevout , txout)) {
77- return TxSize{-1 , -1 };
78- }
79- txouts.emplace_back (txout);
73+ const auto & txout{coin_control->GetExternalOutput (input.prevout )};
74+ if (!txout) return TxSize{-1 , -1 };
75+ txouts.emplace_back (*txout);
8076 } else {
8177 return TxSize{-1 , -1 };
8278 }
@@ -178,9 +174,12 @@ util::Result<PreSelectedInputs> FetchSelectedInputs(const CWallet& wallet, const
178174 input_bytes = CalculateMaximumSignedInputSize (txout, &wallet, &coin_control);
179175 } else {
180176 // The input is external. We did not find the tx in mapWallet.
181- if (!coin_control.GetExternalOutput (outpoint, txout)) {
177+ const auto out{coin_control.GetExternalOutput (outpoint)};
178+ if (!out) {
182179 return util::Error{strprintf (_ (" Not found pre-selected input %s" ), outpoint.ToString ())};
183180 }
181+
182+ txout = *out;
184183 }
185184
186185 if (input_bytes == -1 ) {
0 commit comments