From d54e7c819733e8da9c6c4cd93de2d15666d0aa55 Mon Sep 17 00:00:00 2001 From: Samuel Dobson Date: Sat, 23 Nov 2019 09:33:31 +1300 Subject: [PATCH] Merge #17553: wallet: Remove out of date comments for CalculateMaximumSignedTxSize 6a2e6b0600077e5903400dc74bc8b0c26592fde6 Remove out of date comments for CalculateMaximumSignedTxSize (Gregory Sanders) Pull request description: These paths can be hit for probably a number of reasons, and ISMINE spendability is not a requirement to call it. For example: During watch-only transaction creation, previous transaction in wallet, pubkey imported, but not the witnessscript associated with the prevout. In this case I think no/minimal comment is better than specific and soon to be out of date. ACKs for top commit: achow101: ACK 6a2e6b0600077e5903400dc74bc8b0c26592fde6 darosior: ACK 6a2e6b0600077e5903400dc74bc8b0c26592fde6 Tree-SHA512: ad4c26fd2409eb5aed19d67c19cb5479d226bd11e9298630309c4344f6562ace2e10c2850ebe22770331d71e91320a606e79619b9fe52dd478ce1f589a740122 --- src/wallet/wallet.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 88f1337312..eff3b412be 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1999,11 +1999,9 @@ bool CWallet::DummySignTx(CMutableTransaction &txNew, const std::vector int64_t CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, bool use_max_sig) { std::vector txouts; - // Look up the inputs. We should have already checked that this transaction - // IsAllFromMe(ISMINE_SPENDABLE), so every input should already be in our - // wallet, with a valid index into the vout array, and the ability to sign. for (const CTxIn& input : tx.vin) { const auto mi = wallet->mapWallet.find(input.prevout.hash); + // Can not estimate size without knowing the input details if (mi == wallet->mapWallet.end()) { return -1; } @@ -2018,8 +2016,6 @@ int64_t CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wall { CMutableTransaction txNew(tx); if (!wallet->DummySignTx(txNew, txouts, use_max_sig)) { - // This should never happen, because IsAllFromMe(ISMINE_SPENDABLE) - // implies that we can sign for every input. return -1; } return ::GetSerializeSize(txNew, SER_NETWORK, PROTOCOL_VERSION);