Bitcoin Core 28.99.0
P2P Digital Currency
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
BitcoinUnits Class Reference

Bitcoin unit definitions. More...

#include <bitcoinunits.h>

Inheritance diagram for BitcoinUnits:
[legend]
Collaboration diagram for BitcoinUnits:
[legend]

Public Types

enum class  Unit { BTC , mBTC , uBTC , SAT }
 Bitcoin units. More...
 
enum class  SeparatorStyle { NEVER , STANDARD , ALWAYS }
 

Public Member Functions

 BitcoinUnits (QObject *parent)
 

Static Public Member Functions

static QString removeSpaces (QString text)
 
static CAmount maxMoney ()
 Return maximum number of base units (Satoshis) More...
 
Static API

Unit conversion and formatting

static QList< UnitavailableUnits ()
 Get list of units, for drop-down box. More...
 
static QString longName (Unit unit)
 Long name. More...
 
static QString shortName (Unit unit)
 Short name. More...
 
static QString description (Unit unit)
 Longer description. More...
 
static qint64 factor (Unit unit)
 Number of Satoshis (1e-8) per unit. More...
 
static int decimals (Unit unit)
 Number of decimals left. More...
 
static QString format (Unit unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD, bool justify=false)
 Format as string. More...
 
static QString formatWithUnit (Unit unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD)
 Format as string (with unit) More...
 
static QString formatHtmlWithUnit (Unit unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD)
 Format as HTML string (with unit) More...
 
static QString formatWithPrivacy (Unit unit, const CAmount &amount, SeparatorStyle separators, bool privacy)
 Format as string (with unit) of fixed length to preserve privacy, if it is set. More...
 
static bool parse (Unit unit, const QString &value, CAmount *val_out)
 Parse string to coin amount. More...
 
static QString getAmountColumnTitle (Unit unit)
 Gets title for amount column including current display unit if optionsModel reference available *‍/. More...
 

Private Attributes

QList< Unitunitlist
 

AbstractListModel implementation

List model for unit drop-down selection box.

enum  RoleIndex { UnitRole = Qt::UserRole }
 
int rowCount (const QModelIndex &parent) const override
 
QVariant data (const QModelIndex &index, int role) const override
 

Detailed Description

Bitcoin unit definitions.

Encapsulates parsing and formatting and serves as list model for drop-down selection boxes.

Definition at line 32 of file bitcoinunits.h.

Member Enumeration Documentation

◆ RoleIndex

Enumerator
UnitRole 

Unit identifier.

Definition at line 90 of file bitcoinunits.h.

◆ SeparatorStyle

enum class BitcoinUnits::SeparatorStyle
strong
Enumerator
NEVER 
STANDARD 
ALWAYS 

Definition at line 50 of file bitcoinunits.h.

◆ Unit

enum class BitcoinUnits::Unit
strong

Bitcoin units.

Note
Source: https://en.bitcoin.it/wiki/Units . Please add only sensible ones
Enumerator
BTC 
mBTC 
uBTC 
SAT 

Definition at line 42 of file bitcoinunits.h.

Constructor & Destructor Documentation

◆ BitcoinUnits()

BitcoinUnits::BitcoinUnits ( QObject *  parent)
explicit

Definition at line 15 of file bitcoinunits.cpp.

Member Function Documentation

◆ availableUnits()

QList< BitcoinUnit > BitcoinUnits::availableUnits ( )
static

Get list of units, for drop-down box.

Definition at line 21 of file bitcoinunits.cpp.

Here is the caller graph for this function:

◆ data()

QVariant BitcoinUnits::data ( const QModelIndex &  index,
int  role 
) const
override

Definition at line 206 of file bitcoinunits.cpp.

Here is the call graph for this function:

◆ decimals()

int BitcoinUnits::decimals ( Unit  unit)
static

Number of decimals left.

Definition at line 75 of file bitcoinunits.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ description()

QString BitcoinUnits::description ( Unit  unit)
static

Longer description.

Definition at line 53 of file bitcoinunits.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ factor()

qint64 BitcoinUnits::factor ( Unit  unit)
static

Number of Satoshis (1e-8) per unit.

Definition at line 64 of file bitcoinunits.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ format()

QString BitcoinUnits::format ( Unit  unit,
const CAmount amount,
bool  plussign = false,
SeparatorStyle  separators = SeparatorStyle::STANDARD,
bool  justify = false 
)
static

Format as string.

Definition at line 86 of file bitcoinunits.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ formatHtmlWithUnit()

QString BitcoinUnits::formatHtmlWithUnit ( Unit  unit,
const CAmount amount,
bool  plussign = false,
SeparatorStyle  separators = SeparatorStyle::STANDARD 
)
static

Format as HTML string (with unit)

Definition at line 136 of file bitcoinunits.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ formatWithPrivacy()

QString BitcoinUnits::formatWithPrivacy ( Unit  unit,
const CAmount amount,
SeparatorStyle  separators,
bool  privacy 
)
static

Format as string (with unit) of fixed length to preserve privacy, if it is set.

Definition at line 143 of file bitcoinunits.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ formatWithUnit()

QString BitcoinUnits::formatWithUnit ( Unit  unit,
const CAmount amount,
bool  plussign = false,
SeparatorStyle  separators = SeparatorStyle::STANDARD 
)
static

Format as string (with unit)

Definition at line 131 of file bitcoinunits.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAmountColumnTitle()

QString BitcoinUnits::getAmountColumnTitle ( Unit  unit)
static

Gets title for amount column including current display unit if optionsModel reference available *‍/.

Definition at line 195 of file bitcoinunits.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ longName()

QString BitcoinUnits::longName ( Unit  unit)
static

Long name.

Definition at line 31 of file bitcoinunits.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ maxMoney()

CAmount BitcoinUnits::maxMoney ( )
static

Return maximum number of base units (Satoshis)

Definition at line 226 of file bitcoinunits.cpp.

Here is the caller graph for this function:

◆ parse()

bool BitcoinUnits::parse ( Unit  unit,
const QString &  value,
CAmount val_out 
)
static

Parse string to coin amount.

Definition at line 155 of file bitcoinunits.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeSpaces()

static QString BitcoinUnits::removeSpaces ( QString  text)
inlinestatic

Definition at line 98 of file bitcoinunits.h.

Here is the caller graph for this function:

◆ rowCount()

int BitcoinUnits::rowCount ( const QModelIndex &  parent) const
override

Definition at line 200 of file bitcoinunits.cpp.

◆ shortName()

QString BitcoinUnits::shortName ( Unit  unit)
static

Short name.

Definition at line 42 of file bitcoinunits.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ unitlist

QList<Unit> BitcoinUnits::unitlist
private

Definition at line 109 of file bitcoinunits.h.


The documentation for this class was generated from the following files: