Compare commits

...

2 commits

Author SHA1 Message Date
serkixenos
0aaa07017f Merge branch 'develop' into hotfix/cli-buy-sell-fix 2020-12-17 17:59:11 +01:00
serkixenos
24670d7c5c Remove std::to_string(double), due to fixed conversion precision
- std::to_string(double) converts double to precision 6, eg 1 to "1.000000"
- stringstream conversion from double to string will keep minimal
  number of decimals (eg, it wil ltrim zeros), eg 1 to "1", 1.2 to "1.2"
2020-12-02 01:23:07 +01:00

View file

@ -5561,8 +5561,15 @@ signed_transaction wallet_api::sell( string seller_account,
double amount,
bool broadcast )
{
return my->sell_asset( seller_account, std::to_string( amount ), base,
std::to_string( rate * amount ), quote, 0, false, broadcast );
std::stringstream ss;
ss.str(std::string());
ss << std::noshowpoint << amount;
std::string amount_to_sell = ss.str();
ss.str(std::string());
ss << std::noshowpoint << rate * amount;
std::string min_to_receive = ss.str();
return my->sell_asset( seller_account, amount_to_sell, base,
min_to_receive, quote, 0, false, broadcast );
}
signed_transaction wallet_api::buy( string buyer_account,
@ -5572,8 +5579,15 @@ signed_transaction wallet_api::buy( string buyer_account,
double amount,
bool broadcast )
{
return my->sell_asset( buyer_account, std::to_string( rate * amount ), quote,
std::to_string( amount ), base, 0, false, broadcast );
std::stringstream ss;
ss.str(std::string());
ss << std::noshowpoint << rate * amount;
std::string amount_to_sell = ss.str();
ss.str(std::string());
ss << std::noshowpoint << amount;
std::string min_to_receive = ss.str();
return my->sell_asset( buyer_account, amount_to_sell, quote,
min_to_receive, base, 0, false, broadcast );
}
signed_transaction wallet_api::borrow_asset(string seller_name, string amount_to_sell,