diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index c76d301615..f7cf72dcec 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -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; diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 48ece311d7..c404b9bfbb 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -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);