diff options
| author | Wladimir J. van der Laan <[email protected]> | 2011-07-27 21:44:55 +0200 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2011-07-27 21:44:55 +0200 |
| commit | b5b1d1a66b9f418c9fb293cb1cc3eac09a711c4e (patch) | |
| tree | 0efbb26069cf36cc64775ba0a50c62a7e7f644aa /src/script.cpp | |
| parent | normalize SIGNAL/SLOT signatures (http://marcmutz.wordpress.com/effective-qt/... (diff) | |
| parent | CAddrDB::LoadAddresses: properly initialize CAddress (diff) | |
| download | discoin-b5b1d1a66b9f418c9fb293cb1cc3eac09a711c4e.tar.xz discoin-b5b1d1a66b9f418c9fb293cb1cc3eac09a711c4e.zip | |
Merge branch 'master' of https://github.com/bitcoin/bitcoin
Conflicts:
src/script.cpp
Diffstat (limited to 'src/script.cpp')
| -rw-r--r-- | src/script.cpp | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/script.cpp b/src/script.cpp index d1e747251..f5ca87ced 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; |