using namespace std;
-bool CheckSig(vector<unsigned char> vchSig, const vector<unsigned char> &vchPubKey, const CScript &scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType, int flags);
+bool CheckSig(vector<unsigned char> vchSig, const vector<unsigned char> &vchPubKey, const CScript &scriptCode, const CTransaction& txTo, uint32_t nIn, int nHashType, int flags);
static const valtype vchFalse(0);
static const valtype vchZero(0);
}
-
//
// Script is a stack machine (like Forth) that evaluates a predicate
// returning a bool indicating valid or not. There are no loops.
//
#define stacktop(i) (stack.at(stack.size()+(i)))
+
+//static inline valtype stacktop(vector<valtype>& st, int nDepth)
+//{
+// return st.at(st.size()+nDepth);
+//}
+
#define altstacktop(i) (altstack.at(altstack.size()+(i)))
+
static inline void popstack(vector<valtype>& stack)
{
if (stack.empty())
return IsDERSignature(vchSig, true, (flags & SCRIPT_VERIFY_LOW_S) != 0);
}
-bool CheckLockTime(const int64_t& nLockTime, const CTransaction &txTo, unsigned int nIn)
+bool CheckLockTime(const int64_t& nLockTime, const CTransaction &txTo, uint32_t nIn)
{
// There are two kinds of nLockTime: lock-by-blockheight
// and lock-by-blocktime, distinguished by whether
return true;
}
-bool CheckSequence(const int64_t& nSequence, const CTransaction &txTo, unsigned int nIn)
+bool CheckSequence(const int64_t& nSequence, const CTransaction &txTo, uint32_t nIn)
{
// Relative lock times are supported by comparing the passed
// in operand to the sequence number of the input.
// (x1 x2 x3 x4 -- x3 x4 x1 x2)
if (stack.size() < 4)
return false;
- swap(stacktop(-4), stacktop(-2));
- swap(stacktop(-3), stacktop(-1));
+ swap(*(stack.end()-4),*(stack.end()-2));
+ swap(*(stack.end()-3),*(stack.end()-1));
}
break;
// (xn ... x2 x1 x0 n - ... x2 x1 x0 xn)
if (stack.size() < 2)
return false;
- int n = CastToBigNum(stacktop(-1)).getint32();
+ int n = CastToBigNum(stack.back()).getint32();
popstack(stack);
if (n < 0 || n >= (int)stack.size())
return false;
// x2 x3 x1 after second swap
if (stack.size() < 3)
return false;
- swap(stacktop(-3), stacktop(-2));
- swap(stacktop(-2), stacktop(-1));
+ swap(*(stack.end()-3), *(stack.end()-2));
+ swap(*(stack.end()-2), *(stack.end()-1));
}
break;
// (x1 x2 -- x2 x1)
if (stack.size() < 2)
return false;
- swap(stacktop(-2), stacktop(-1));
+ swap(*(stack.end()-2),*(stack.end()-1));
}
break;
// (in -- in size)
if (stack.size() < 1)
return false;
- CBigNum bn((uint16_t) stacktop(-1).size());
+ CBigNum bn((uint16_t) (stack.back()).size());
stack.push_back(bn.getvch());
}
break;
{
private:
// sigdata_type is (signature hash, signature, public key):
- typedef tuple<uint256, std::vector<unsigned char>, CPubKey > sigdata_type;
+ typedef tuple<uint256, vector<unsigned char>, CPubKey > sigdata_type;
set< sigdata_type> setValid;
boost::shared_mutex cs_sigcache;
public:
bool
- Get(const uint256 &hash, const std::vector<unsigned char>& vchSig, const CPubKey& pubKey)
+ Get(const uint256 &hash, const vector<unsigned char>& vchSig, const CPubKey& pubKey)
{
boost::shared_lock<boost::shared_mutex> lock(cs_sigcache);
return false;
}
- void Set(const uint256 &hash, const std::vector<unsigned char>& vchSig, const CPubKey& pubKey)
+ void Set(const uint256 &hash, const vector<unsigned char>& vchSig, const CPubKey& pubKey)
{
// DoS prevention: limit cache size to less than 10MB
// (~200 bytes per cache entry times 50,000 entries)
// Since there are a maximum of 20,000 signature operations per block
// 50,000 is a reasonable default.
- int64_t nMaxCacheSize = GetArg("-maxsigcachesize", 50000);
+ size_t nMaxCacheSize = GetArgUInt("-maxsigcachesize", 50000u);
if (nMaxCacheSize <= 0) return;
boost::shared_lock<boost::shared_mutex> lock(cs_sigcache);
- while (static_cast<int64_t>(setValid.size()) > nMaxCacheSize)
+ while (setValid.size() > nMaxCacheSize)
{
// Evict a random entry. Random because that helps
// foil would-be DoS attackers who might try to pre-generate
// and re-use a set of valid signatures just-slightly-greater
// than our cache size.
auto randomHash = GetRandHash();
- std::vector<unsigned char> unused;
+ vector<unsigned char> unused;
auto it = setValid.lower_bound(sigdata_type(randomHash, unused, unused));
if (it == setValid.end())
it = setValid.begin();
};
bool CheckSig(vector<unsigned char> vchSig, const vector<unsigned char> &vchPubKey, const CScript &scriptCode,
- const CTransaction& txTo, unsigned int nIn, int nHashType, int flags)
+ const CTransaction& txTo, uint32_t nIn, int nHashType, int flags)
{
static CSignatureCache signatureCache;
return false;
}
-int ScriptSigArgsExpected(txnouttype t, const std::vector<std::vector<unsigned char> >& vSolutions)
+int ScriptSigArgsExpected(txnouttype t, const vector<vector<unsigned char> >& vSolutions)
{
switch (t)
{
private:
const CKeyStore &keystore;
CAffectedKeysVisitor& operator=(CAffectedKeysVisitor const&);
- std::vector<CKeyID> &vKeys;
+ vector<CKeyID> &vKeys;
public:
- CAffectedKeysVisitor(const CKeyStore &keystoreIn, std::vector<CKeyID> &vKeysIn) : keystore(keystoreIn), vKeys(vKeysIn) {}
+ CAffectedKeysVisitor(const CKeyStore &keystoreIn, vector<CKeyID> &vKeysIn) : keystore(keystoreIn), vKeys(vKeysIn) {}
void Process(const CScript &script) {
txnouttype type;
- std::vector<CTxDestination> vDest;
+ vector<CTxDestination> vDest;
int nRequired;
if (ExtractDestinations(script, type, vDest, nRequired)) {
for(const CTxDestination &dest : vDest)
};
-void ExtractAffectedKeys(const CKeyStore &keystore, const CScript& scriptPubKey, std::vector<CKeyID> &vKeys) {
+void ExtractAffectedKeys(const CKeyStore &keystore, const CScript& scriptPubKey, vector<CKeyID> &vKeys) {
CAffectedKeysVisitor(keystore, vKeys).Process(scriptPubKey);
}
return result;
}
-static CScript CombineMultisig(const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn,
+static CScript CombineMultisig(const CScript& scriptPubKey, const CTransaction& txTo, uint32_t nIn,
const vector<valtype>& vSolutions,
vector<valtype>& sigs1, vector<valtype>& sigs2)
{
return result;
}
-static CScript CombineSignatures(const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn,
+static CScript CombineSignatures(const CScript& scriptPubKey, const CTransaction& txTo, uint32_t nIn,
const txnouttype txType, const vector<valtype>& vSolutions,
vector<valtype>& sigs1, vector<valtype>& sigs2)
{
CScript& CScript::operator<<(const CPubKey& key)
{
- std::vector<uint8_t> vchKey(key.begin(), key.end());
+ vector<uint8_t> vchKey(key.begin(), key.end());
return (*this) << vchKey;
}
return *this;
}
-CScript& CScript::operator<<(const std::vector<uint8_t>& b)
+CScript& CScript::operator<<(const vector<uint8_t>& b)
{
if (b.size() < OP_PUSHDATA1)
{
return *this;
}
-bool CScript::GetOp(iterator& pc, opcodetype& opcodeRet, std::vector<uint8_t>& vchRet)
+bool CScript::GetOp(iterator& pc, opcodetype& opcodeRet, vector<uint8_t>& vchRet)
{
// Wrapper so it can be called with either iterator or const_iterator
const_iterator pc2 = pc;
return fRet;
}
-bool CScript::GetOp(const_iterator& pc, opcodetype& opcodeRet, std::vector<uint8_t>& vchRet) const
+bool CScript::GetOp(const_iterator& pc, opcodetype& opcodeRet, vector<uint8_t>& vchRet) const
{
return GetOp2(pc, opcodeRet, &vchRet);
}
return GetOp2(pc, opcodeRet, NULL);
}
-bool CScript::GetOp2(const_iterator& pc, opcodetype& opcodeRet, std::vector<uint8_t>* pvchRet) const
+bool CScript::GetOp2(const_iterator& pc, opcodetype& opcodeRet, vector<uint8_t>* pvchRet) const
{
opcodeRet = OP_INVALIDOPCODE;
if (pvchRet)
while (pc < end())
{
opcodetype opcode;
- std::vector<unsigned char> data;
+ vector<unsigned char> data;
if (!GetOp(pc, opcode, data))
return false;
if (opcode > OP_16)
}
}
-void CScript::SetMultisig(int nRequired, const std::vector<CPubKey>& keys)
+void CScript::SetMultisig(int nRequired, const vector<CPubKey>& keys)
{
this->clear();
printf("CScript(%s)\n", HexStr(begin(), end(), true).c_str());
}
-std::string CScript::ToString(bool fShort) const
+string CScript::ToString(bool fShort) const
{
- std::string str;
+ string str;
opcodetype opcode;
- std::vector<uint8_t> vch;
+ vector<uint8_t> vch;
const_iterator pc = begin();
while (pc < end())
{