mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-19 13:27:35 +02:00
script: add ToByteVector() for converting anything with begin/end
This should move to a util header once their dependencies are cleaned up.
This commit is contained in:
parent
066e2a1403
commit
e9ca4280f3
9 changed files with 91 additions and 108 deletions
|
|
@ -16,6 +16,12 @@
|
|||
|
||||
static const unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520; // bytes
|
||||
|
||||
template <typename T>
|
||||
std::vector<unsigned char> ToByteVector(const T& in)
|
||||
{
|
||||
return std::vector<unsigned char>(in.begin(), in.end());
|
||||
}
|
||||
|
||||
/** Script opcodes */
|
||||
enum opcodetype
|
||||
{
|
||||
|
|
@ -358,7 +364,6 @@ public:
|
|||
CScript(int64_t b) { operator<<(b); }
|
||||
|
||||
explicit CScript(opcodetype b) { operator<<(b); }
|
||||
explicit CScript(const uint256& b) { operator<<(b); }
|
||||
explicit CScript(const CScriptNum& b) { operator<<(b); }
|
||||
explicit CScript(const std::vector<unsigned char>& b) { operator<<(b); }
|
||||
|
||||
|
|
@ -373,28 +378,6 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
CScript& operator<<(const uint160& b)
|
||||
{
|
||||
insert(end(), sizeof(b));
|
||||
insert(end(), (unsigned char*)&b, (unsigned char*)&b + sizeof(b));
|
||||
return *this;
|
||||
}
|
||||
|
||||
CScript& operator<<(const uint256& b)
|
||||
{
|
||||
insert(end(), sizeof(b));
|
||||
insert(end(), (unsigned char*)&b, (unsigned char*)&b + sizeof(b));
|
||||
return *this;
|
||||
}
|
||||
|
||||
CScript& operator<<(const CPubKey& key)
|
||||
{
|
||||
assert(key.size() < OP_PUSHDATA1);
|
||||
insert(end(), (unsigned char)key.size());
|
||||
insert(end(), key.begin(), key.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
CScript& operator<<(const CScriptNum& b)
|
||||
{
|
||||
*this << b.getvch();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue