From e679ec969c8b22c676ebb10bea1038f6c8f13b33 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Mon, 3 Oct 2011 13:05:43 -0400 Subject: OP_EVAL implementation OP_EVAL is a new opcode that evaluates an item on the stack as a script. It enables a new type of bitcoin address that needs an arbitrarily complex script to redeem. --- src/keystore.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/keystore.cpp') diff --git a/src/keystore.cpp b/src/keystore.cpp index 6cf557faf..c9b9b4a5d 100644 --- a/src/keystore.cpp +++ b/src/keystore.cpp @@ -33,6 +33,36 @@ bool CBasicKeyStore::AddKey(const CKey& key) return true; } +bool CBasicKeyStore::AddCScript(const uint160 &hash, const std::vector& data) +{ + CRITICAL_BLOCK(cs_KeyStore) + mapData[hash] = data; + return true; +} + +bool CBasicKeyStore::HaveCScript(const uint160& hash) const +{ + bool result; + CRITICAL_BLOCK(cs_KeyStore) + result = (mapData.count(hash) > 0); + return result; +} + + +bool CBasicKeyStore::GetCScript(const uint160 &hash, std::vector& dataOut) const +{ + CRITICAL_BLOCK(cs_KeyStore) + { + DataMap::const_iterator mi = mapData.find(hash); + if (mi != mapData.end()) + { + dataOut = (*mi).second; + return true; + } + } + return false; +} + bool CCryptoKeyStore::SetCrypted() { CRITICAL_BLOCK(cs_KeyStore) -- cgit v1.2.3 From 2a45a494b0bec6a0f1fc6ab7f26c260b85e7ff3e Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Tue, 8 Nov 2011 13:20:29 -0500 Subject: Use block times for 'hard' OP_EVAL switchover, and refactored EvalScript so it takes a flag for how to interpret OP_EVAL. Also increased IsStandard size of scriptSigs to 500 bytes, so a 3-of-3 multisig transaction IsStandard. --- src/keystore.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/keystore.cpp') diff --git a/src/keystore.cpp b/src/keystore.cpp index c9b9b4a5d..21fb0f91b 100644 --- a/src/keystore.cpp +++ b/src/keystore.cpp @@ -4,8 +4,9 @@ // file license.txt or http://www.opensource.org/licenses/mit-license.php. #include "headers.h" -#include "db.h" #include "crypter.h" +#include "db.h" +#include "script.h" std::vector CKeyStore::GenerateNewKey() { @@ -33,10 +34,10 @@ bool CBasicKeyStore::AddKey(const CKey& key) return true; } -bool CBasicKeyStore::AddCScript(const uint160 &hash, const std::vector& data) +bool CBasicKeyStore::AddCScript(const uint160 &hash, const CScript& redeemScript) { CRITICAL_BLOCK(cs_KeyStore) - mapData[hash] = data; + mapScripts[hash] = redeemScript; return true; } @@ -44,19 +45,19 @@ bool CBasicKeyStore::HaveCScript(const uint160& hash) const { bool result; CRITICAL_BLOCK(cs_KeyStore) - result = (mapData.count(hash) > 0); + result = (mapScripts.count(hash) > 0); return result; } -bool CBasicKeyStore::GetCScript(const uint160 &hash, std::vector& dataOut) const +bool CBasicKeyStore::GetCScript(const uint160 &hash, CScript& redeemScriptOut) const { CRITICAL_BLOCK(cs_KeyStore) { - DataMap::const_iterator mi = mapData.find(hash); - if (mi != mapData.end()) + ScriptMap::const_iterator mi = mapScripts.find(hash); + if (mi != mapScripts.end()) { - dataOut = (*mi).second; + redeemScriptOut = (*mi).second; return true; } } -- cgit v1.2.3