mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 03:49:22 +00:00
weird ecash electrumx server edgecase
This commit is contained in:
parent
d78a3e5104
commit
268dd9dd76
2 changed files with 10 additions and 5 deletions
|
@ -46,6 +46,7 @@ class OutputV2 {
|
|||
Map<String, dynamic> json, {
|
||||
required bool walletOwns,
|
||||
required int decimalPlaces,
|
||||
bool isECashFullAmountNotSats = false,
|
||||
}) {
|
||||
try {
|
||||
List<String> 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();
|
||||
|
|
|
@ -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<String, dynamic>.from(outputJson as Map),
|
||||
decimalPlaces: cryptoCurrency.fractionDigits,
|
||||
isECashFullAmountNotSats: true,
|
||||
// don't know yet if wallet owns. Need addresses first
|
||||
walletOwns: false,
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue