aboutsummaryrefslogtreecommitdiff
path: root/src/qt/bitcoinunits.h
blob: fa85755ad412e0f0c85d729050d32120ba9fc2dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef BITCOINUNITS_H
#define BITCOINUNITS_H

#include <QString>

// Bitcoin unit definitions
class BitcoinUnits
{
public:
    enum Unit
    {
        BTC,
        mBTC,
        uBTC
    };

    // Short name
    static QString name(Unit unit);
    // Longer description
    static QString description(Unit unit);
    // Number of satoshis / unit
    static qint64 factor(Unit unit);
    // Number of decimals left
    static int decimals(Unit unit);
    // Format as string
    static QString format(Unit unit, qint64 amount, bool plussign=false);
    // Format as string (with unit)
    static QString formatWithUnit(Unit unit, qint64 amount, bool plussign=false);
    // Parse string to coin amount
    static bool parse(Unit unit, const QString &value, qint64 *val_out);

};

#endif // BITCOINUNITS_H