Skip to content

Commit

Permalink
GUI: GUIUtil::parseAssetAmount abstraction
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-jr authored and instagibbs committed Apr 9, 2019
1 parent 881862c commit a1a8848
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,15 @@ QString formatMultiAssetAmount(const CAmountMap& amountmap, const int bitcoin_un
return ret.join(line_separator);
}

bool parseAssetAmount(const CAsset& asset, const QString& text, const int bitcoin_unit, CAmount *val_out)
{
if (asset == Params().GetConsensus().pegged_asset) {
return BitcoinUnits::parse(bitcoin_unit, text, val_out);
}

return BitcoinUnits::parse(BitcoinUnits::BTC, text, val_out);
}

QString formatDurationStr(int secs)
{
QStringList strList;
Expand Down
3 changes: 3 additions & 0 deletions src/qt/guiutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ namespace GUIUtil
/* Format one or more asset+amounts in a user-friendly style */
QString formatMultiAssetAmount(const CAmountMap&, int bitcoin_unit, BitcoinUnits::SeparatorStyle, QString line_separator);

/* Parse an amount of a given asset from text */
bool parseAssetAmount(const CAsset&, const QString& text, int bitcoin_unit, CAmount *val_out);

/* Convert seconds into a QString with days, hours, mins, secs */
QString formatDurationStr(int secs);

Expand Down

0 comments on commit a1a8848

Please sign in to comment.