From 5abbc8f4ddaab9a58ed79327441aecb710f3c538 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Wed, 15 Feb 2023 23:16:21 +0200 Subject: [PATCH] Fix incorrect amount parsing due to bytes approximation --- cw_bitcoin/lib/bitcoin_amount_format.dart | 2 +- cw_core/lib/monero_amount_format.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cw_bitcoin/lib/bitcoin_amount_format.dart b/cw_bitcoin/lib/bitcoin_amount_format.dart index c72d21960..d5a42d984 100644 --- a/cw_bitcoin/lib/bitcoin_amount_format.dart +++ b/cw_bitcoin/lib/bitcoin_amount_format.dart @@ -17,7 +17,7 @@ int stringDoubleToBitcoinAmount(String amount) { int result = 0; try { - result = (double.parse(amount) * bitcoinAmountDivider).toInt(); + result = (double.parse(amount) * bitcoinAmountDivider).round(); } catch (e) { result = 0; } diff --git a/cw_core/lib/monero_amount_format.dart b/cw_core/lib/monero_amount_format.dart index 912527b4e..0bf0031c9 100644 --- a/cw_core/lib/monero_amount_format.dart +++ b/cw_core/lib/monero_amount_format.dart @@ -15,4 +15,4 @@ double moneroAmountToDouble({required int amount}) => cryptoAmountToDouble(amount: amount, divider: moneroAmountDivider); int moneroParseAmount({required String amount}) => - (double.parse(amount) * moneroAmountDivider).toInt(); + (double.parse(amount) * moneroAmountDivider).round();