Skip to content

Commit

Permalink
Merge pull request #69 from twostack/coinfix
Browse files Browse the repository at this point in the history
fixed decimal display of coins
  • Loading branch information
stephanfeb authored Sep 5, 2023
2 parents 7f78d89 + eac2a8c commit c71ad29
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/src/coin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class Coin {
static Coin parseCoin(final String str) {
try {
BigInt satoshis = Decimal.parse(str)
.shift(SMALLEST_UNIT_EXPONENT)
.shift(-SMALLEST_UNIT_EXPONENT)
.toBigInt();
return Coin.valueOf(satoshis);
} on FormatException catch (e) {
Expand All @@ -128,7 +128,7 @@ class Coin {
* @return number of bitcoins (in BTC)
*/
static Decimal satoshiToBtc(BigInt satoshis) {
return new Decimal.fromBigInt(satoshis).shift(SMALLEST_UNIT_EXPONENT);
return new Decimal.fromBigInt(satoshis).shift(-SMALLEST_UNIT_EXPONENT);
}

/**
Expand Down Expand Up @@ -174,7 +174,7 @@ class Coin {
static Coin parseCoinInexact(final String str) {
try {
BigInt satoshis = Decimal.parse(str)
.shift(SMALLEST_UNIT_EXPONENT)
.shift(-SMALLEST_UNIT_EXPONENT)
.toBigInt();
return Coin.valueOf(satoshis);
} on FormatException catch (e) {
Expand Down

0 comments on commit c71ad29

Please sign in to comment.