Changeset View
Changeset View
Standalone View
Standalone View
src/qt/addresstablemodel.cpp
// Copyright (c) 2011-2016 The Bitcoin Core developers | // Copyright (c) 2011-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <qt/addresstablemodel.h> | #include <qt/addresstablemodel.h> | ||||
#include <cashaddrenc.h> | |||||
#include <dstencode.h> | #include <dstencode.h> | ||||
#include <interfaces/node.h> | #include <interfaces/node.h> | ||||
#include <qt/guiutil.h> | #include <qt/guiutil.h> | ||||
#include <qt/walletmodel.h> | #include <qt/walletmodel.h> | ||||
#include <wallet/wallet.h> | #include <wallet/wallet.h> | ||||
#include <QDebug> | #include <QDebug> | ||||
#include <QFont> | #include <QFont> | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | public: | ||||
void refreshAddressTable(interfaces::Wallet &wallet) { | void refreshAddressTable(interfaces::Wallet &wallet) { | ||||
cachedAddressTable.clear(); | cachedAddressTable.clear(); | ||||
for (const auto &address : wallet.getAddresses()) { | for (const auto &address : wallet.getAddresses()) { | ||||
AddressTableEntry::Type addressType = translateTransactionType( | AddressTableEntry::Type addressType = translateTransactionType( | ||||
QString::fromStdString(address.purpose), address.is_mine); | QString::fromStdString(address.purpose), address.is_mine); | ||||
cachedAddressTable.append(AddressTableEntry( | cachedAddressTable.append(AddressTableEntry( | ||||
addressType, QString::fromStdString(address.name), | addressType, QString::fromStdString(address.name), | ||||
QString::fromStdString(EncodeDestination(address.dest)))); | QString::fromStdString(EncodeCashAddr( | ||||
address.dest, parent->walletModel->getChainParams())))); | |||||
} | } | ||||
// qLowerBound() and qUpperBound() require our cachedAddressTable list | // qLowerBound() and qUpperBound() require our cachedAddressTable list | ||||
// to be sorted in asc order. Even though the map is already sorted this | // to be sorted in asc order. Even though the map is already sorted this | ||||
// re-sorting step is needed because the originating map is sorted by | // re-sorting step is needed because the originating map is sorted by | ||||
// binary address, not by base58() address. | // binary address, not by base58() address. | ||||
qSort(cachedAddressTable.begin(), cachedAddressTable.end(), | qSort(cachedAddressTable.begin(), cachedAddressTable.end(), | ||||
AddressTableEntryLessThan()); | AddressTableEntryLessThan()); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 254 Lines • ▼ Show 20 Lines | if (type == Send) { | ||||
if (!walletModel->wallet().getKeyFromPool(false /* internal */, | if (!walletModel->wallet().getKeyFromPool(false /* internal */, | ||||
newKey)) { | newKey)) { | ||||
editStatus = KEY_GENERATION_FAILURE; | editStatus = KEY_GENERATION_FAILURE; | ||||
return QString(); | return QString(); | ||||
} | } | ||||
} | } | ||||
walletModel->wallet().learnRelatedScripts(newKey, g_address_type); | walletModel->wallet().learnRelatedScripts(newKey, g_address_type); | ||||
strAddress = | strAddress = | ||||
EncodeDestination(GetDestinationForKey(newKey, g_address_type)); | EncodeCashAddr(GetDestinationForKey(newKey, g_address_type), | ||||
walletModel->getChainParams()); | |||||
} else { | } else { | ||||
return QString(); | return QString(); | ||||
} | } | ||||
// Add entry | // Add entry | ||||
walletModel->wallet().setAddressBook( | walletModel->wallet().setAddressBook( | ||||
DecodeDestination(strAddress, walletModel->getChainParams()), strLabel, | DecodeDestination(strAddress, walletModel->getChainParams()), strLabel, | ||||
(type == Send ? "send" : "receive")); | (type == Send ? "send" : "receive")); | ||||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |