Change anonFees key to a more generalized overrideFee in tx otherData. May cause some current testing wallets to display weird prices. Won't affect production. To fix testing wallets just rescan/restore.

This commit is contained in:
julian 2024-01-10 16:28:30 -06:00
parent da88f6640c
commit af02bddef1
5 changed files with 10 additions and 9 deletions
lib
models/isar/models/blockchain_data/v2
wallets/wallet

View file

@ -76,8 +76,8 @@ class TransactionV2 {
}
Amount getFee({required Coin coin}) {
// try anon fee first
final fee = _getAnonFee();
// check for override fee
final fee = _getOverrideFee();
if (fee != null) {
return fee;
}
@ -136,10 +136,11 @@ class TransactionV2 {
...outputs.map((e) => e.addresses).expand((e) => e),
};
Amount? _getAnonFee() {
Amount? _getOverrideFee() {
try {
final map = jsonDecode(otherData!) as Map;
return Amount.fromSerializedJsonString(map["anonFees"] as String);
return Amount.fromSerializedJsonString(
_getFromOtherData(key: "overrideFee") as String,
);
} catch (_) {
return null;
}

View file

@ -1022,7 +1022,7 @@ class EpiccashWallet extends Bip39Wallet {
"isCancelled":
tx.txType == epic_models.TransactionType.TxSentCancelled ||
tx.txType == epic_models.TransactionType.TxReceivedCancelled,
"anonFees": Amount(
"overrideFee": Amount(
rawValue: BigInt.from(fee),
fractionDigits: cryptoCurrency.fractionDigits,
).toJsonString(),

View file

@ -308,7 +308,7 @@ class EthereumWallet extends Bip39Wallet with PrivateKeyInterface {
final otherData = {
"nonce": tuple.item2,
"isCancelled": txFailed,
"anonFees": txFee.toJsonString(),
"overrideFee": txFee.toJsonString(),
};
final txn = TransactionV2(

View file

@ -500,7 +500,7 @@ class FiroWallet extends Bip39HDWallet
if (anonFees != null) {
otherData = jsonEncode(
{
"anonFees": anonFees.toJsonString(),
"overrideFee": anonFees.toJsonString(),
},
);
}

View file

@ -507,7 +507,7 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface {
subType: TransactionSubType.sparkSpend,
otherData: jsonEncode(
{
"anonFees": fee.toJsonString(),
"overrideFee": fee.toJsonString(),
},
),
height: null,