From a321e6195fcfb5a3551a1c870b0902d976113ddf Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Thu, 7 Sep 2017 01:22:01 +0200 Subject: [PATCH] Merge #11259: Remove duplicate destination decoding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 86e6dd4b6 Remove duplicate destination decoding (João Barbosa) 8d0041e60 Remove unused GetKeyID and IsScript methods from CBitcoinAddress (João Barbosa) Pull request description: Follow up of #11117, this patch removes an extra unnecessary destination decoding that was identified while reviewing #11117. It is also the only case where `IsValidDestinationString` is called before `DecodeDestination`. For reference see [comment](https://github.com/bitcoin/bitcoin/pull/11117#discussion_r137145517). Tree-SHA512: f5ff5cb28a576ccd819a058f102188bde55654f30618520cc680c91d2f6e536fe038fc7220dd2d2dd64c6175fcb23f89b94b48444521e11ddec0b2f8ef2c05dd --- src/base58.cpp | 11 ----------- src/qt/transactiondesc.cpp | 4 ++-- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/base58.cpp b/src/base58.cpp index d7534cfcddba4..5db8e807a3b7c 100644 --- a/src/base58.cpp +++ b/src/base58.cpp @@ -232,7 +232,6 @@ class CBitcoinAddress : public CBase58Data { CBitcoinAddress(const char* pszAddress) { SetString(pszAddress); } CTxDestination Get() const; - bool GetKeyID(CKeyID &keyID) const; }; class CBitcoinAddressVisitor : public boost::static_visitor @@ -294,16 +293,6 @@ CTxDestination CBitcoinAddress::Get() const return CNoDestination(); } -bool CBitcoinAddress::GetKeyID(CKeyID& keyID) const -{ - if (!IsValid() || vchVersion != Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS)) - return false; - uint160 id; - memcpy(&id, vchData.data(), 20); - keyID = CKeyID(id); - return true; -} - void CBitcoinSecret::SetKey(const CKey& vchSecret) { assert(vchSecret.IsValid()); diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index 032063021fdda..9134b1d8015a6 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -107,8 +107,8 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco if (nNet > 0) { // Credit - if (IsValidDestinationString(rec->strAddress)) { - CTxDestination address = rec->txDest; + CTxDestination address = DecodeDestination(rec->strAddress); + if (IsValidDestination(address)) { if (wallet->mapAddressBook.count(address)) { strHTML += "" + tr("From") + ": " + tr("unknown") + "
";