Bitcoin Core 28.99.0
P2P Digital Currency
script.h
Go to the documentation of this file.
1// Copyright (c) 2021 The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#ifndef BITCOIN_TEST_UTIL_SCRIPT_H
6#define BITCOIN_TEST_UTIL_SCRIPT_H
7
8#include <crypto/sha256.h>
9#include <script/script.h>
10
11static const std::vector<uint8_t> WITNESS_STACK_ELEM_OP_TRUE{uint8_t{OP_TRUE}};
13 CScript{}
14 << OP_0
15 << ToByteVector([] {
16 uint256 hash;
18 return hash;
19 }())};
20
21static const std::vector<uint8_t> EMPTY{};
22static const CScript P2WSH_EMPTY{
23 CScript{}
24 << OP_0
25 << ToByteVector([] {
26 uint256 hash;
27 CSHA256().Write(EMPTY.data(), EMPTY.size()).Finalize(hash.begin());
28 return hash;
29 }())};
30static const std::vector<std::vector<uint8_t>> P2WSH_EMPTY_TRUE_STACK{{static_cast<uint8_t>(OP_TRUE)}, {}};
31static const std::vector<std::vector<uint8_t>> P2WSH_EMPTY_TWO_STACK{{static_cast<uint8_t>(OP_2)}, {}};
32
34bool IsValidFlagCombination(unsigned flags);
35
36#endif // BITCOIN_TEST_UTIL_SCRIPT_H
int flags
Definition: bitcoin-tx.cpp:536
A hasher class for SHA-256.
Definition: sha256.h:14
void Finalize(unsigned char hash[OUTPUT_SIZE])
Definition: sha256.cpp:727
CSHA256 & Write(const unsigned char *data, size_t len)
Definition: sha256.cpp:701
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:415
constexpr unsigned char * begin()
Definition: uint256.h:104
256-bit opaque blob.
Definition: uint256.h:190
@ OP_2
Definition: script.h:85
@ OP_TRUE
Definition: script.h:84
@ OP_0
Definition: script.h:76
std::vector< unsigned char > ToByteVector(const T &in)
Definition: script.h:67
static const std::vector< std::vector< uint8_t > > P2WSH_EMPTY_TRUE_STACK
Definition: script.h:30
static const std::vector< std::vector< uint8_t > > P2WSH_EMPTY_TWO_STACK
Definition: script.h:31
static const std::vector< uint8_t > WITNESS_STACK_ELEM_OP_TRUE
Definition: script.h:11
static const std::vector< uint8_t > EMPTY
Definition: script.h:21
static const CScript P2WSH_OP_TRUE
Definition: script.h:12
static const CScript P2WSH_EMPTY
Definition: script.h:22
bool IsValidFlagCombination(unsigned flags)
Flags that are not forbidden by an assert in script validation.
Definition: script.cpp:8