aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2011-07-27 21:44:55 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2011-07-27 21:44:55 +0200
commitb5b1d1a66b9f418c9fb293cb1cc3eac09a711c4e (patch)
tree0efbb26069cf36cc64775ba0a50c62a7e7f644aa
parent7df001be9449bf99e720d6e750d282b77eda5a51 (diff)
parenta139ed74f2a5764afbd678c0e4eb6143455a3a49 (diff)
Merge branch 'master' of https://github.com/bitcoin/bitcoin
Conflicts: src/script.cpp
-rw-r--r--src/db.cpp2
-rw-r--r--src/qt/transactiondesc.cpp2
-rw-r--r--src/qt/transactionrecord.cpp2
-rw-r--r--src/script.cpp33
-rw-r--r--src/ui.cpp8
-rw-r--r--src/wallet.cpp2
6 files changed, 28 insertions, 21 deletions
diff --git a/src/db.cpp b/src/db.cpp
index 6692db239f..9c8c9c4f73 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -528,7 +528,7 @@ bool CAddrDB::LoadAddresses()
char psz[1000];
while (fgets(psz, sizeof(psz), filein))
{
- CAddress addr(psz, NODE_NETWORK);
+ CAddress addr(psz, false, NODE_NETWORK);
addr.nTime = 0; // so it won't relay unless successfully connected
if (addr.IsValid())
AddAddress(addr);
diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
index 7f4bebb3fb..625b8e3f5e 100644
--- a/src/qt/transactiondesc.cpp
+++ b/src/qt/transactiondesc.cpp
@@ -211,7 +211,7 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
{
// Offline transaction
CBitcoinAddress address;
- if (ExtractAddress(txout.scriptPubKey, wallet, address))
+ if (ExtractAddress(txout.scriptPubKey, 0, address))
{
strHTML += _("<b>To:</b> ");
if (wallet->mapAddressBook.count(address) && !wallet->mapAddressBook[address].empty())
diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp
index 50767d30fe..77c5a01260 100644
--- a/src/qt/transactionrecord.cpp
+++ b/src/qt/transactionrecord.cpp
@@ -138,7 +138,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
// Sent to Bitcoin Address
sub.type = TransactionRecord::SendToAddress;
CBitcoinAddress address;
- if (ExtractAddress(txout.scriptPubKey, wallet, address))
+ if (ExtractAddress(txout.scriptPubKey, 0, address))
{
sub.address = address.ToString();
}
diff --git a/src/script.cpp b/src/script.cpp
index d1e747251b..f5ca87ced8 100644
--- a/src/script.cpp
+++ b/src/script.cpp
@@ -1122,31 +1122,38 @@ bool IsMine(const CKeyStore &keystore, const CScript& scriptPubKey)
return true;
}
-
-bool ExtractAddress(const CScript& scriptPubKey, const CKeyStore* keystore, CBitcoinAddress& addressRet)
+// requires either keystore==0, or a lock on keystore->cs_KeyStore
+bool static ExtractAddressInner(const CScript& scriptPubKey, const CKeyStore* keystore, CBitcoinAddress& addressRet)
{
vector<pair<opcodetype, valtype> > vSolution;
if (!Solver(scriptPubKey, vSolution))
return false;
- CRITICAL_BLOCK(keystore->cs_KeyStore)
+ BOOST_FOREACH(PAIRTYPE(opcodetype, valtype)& item, vSolution)
{
- BOOST_FOREACH(PAIRTYPE(opcodetype, valtype)& item, vSolution)
- {
- uint160 hash160;
- if (item.first == OP_PUBKEY)
- addressRet.SetPubKey(item.second);
- else if (item.first == OP_PUBKEYHASH)
- addressRet.SetHash160((uint160)item.second);
- //if (keystore == NULL || keystore->HaveKey(addressRet))
- return true;
- }
+ if (item.first == OP_PUBKEY)
+ addressRet.SetPubKey(item.second);
+ else if (item.first == OP_PUBKEYHASH)
+ addressRet.SetHash160((uint160)item.second);
+ if (keystore == NULL || keystore->HaveKey(addressRet))
+ return true;
}
return false;
}
+bool ExtractAddress(const CScript& scriptPubKey, const CKeyStore* keystore, CBitcoinAddress& addressRet)
+{
+ if (keystore)
+ CRITICAL_BLOCK(keystore->cs_KeyStore)
+ return ExtractAddressInner(scriptPubKey, keystore, addressRet);
+ else
+ return ExtractAddressInner(scriptPubKey, NULL, addressRet);
+ return false;
+}
+
+
bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, int nHashType)
{
vector<vector<unsigned char> > stack;
diff --git a/src/ui.cpp b/src/ui.cpp
index 7d06caaec4..c3c234439c 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -776,6 +776,7 @@ bool CMainFrame::InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex)
if (pwalletMain->IsMine(txout))
continue;
+ CBitcoinAddress address;
string strAddress;
if (!mapValue["to"].empty())
{
@@ -785,15 +786,14 @@ bool CMainFrame::InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex)
else
{
// Sent to Bitcoin Address
- CBitcoinAddress address;
- if (ExtractAddress(txout.scriptPubKey, pwalletMain, address))
+ if (ExtractAddress(txout.scriptPubKey, NULL, address))
strAddress = address.ToString();
}
string strDescription = _("To: ");
CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook)
- if (pwalletMain->mapAddressBook.count(strAddress) && !pwalletMain->mapAddressBook[strAddress].empty())
- strDescription += pwalletMain->mapAddressBook[strAddress] + " ";
+ if (pwalletMain->mapAddressBook.count(address) && !pwalletMain->mapAddressBook[address].empty())
+ strDescription += pwalletMain->mapAddressBook[address] + " ";
strDescription += strAddress;
if (!mapValue["message"].empty())
{
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 1baf575a59..fcd49e66b9 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -437,7 +437,7 @@ void CWalletTx::GetAmounts(int64& nGeneratedImmature, int64& nGeneratedMature, l
{
CBitcoinAddress address;
vector<unsigned char> vchPubKey;
- if (!ExtractAddress(txout.scriptPubKey, pwallet, address))
+ if (!ExtractAddress(txout.scriptPubKey, NULL, address))
{
printf("CWalletTx::GetAmounts: Unknown transaction type found, txid %s\n",
this->GetHash().ToString().c_str());