Bitcoin Core  25.99.0
P2P Digital Currency
Go to the documentation of this file.
1 // Copyright (c) 2023 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or
5 #include <test/util/coins.h>
7 #include <coins.h>
9 #include <script/script.h>
10 #include <test/util/random.h>
11 #include <uint256.h>
13 #include <stdint.h>
14 #include <utility>
17 {
18  Coin new_coin;
19  const uint256 txid{InsecureRand256()};
20  COutPoint outpoint{txid, /*nIn=*/0};
21  new_coin.nHeight = 1;
22  new_coin.out.nValue = InsecureRandMoneyAmount();
23  new_coin.out.scriptPubKey.assign(uint32_t{56}, 1);
24  coins_view.AddCoin(outpoint, std::move(new_coin), /*possible_overwrite=*/false);
26  return outpoint;
27 };
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:230
void AddCoin(const COutPoint &outpoint, Coin &&coin, bool possible_overwrite)
Add a coin.
Definition: coins.cpp:70
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:36
CScript scriptPubKey
Definition: transaction.h:161
CAmount nValue
Definition: transaction.h:160
A UTXO entry.
Definition: coins.h:32
CTxOut out
unspent transaction output
Definition: coins.h:35
uint32_t nHeight
at which height this containing transaction was included in the active block chain
Definition: coins.h:41
void assign(size_type n, const T &val)
Definition: prevector.h:220
256-bit opaque blob.
Definition: uint256.h:106
COutPoint AddTestCoin(CCoinsViewCache &coins_view)
Create a Coin with DynamicMemoryUsage of 80 bytes and add it to the given view.
Definition: coins.cpp:16
static CAmount InsecureRandMoneyAmount()
Definition: random.h:70
static uint256 InsecureRand256()
Definition: random.h:50