Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
test
util
coins.cpp
Go to the documentation of this file.
1
// Copyright (c) 2023-present 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
#include <
test/util/coins.h
>
6
7
#include <
coins.h
>
8
#include <
primitives/transaction.h
>
9
#include <
script/script.h
>
10
#include <
test/util/random.h
>
11
#include <
uint256.h
>
12
13
#include <cstdint>
14
#include <utility>
15
16
COutPoint
AddTestCoin
(
FastRandomContext
& rng,
CCoinsViewCache
& coins_view)
17
{
18
Coin
new_coin;
19
COutPoint
outpoint{
Txid::FromUint256
(rng.
rand256
()),
/*nIn=*/
0};
20
new_coin.
nHeight
= 1;
21
new_coin.
out
.
nValue
=
RandMoney
(rng);
22
new_coin.
out
.
scriptPubKey
.
assign
(uint32_t{56}, 1);
23
coins_view.
AddCoin
(outpoint, std::move(new_coin),
/*possible_overwrite=*/
false
);
24
25
return
outpoint;
26
};
CCoinsViewCache
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition
coins.h:368
CCoinsViewCache::AddCoin
void AddCoin(const COutPoint &outpoint, Coin &&coin, bool possible_overwrite)
Add a coin.
Definition
coins.cpp:89
COutPoint
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition
transaction.h:29
CTxOut::scriptPubKey
CScript scriptPubKey
Definition
transaction.h:143
CTxOut::nValue
CAmount nValue
Definition
transaction.h:142
Coin
A UTXO entry.
Definition
coins.h:35
Coin::out
CTxOut out
unspent transaction output
Definition
coins.h:38
Coin::nHeight
uint32_t nHeight
at which height this containing transaction was included in the active block chain
Definition
coins.h:44
FastRandomContext
Fast randomness source.
Definition
random.h:386
RandomMixin::rand256
uint256 rand256() noexcept
generate a random uint256.
Definition
random.h:317
prevector::assign
void assign(size_type n, const T &val)
Definition
prevector.h:176
transaction_identifier< false >::FromUint256
static transaction_identifier FromUint256(const uint256 &id)
Definition
transaction_identifier.h:49
transaction.h
script.h
AddTestCoin
COutPoint AddTestCoin(FastRandomContext &rng, CCoinsViewCache &coins_view)
Create a Coin with DynamicMemoryUsage of 80 bytes and add it to the given view.
Definition
coins.cpp:16
coins.h
random.h
RandMoney
CAmount RandMoney(Rng &&rng)
Definition
random.h:35
uint256.h
Generated on
for Bitcoin Core by
1.17.0