Conflicts:
	src/script.cpp
This commit is contained in:
Wladimir J. van der Laan 2011-07-27 21:44:55 +02:00
commit b5b1d1a66b
6 changed files with 28 additions and 21 deletions

View File

@ -528,7 +528,7 @@ bool CAddrDB::LoadAddresses()
char psz[1000]; char psz[1000];
while (fgets(psz, sizeof(psz), filein)) 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 addr.nTime = 0; // so it won't relay unless successfully connected
if (addr.IsValid()) if (addr.IsValid())
AddAddress(addr); AddAddress(addr);

View File

@ -211,7 +211,7 @@ string TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
{ {
// Offline transaction // Offline transaction
CBitcoinAddress address; CBitcoinAddress address;
if (ExtractAddress(txout.scriptPubKey, wallet, address)) if (ExtractAddress(txout.scriptPubKey, 0, address))
{ {
strHTML += _("<b>To:</b> "); strHTML += _("<b>To:</b> ");
if (wallet->mapAddressBook.count(address) && !wallet->mapAddressBook[address].empty()) if (wallet->mapAddressBook.count(address) && !wallet->mapAddressBook[address].empty())

View File

@ -138,7 +138,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
// Sent to Bitcoin Address // Sent to Bitcoin Address
sub.type = TransactionRecord::SendToAddress; sub.type = TransactionRecord::SendToAddress;
CBitcoinAddress address; CBitcoinAddress address;
if (ExtractAddress(txout.scriptPubKey, wallet, address)) if (ExtractAddress(txout.scriptPubKey, 0, address))
{ {
sub.address = address.ToString(); sub.address = address.ToString();
} }

View File

@ -1122,31 +1122,38 @@ bool IsMine(const CKeyStore &keystore, const CScript& scriptPubKey)
return true; return true;
} }
// requires either keystore==0, or a lock on keystore->cs_KeyStore
bool ExtractAddress(const CScript& scriptPubKey, const CKeyStore* keystore, CBitcoinAddress& addressRet) bool static ExtractAddressInner(const CScript& scriptPubKey, const CKeyStore* keystore, CBitcoinAddress& addressRet)
{ {
vector<pair<opcodetype, valtype> > vSolution; vector<pair<opcodetype, valtype> > vSolution;
if (!Solver(scriptPubKey, vSolution)) if (!Solver(scriptPubKey, vSolution))
return false; 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) if (item.first == OP_PUBKEY)
addressRet.SetPubKey(item.second); addressRet.SetPubKey(item.second);
else if (item.first == OP_PUBKEYHASH) else if (item.first == OP_PUBKEYHASH)
addressRet.SetHash160((uint160)item.second); addressRet.SetHash160((uint160)item.second);
//if (keystore == NULL || keystore->HaveKey(addressRet)) if (keystore == NULL || keystore->HaveKey(addressRet))
return true; return true;
} }
}
return false; 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) bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, int nHashType)
{ {
vector<vector<unsigned char> > stack; vector<vector<unsigned char> > stack;

View File

@ -776,6 +776,7 @@ bool CMainFrame::InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex)
if (pwalletMain->IsMine(txout)) if (pwalletMain->IsMine(txout))
continue; continue;
CBitcoinAddress address;
string strAddress; string strAddress;
if (!mapValue["to"].empty()) if (!mapValue["to"].empty())
{ {
@ -785,15 +786,14 @@ bool CMainFrame::InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex)
else else
{ {
// Sent to Bitcoin Address // Sent to Bitcoin Address
CBitcoinAddress address; if (ExtractAddress(txout.scriptPubKey, NULL, address))
if (ExtractAddress(txout.scriptPubKey, pwalletMain, address))
strAddress = address.ToString(); strAddress = address.ToString();
} }
string strDescription = _("To: "); string strDescription = _("To: ");
CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook) CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook)
if (pwalletMain->mapAddressBook.count(strAddress) && !pwalletMain->mapAddressBook[strAddress].empty()) if (pwalletMain->mapAddressBook.count(address) && !pwalletMain->mapAddressBook[address].empty())
strDescription += pwalletMain->mapAddressBook[strAddress] + " "; strDescription += pwalletMain->mapAddressBook[address] + " ";
strDescription += strAddress; strDescription += strAddress;
if (!mapValue["message"].empty()) if (!mapValue["message"].empty())
{ {

View File

@ -437,7 +437,7 @@ void CWalletTx::GetAmounts(int64& nGeneratedImmature, int64& nGeneratedMature, l
{ {
CBitcoinAddress address; CBitcoinAddress address;
vector<unsigned char> vchPubKey; 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", printf("CWalletTx::GetAmounts: Unknown transaction type found, txid %s\n",
this->GetHash().ToString().c_str()); this->GetHash().ToString().c_str());