Skip to content

Commit

Permalink
Remove duplicate destination decoding
Browse files Browse the repository at this point in the history
Summary:
Port of bitcoin/bitcoin#11259

Depends on D540

Test Plan: None

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Subscribers: deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D541
  • Loading branch information
promag authored and dagurval committed Sep 27, 2017
1 parent 01fccce commit 3648e1b
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 27 deletions.
18 changes: 0 additions & 18 deletions src/base58.cpp
Expand Up @@ -231,8 +231,6 @@ class CBitcoinAddress : public CBase58Data {
CBitcoinAddress(const char *pszAddress) { SetString(pszAddress); }

CTxDestination Get() const;
bool GetKeyID(CKeyID &keyID) const;
bool IsScript() const;
};

class CBitcoinAddressVisitor : public boost::static_visitor<bool> {
Expand Down Expand Up @@ -289,22 +287,6 @@ CTxDestination CBitcoinAddress::Get() const {
}
}

bool CBitcoinAddress::GetKeyID(CKeyID &keyID) const {
if (!IsValid() ||
vchVersion != Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS)) {
return false;
}
uint160 id;
memcpy(&id, &vchData[0], 20);
keyID = CKeyID(id);
return true;
}

bool CBitcoinAddress::IsScript() const {
return IsValid() &&
vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS);
}

void CBitcoinSecret::SetKey(const CKey &vchSecret) {
assert(vchSecret.IsValid());
SetData(Params().Base58Prefix(CChainParams::SECRET_KEY), vchSecret.begin(),
Expand Down
3 changes: 1 addition & 2 deletions src/qt/addresstablemodel.cpp
Expand Up @@ -230,8 +230,7 @@ bool AddressTableModel::setData(const QModelIndex &index, const QVariant &value,
editStatus = OK;

if (role == Qt::EditRole) {
/* For SetAddressBook / DelAddressBook */
LOCK(wallet->cs_wallet);
LOCK(wallet->cs_wallet); /* For SetAddressBook / DelAddressBook */
CTxDestination curAddress =
DecodeDestination(rec->address.toStdString());
if (index.column() == Label) {
Expand Down
3 changes: 1 addition & 2 deletions src/qt/coincontroldialog.cpp
Expand Up @@ -746,9 +746,8 @@ void CoinControlDialog::updateView() {

// if listMode or change => show bitcoin address. In tree mode,
// address is not shown again for direct wallet address outputs
if (!treeMode || (!(sAddress == sWalletAddress))) {
if (!treeMode || (!(sAddress == sWalletAddress)))
itemOutput->setText(COLUMN_ADDRESS, sAddress);
}
}

// label
Expand Down
2 changes: 1 addition & 1 deletion src/qt/guiutil.cpp
Expand Up @@ -119,7 +119,7 @@ static const uint8_t dummydata[] = {

// Generate a dummy address with invalid CRC, starting with the network prefix.
static std::string DummyAddress(const CChainParams &params) {
std::vector<uint8_t> sourcedata =
std::vector<unsigned char> sourcedata =
params.Base58Prefix(CChainParams::PUBKEY_ADDRESS);
sourcedata.insert(sourcedata.end(), dummydata,
dummydata + sizeof(dummydata));
Expand Down
6 changes: 4 additions & 2 deletions src/qt/paymentserver.cpp
Expand Up @@ -549,8 +549,10 @@ bool PaymentServer::processPaymentRequest(const PaymentRequestPlus &request,
addresses.append(QString::fromStdString(EncodeDestination(dest)));
} else if (!recipient.authenticatedMerchant.isEmpty()) {
// Unauthenticated payment requests to custom bitcoin addresses are
// not supported (there is no good way to tell the user where they
// are paying in a way they'd have a chance of understanding).
// not supported
// (there is no good way to tell the user where they are paying in a
// way they'd
// have a chance of understanding).
Q_EMIT message(tr("Payment request rejected"),
tr("Unverified payment requests to custom payment "
"scripts are unsupported."),
Expand Down
4 changes: 2 additions & 2 deletions src/qt/transactiondesc.cpp
Expand Up @@ -90,8 +90,8 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx,
// Offline transaction
if (nNet > 0) {
// Credit
if (IsValidDestinationString(rec->address)) {
CTxDestination address = DecodeDestination(rec->address);
CTxDestination address = DecodeDestination(rec->address);
if (IsValidDestination(address)) {
if (wallet->mapAddressBook.count(address)) {
strHTML +=
"<b>" + tr("From") + ":</b> " + tr("unknown") + "<br>";
Expand Down

0 comments on commit 3648e1b

Please sign in to comment.