12#include <validation.h>
14#include <boost/test/unit_test.hpp>
21 int height,
const CKey &masterKey) {
25 const Amount v = (int64_t(score) *
COIN) / 100;
26 const bool is_coinbase =
false;
36 ProofBuilder pb(0, std::numeric_limits<uint32_t>::max(), masterKey, script);
58 for (
auto it = pb.
stakes.rbegin(); it != pb.
stakes.rend(); it++) {
72 std::vector<SignedStake> signedStakes;
73 signedStakes.reserve(pb.
stakes.size());
75 while (!pb.
stakes.empty()) {
78 auto handle = pb.
stakes.extract(std::prev(pb.
stakes.end()));
79 signedStakes.push_back(handle.value());
98 for (
auto &s : pb.
stakes) {
113 std::vector<SignedStake> signedStakes;
114 signedStakes.reserve(2 * pb.
stakes.size());
116 while (!pb.
stakes.empty()) {
119 signedStakes.push_back(signedStake);
120 signedStakes.push_back(signedStake);
static constexpr Amount COIN
CCoinsView that adds a memory cache for transactions to another CCoinsView.
void AddCoin(const COutPoint &outpoint, Coin coin, bool possible_overwrite)
Add a coin.
An encapsulated secp256k1 private key.
static CKey MakeCompressedKey()
Produce a valid compressed key.
CPubKey GetPubKey() const
Compute the public key from a private key.
bool SignSchnorr(const uint256 &hash, SchnorrSig &sig, uint32_t test_case=0) const
Create a Schnorr signature.
An outpoint - a combination of a transaction hash and an index n into its vout.
An encapsulated public key.
Serialized script, used inside transaction inputs and outputs.
An output of a transaction.
Chainstate stores and provides an API to update our local knowledge of the current best chain.
CCoinsViewCache & CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(
A writer stream (for serialization) that computes a 256-bit hash.
static RCUPtr make(Args &&...args)
Construct a new object that is owned by the pointer.
bool addUTXO(COutPoint utxo, Amount amount, uint32_t height, bool is_coinbase, CKey key)
std::set< SignedStake, SignedStakeComparator > stakes
CScript payoutScriptPubKey
const std::vector< SignedStake > & getStakes() const
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
std::array< uint8_t, CPubKey::SCHNORR_SIZE > SchnorrSig
a Schnorr signature
static constexpr Amount PROOF_DUST_THRESHOLD
Minimum amount per utxo.
ProofRef buildRandomProof(Chainstate &active_chainstate, uint32_t score, int height, const CKey &masterKey)
bool hasDustStake(const ProofRef &proof)
#define BOOST_CHECK(expr)
uint256 GetRandHash() noexcept
void WriteCompactSize(CSizeComputer &os, uint64_t nSize)
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
A TxId is the identifier of a transaction.
static ProofRef buildWithReversedOrderStakes(ProofBuilder &pb)
static ProofRef buildDuplicatedStakes(ProofBuilder &pb)
static LimitedProofId getReverseOrderLimitedProofId(ProofBuilder &pb)
static LimitedProofId getDuplicatedStakeLimitedProofId(ProofBuilder &pb)