diff --git a/lib/models/isar/models/blockchain_data/v2/output_v2.dart b/lib/models/isar/models/blockchain_data/v2/output_v2.dart index 30e24539e..e8f84c54a 100644 --- a/lib/models/isar/models/blockchain_data/v2/output_v2.dart +++ b/lib/models/isar/models/blockchain_data/v2/output_v2.dart @@ -46,6 +46,7 @@ class OutputV2 { Map json, { required bool walletOwns, required int decimalPlaces, + bool isECashFullAmountNotSats = false, }) { try { List addresses = []; @@ -60,10 +61,9 @@ class OutputV2 { return OutputV2.isarCantDoRequiredInDefaultConstructor( scriptPubKeyHex: json["scriptPubKey"]["hex"] as String, - valueStringSats: parseOutputAmountString( - json["value"].toString(), - decimalPlaces: decimalPlaces, - ), + valueStringSats: parseOutputAmountString(json["value"].toString(), + decimalPlaces: decimalPlaces, + isECashFullAmountNotSats: isECashFullAmountNotSats), addresses: addresses, walletOwns: walletOwns, ); @@ -75,6 +75,7 @@ class OutputV2 { static String parseOutputAmountString( String amount, { required int decimalPlaces, + bool isECashFullAmountNotSats = false, }) { final temp = Decimal.parse(amount); if (temp < Decimal.zero) { @@ -82,7 +83,9 @@ class OutputV2 { } final String valueStringSats; - if (temp.isInteger) { + if (isECashFullAmountNotSats) { + valueStringSats = temp.shift(decimalPlaces).toBigInt().toString(); + } else if (temp.isInteger) { valueStringSats = temp.toString(); } else { valueStringSats = temp.shift(decimalPlaces).toBigInt().toString(); diff --git a/lib/wallets/wallet/impl/ecash_wallet.dart b/lib/wallets/wallet/impl/ecash_wallet.dart index 8bf6b24bc..9d38f082a 100644 --- a/lib/wallets/wallet/impl/ecash_wallet.dart +++ b/lib/wallets/wallet/impl/ecash_wallet.dart @@ -168,6 +168,7 @@ class EcashWallet extends Bip39HDWallet final prevOut = OutputV2.fromElectrumXJson( prevOutJson, decimalPlaces: cryptoCurrency.fractionDigits, + isECashFullAmountNotSats: true, walletOwns: false, // doesn't matter here as this is not saved ); @@ -206,6 +207,7 @@ class EcashWallet extends Bip39HDWallet OutputV2 output = OutputV2.fromElectrumXJson( Map.from(outputJson as Map), decimalPlaces: cryptoCurrency.fractionDigits, + isECashFullAmountNotSats: true, // don't know yet if wallet owns. Need addresses first walletOwns: false, );