diff options
author | Ilya Kitaev <mbg033@gmail.com> | 2016-06-16 16:42:33 +0300 |
---|---|---|
committer | Ilya Kitaev <mbg033@gmail.com> | 2016-06-23 16:01:41 +0300 |
commit | 85a632244ef97a500a17a9954914c52487422c5e (patch) | |
tree | 9685f31a01a906cc2dbc08f0e34c8f49ceaeb24d /src/wallet/api/wallet.cpp | |
parent | wallet::default_mixin exposed to public interface as (diff) | |
download | monero-85a632244ef97a500a17a9954914c52487422c5e.tar.xz |
double/string to monero integer convertion methods
Diffstat (limited to 'src/wallet/api/wallet.cpp')
-rw-r--r-- | src/wallet/api/wallet.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index f6d7a561e..1f414b3bf 100644 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -36,6 +36,7 @@ #include "mnemonics/electrum-words.h" #include <boost/format.hpp> +#include <sstream> using namespace std; using namespace cryptonote; @@ -122,6 +123,22 @@ string Wallet::displayAmount(uint64_t amount) return cryptonote::print_money(amount); } +uint64_t Wallet::amountFromString(const string &amount) +{ + uint64_t result; + cryptonote::parse_amount(result, amount); + return result; +} + +uint64_t Wallet::amountFromDouble(double amount) +{ + std::stringstream ss; + ss << std::fixed << std::setprecision(CRYPTONOTE_DISPLAY_DECIMAL_POINT) << amount; + return amountFromString(ss.str()); +} + + + ///////////////////////// WalletImpl implementation //////////////////////// WalletImpl::WalletImpl(bool testnet) :m_wallet(nullptr), m_status(Wallet::Status_Ok), m_trustedDaemon(false), |