aboutsummaryrefslogtreecommitdiff
path: root/src/qt
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2011-07-26 15:38:31 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2011-07-26 16:47:23 +0200
commit491ad6db507776054c38230387f384991f42ad29 (patch)
tree7d708a59cb5f61f9d970950c528889dec8fde8d5 /src/qt
parentc0b892fee89cba7d1fda5fda2d2fc7e966643be1 (diff)
parenta9ba47101a46533ff0418d6868ebc9bf5c889818 (diff)
Merge remote branch 'upstream/master'
Conflicts: src/bitcoinrpc.cpp
Diffstat (limited to 'src/qt')
-rw-r--r--src/qt/addresstablemodel.cpp20
-rw-r--r--src/qt/transactiondesc.cpp24
-rw-r--r--src/qt/transactionrecord.cpp14
-rw-r--r--src/qt/walletmodel.cpp7
4 files changed, 32 insertions, 33 deletions
diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp
index 125ceebb33..da086b2784 100644
--- a/src/qt/addresstablemodel.cpp
+++ b/src/qt/addresstablemodel.cpp
@@ -39,18 +39,18 @@ struct AddressTablePriv
{
cachedAddressTable.clear();
- CRITICAL_BLOCK(cs_mapPubKeys)
+ CRITICAL_BLOCK(wallet->cs_KeyStore)
CRITICAL_BLOCK(wallet->cs_mapAddressBook)
{
- BOOST_FOREACH(const PAIRTYPE(std::string, std::string)& item, wallet->mapAddressBook)
+ BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, std::string)& item, wallet->mapAddressBook)
{
- std::string strAddress = item.first;
- std::string strName = item.second;
+ const CBitcoinAddress& address = item.first;
+ const std::string& strName = item.second;
uint160 hash160;
- bool fMine = (AddressToHash160(strAddress, hash160) && mapPubKeys.count(hash160));
+ bool fMine = wallet->HaveKey(address);
cachedAddressTable.append(AddressTableEntry(fMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending,
QString::fromStdString(strName),
- QString::fromStdString(strAddress)));
+ QString::fromStdString(address.ToString())));
}
}
}
@@ -268,9 +268,8 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con
}
else if(type == Receive)
{
- // Generate a new address to associate with given label, optionally
- // set as default receiving address.
- strAddress = PubKeyToAddress(wallet->GetOrReuseKeyFromPool());
+ // Generate a new address to associate with given label
+ strAddress = CBitcoinAddress(wallet->GetOrReuseKeyFromPool()).ToString();
}
else
{
@@ -312,7 +311,8 @@ QString AddressTableModel::labelForAddress(const QString &address) const
{
CRITICAL_BLOCK(wallet->cs_mapAddressBook)
{
- std::map<std::string, std::string>::iterator mi = wallet->mapAddressBook.find(address.toStdString());
+ CBitcoinAddress address_parsed(address.toStdString());
+ std::map<CBitcoinAddress, std::string>::iterator mi = wallet->mapAddressBook.find(address_parsed);
if (mi != wallet->mapAddressBook.end())
{
return QString::fromStdString(mi->second);
diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
index 809e473060..7f4bebb3fb 100644
--- a/src/qt/transactiondesc.cpp
+++ b/src/qt/transactiondesc.cpp
@@ -125,17 +125,16 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
{
if (wallet->IsMine(txout))
{
- vector<unsigned char> vchPubKey;
- if (ExtractPubKey(txout.scriptPubKey, wallet, vchPubKey))
+ CBitcoinAddress address;
+ if (ExtractAddress(txout.scriptPubKey, wallet, address))
{
- string strAddress = PubKeyToAddress(vchPubKey);
- if (wallet->mapAddressBook.count(strAddress))
+ if (wallet->mapAddressBook.count(address))
{
strHTML += string() + _("<b>From:</b> ") + _("unknown") + "<br>";
strHTML += _("<b>To:</b> ");
- strHTML += HtmlEscape(strAddress);
- if (!wallet->mapAddressBook[strAddress].empty())
- strHTML += _(" (yours, label: ") + wallet->mapAddressBook[strAddress] + ")";
+ strHTML += HtmlEscape(address.ToString());
+ if (!wallet->mapAddressBook[address].empty())
+ strHTML += _(" (yours, label: ") + wallet->mapAddressBook[address] + ")";
else
strHTML += _(" (yours)");
strHTML += "<br>";
@@ -211,14 +210,13 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
if (wtx.mapValue["to"].empty())
{
// Offline transaction
- uint160 hash160;
- if (ExtractHash160(txout.scriptPubKey, hash160))
+ CBitcoinAddress address;
+ if (ExtractAddress(txout.scriptPubKey, wallet, address))
{
- string strAddress = Hash160ToAddress(hash160);
strHTML += _("<b>To:</b> ");
- if (wallet->mapAddressBook.count(strAddress) && !wallet->mapAddressBook[strAddress].empty())
- strHTML += wallet->mapAddressBook[strAddress] + " ";
- strHTML += strAddress;
+ if (wallet->mapAddressBook.count(address) && !wallet->mapAddressBook[address].empty())
+ strHTML += wallet->mapAddressBook[address] + " ";
+ strHTML += address.ToString();
strHTML += "<br>";
}
}
diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp
index c74b48bd61..50767d30fe 100644
--- a/src/qt/transactionrecord.cpp
+++ b/src/qt/transactionrecord.cpp
@@ -79,10 +79,10 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
{
if(wallet->IsMine(txout))
{
- std::vector<unsigned char> vchPubKey;
- if (ExtractPubKey(txout.scriptPubKey, wallet, vchPubKey))
+ CBitcoinAddress address;
+ if (ExtractAddress(txout.scriptPubKey, wallet, address))
{
- sub.address = PubKeyToAddress(vchPubKey);
+ sub.address = address.ToString();
}
break;
}
@@ -137,9 +137,11 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
{
// Sent to Bitcoin Address
sub.type = TransactionRecord::SendToAddress;
- uint160 hash160;
- if (ExtractHash160(txout.scriptPubKey, hash160))
- sub.address = Hash160ToAddress(hash160);
+ CBitcoinAddress address;
+ if (ExtractAddress(txout.scriptPubKey, wallet, address))
+ {
+ sub.address = address.ToString();
+ }
}
int64 nValue = txout.nValue;
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
index 4ff2e0ab15..732472c1a9 100644
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -66,9 +66,8 @@ void WalletModel::update()
bool WalletModel::validateAddress(const QString &address)
{
- uint160 hash160 = 0;
-
- return AddressToHash160(address.toStdString(), hash160);
+ CBitcoinAddress addressParsed(address.toStdString());
+ return addressParsed.IsValid();
}
WalletModel::SendCoinsReturn WalletModel::sendCoins(const QList<SendCoinsRecipient> &recipients)
@@ -87,7 +86,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(const QList<SendCoinsRecipie
{
uint160 hash160 = 0;
- if(!AddressToHash160(rcp.address.toUtf8().constData(), hash160))
+ if(!validateAddress(rcp.address))
{
return InvalidAddress;
}