Bitcoin Core
32.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
test
util
coins.h
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
#ifndef BITCOIN_TEST_UTIL_COINS_H
6
#define BITCOIN_TEST_UTIL_COINS_H
7
8
#include <
coins.h
>
9
#include <
crypto/hex_base.h
>
10
#include <
primitives/transaction.h
>
11
#include <
tinyformat.h
>
12
13
#include <ostream>
14
15
class
CCoinsViewCache
;
16
class
FastRandomContext
;
17
23
COutPoint
AddTestCoin
(
FastRandomContext
&
rng
,
CCoinsViewCache
& coins_view);
24
26
inline
bool
operator==
(
const
Coin
& a,
const
Coin
& b)
27
{
28
return
a.
fCoinBase
== b.
fCoinBase
&& a.
nHeight
== b.
nHeight
&& a.
out
== b.
out
;
29
}
30
32
inline
std::ostream&
operator<<
(std::ostream& os,
const
Coin
& coin)
33
{
34
return
os <<
strprintf
(
"Coin(spent=%d, coinbase=%d, height=%d, value=%d, scriptPubKey=%s)"
,
35
coin.
IsSpent
(), coin.
fCoinBase
, coin.
nHeight
, coin.
out
.
nValue
,
HexStr
(coin.
out
.
scriptPubKey
));
36
}
37
38
#endif
// BITCOIN_TEST_UTIL_COINS_H
operator<<
QDataStream & operator<<(QDataStream &out, const BitcoinUnit &unit)
Definition
bitcoinunits.cpp:255
CCoinsViewCache
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition
coins.h:437
COutPoint
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition
transaction.h:30
CTxOut::scriptPubKey
CScript scriptPubKey
Definition
transaction.h:144
CTxOut::nValue
CAmount nValue
Definition
transaction.h:143
Coin
A UTXO entry.
Definition
coins.h:46
Coin::out
CTxOut out
unspent transaction output
Definition
coins.h:49
Coin::IsSpent
bool IsSpent() const
Either this coin never existed (see e.g.
Definition
coins.h:94
Coin::fCoinBase
bool fCoinBase
whether containing transaction was a coinbase
Definition
coins.h:52
Coin::nHeight
uint32_t nHeight
at which height this containing transaction was included in the active block chain
Definition
coins.h:55
FastRandomContext
Fast randomness source.
Definition
random.h:386
HexStr
std::string HexStr(const std::span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
Definition
hex_base.cpp:30
hex_base.h
operator==
bool operator==(const CNetAddr &a, const CNetAddr &b)
Definition
netaddress.cpp:609
transaction.h
rng
FastRandomContext rng
Definition
dbwrapper.cpp:413
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
tinyformat.h
strprintf
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition
tinyformat.h:1172
Generated on
for Bitcoin Core by
1.18.0