mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-17 19:18:00 +02:00
Prevector type
This commit is contained in:
@@ -1032,7 +1032,7 @@ public:
|
||||
// Serialize the script
|
||||
if (nInput != nIn)
|
||||
// Blank out other inputs' signatures
|
||||
::Serialize(s, CScript(), nType, nVersion);
|
||||
::Serialize(s, CScriptBase(), nType, nVersion);
|
||||
else
|
||||
SerializeScriptCode(s, nType, nVersion);
|
||||
// Serialize the nSequence
|
||||
|
||||
@@ -205,9 +205,9 @@ bool CScript::IsPayToScriptHash() const
|
||||
{
|
||||
// Extra-fast test for pay-to-script-hash CScripts:
|
||||
return (this->size() == 23 &&
|
||||
this->at(0) == OP_HASH160 &&
|
||||
this->at(1) == 0x14 &&
|
||||
this->at(22) == OP_EQUAL);
|
||||
(*this)[0] == OP_HASH160 &&
|
||||
(*this)[1] == 0x14 &&
|
||||
(*this)[22] == OP_EQUAL);
|
||||
}
|
||||
|
||||
bool CScript::IsPushOnly(const_iterator pc) const
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#define BITCOIN_SCRIPT_SCRIPT_H
|
||||
|
||||
#include "crypto/common.h"
|
||||
#include "prevector.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <climits>
|
||||
@@ -354,8 +355,10 @@ private:
|
||||
int64_t m_value;
|
||||
};
|
||||
|
||||
typedef prevector<28, unsigned char> CScriptBase;
|
||||
|
||||
/** Serialized script, used inside transaction inputs and outputs */
|
||||
class CScript : public std::vector<unsigned char>
|
||||
class CScript : public CScriptBase
|
||||
{
|
||||
protected:
|
||||
CScript& push_int64(int64_t n)
|
||||
@@ -376,9 +379,10 @@ protected:
|
||||
}
|
||||
public:
|
||||
CScript() { }
|
||||
CScript(const CScript& b) : std::vector<unsigned char>(b.begin(), b.end()) { }
|
||||
CScript(const_iterator pbegin, const_iterator pend) : std::vector<unsigned char>(pbegin, pend) { }
|
||||
CScript(const unsigned char* pbegin, const unsigned char* pend) : std::vector<unsigned char>(pbegin, pend) { }
|
||||
CScript(const CScript& b) : CScriptBase(b.begin(), b.end()) { }
|
||||
CScript(const_iterator pbegin, const_iterator pend) : CScriptBase(pbegin, pend) { }
|
||||
CScript(std::vector<unsigned char>::const_iterator pbegin, std::vector<unsigned char>::const_iterator pend) : CScriptBase(pbegin, pend) { }
|
||||
CScript(const unsigned char* pbegin, const unsigned char* pend) : CScriptBase(pbegin, pend) { }
|
||||
|
||||
CScript& operator+=(const CScript& b)
|
||||
{
|
||||
@@ -611,7 +615,7 @@ public:
|
||||
void clear()
|
||||
{
|
||||
// The default std::vector::clear() does not release memory.
|
||||
std::vector<unsigned char>().swap(*this);
|
||||
CScriptBase().swap(*this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef vector<unsigned char> valtype;
|
||||
typedef std::vector<unsigned char> valtype;
|
||||
|
||||
TransactionSignatureCreator::TransactionSignatureCreator(const CKeyStore* keystoreIn, const CTransaction* txToIn, unsigned int nInIn, int nHashTypeIn) : BaseSignatureCreator(keystoreIn), txTo(txToIn), nIn(nInIn), nHashType(nHashTypeIn), checker(txTo, nIn) {}
|
||||
|
||||
@@ -118,7 +118,7 @@ bool ProduceSignature(const BaseSignatureCreator& creator, const CScript& fromPu
|
||||
bool fSolved =
|
||||
SignStep(creator, subscript, scriptSig, subType) && subType != TX_SCRIPTHASH;
|
||||
// Append serialized subscript whether or not it is completely signed:
|
||||
scriptSig << static_cast<valtype>(subscript);
|
||||
scriptSig << valtype(subscript.begin(), subscript.end());
|
||||
if (!fSolved) return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user