mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-16 17:27:39 +00:00
use BigInt defaultFeeRate, BitcoinFrost's default, right cryptoCurrency
This commit is contained in:
parent
3b9676f40e
commit
713d8b0cde
12 changed files with 28 additions and 25 deletions
|
@ -10,7 +10,6 @@
|
|||
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:decimal/decimal.dart';
|
||||
|
@ -26,6 +25,7 @@ import '../services/event_bus/events/global/tor_connection_status_changed_event.
|
|||
import '../services/event_bus/events/global/tor_status_changed_event.dart';
|
||||
import '../services/event_bus/global_event_bus.dart';
|
||||
import '../services/tor_service.dart';
|
||||
import '../utilities/amount/amount.dart';
|
||||
import '../utilities/logger.dart';
|
||||
import '../utilities/prefs.dart';
|
||||
import '../wallets/crypto_currency/crypto_currency.dart';
|
||||
|
@ -1115,22 +1115,24 @@ class ElectrumXClient {
|
|||
],
|
||||
);
|
||||
try {
|
||||
// If the response is -1 or null, fall back to the defaultFeeRate.
|
||||
if (response == null ||
|
||||
response == -1 ||
|
||||
Decimal.parse(response.toString()) == Decimal.parse("-1")) {
|
||||
if (CryptoCurrency is! BitcoinFrost) {
|
||||
// TODO [prio=low]: Take `blocks` into account.
|
||||
return Decimal.parse(
|
||||
((cryptoCurrency as ElectrumXCurrencyInterface).defaultFeeRate /
|
||||
pow(10, cryptoCurrency.fractionDigits))
|
||||
.toString());
|
||||
if (cryptoCurrency is BitcoinFrost) {
|
||||
final rate = Amount(
|
||||
rawValue: (cryptoCurrency as BitcoinFrost).defaultFeeRate,
|
||||
fractionDigits: cryptoCurrency.fractionDigits,
|
||||
);
|
||||
return rate.decimal;
|
||||
} else if (cryptoCurrency is ElectrumXCurrencyInterface) {
|
||||
final rate = Amount(
|
||||
rawValue:
|
||||
(cryptoCurrency as ElectrumXCurrencyInterface).defaultFeeRate,
|
||||
fractionDigits: cryptoCurrency.fractionDigits,
|
||||
);
|
||||
return rate.decimal;
|
||||
} else {
|
||||
// Use Bitcoin's default fee rate for Bitcoin Frost.
|
||||
return Decimal.parse(
|
||||
((Bitcoin(CryptoCurrencyNetwork.main).defaultFeeRate /
|
||||
pow(10, cryptoCurrency.fractionDigits))
|
||||
.toString()));
|
||||
throw Exception("Unexpected cryptoCurrency found!");
|
||||
}
|
||||
}
|
||||
return Decimal.parse(response.toString());
|
||||
|
|
|
@ -297,6 +297,6 @@ class Bitcoin extends Bip39HDCurrency
|
|||
int get transactionVersion => 1;
|
||||
|
||||
@override
|
||||
int get defaultFeeRate => 1000;
|
||||
BigInt get defaultFeeRate => BigInt.from(1000);
|
||||
// https://github.com/bitcoin/bitcoin/blob/feab35189bc00bc4cf15e9dcb5cf6b34ff3a1e91/test/functional/mempool_limit.py#L259
|
||||
}
|
||||
|
|
|
@ -202,6 +202,7 @@ class BitcoinFrost extends FrostCurrency {
|
|||
}
|
||||
}
|
||||
|
||||
@override
|
||||
int get defaultFeeRate => 1000;
|
||||
// @override
|
||||
BigInt get defaultFeeRate => BigInt.from(1000);
|
||||
// https://github.com/bitcoin/bitcoin/blob/feab35189bc00bc4cf15e9dcb5cf6b34ff3a1e91/test/functional/mempool_limit.py#L259
|
||||
}
|
||||
|
|
|
@ -369,5 +369,5 @@ class Bitcoincash extends Bip39HDCurrency with ElectrumXCurrencyInterface {
|
|||
int get transactionVersion => 2;
|
||||
|
||||
@override
|
||||
int get defaultFeeRate => 1000;
|
||||
BigInt get defaultFeeRate => BigInt.from(1000);
|
||||
}
|
||||
|
|
|
@ -254,6 +254,6 @@ class Dogecoin extends Bip39HDCurrency with ElectrumXCurrencyInterface {
|
|||
int get transactionVersion => 1;
|
||||
|
||||
@override
|
||||
int get defaultFeeRate => 1000000;
|
||||
BigInt get defaultFeeRate => BigInt.from(1000000);
|
||||
// https://github.com/dogecoin/dogecoin/blob/master/doc/fee-recommendation.md
|
||||
}
|
||||
|
|
|
@ -341,5 +341,5 @@ class Ecash extends Bip39HDCurrency with ElectrumXCurrencyInterface {
|
|||
int get transactionVersion => 2;
|
||||
|
||||
@override
|
||||
int get defaultFeeRate => 200;
|
||||
BigInt get defaultFeeRate => BigInt.from(200);
|
||||
}
|
||||
|
|
|
@ -272,5 +272,5 @@ class Firo extends Bip39HDCurrency with ElectrumXCurrencyInterface {
|
|||
int get transactionVersion => 1;
|
||||
|
||||
@override
|
||||
int get defaultFeeRate => 1000;
|
||||
BigInt get defaultFeeRate => BigInt.from(1000);
|
||||
}
|
||||
|
|
|
@ -285,5 +285,5 @@ class Litecoin extends Bip39HDCurrency with ElectrumXCurrencyInterface {
|
|||
int get transactionVersion => 1;
|
||||
|
||||
@override
|
||||
int get defaultFeeRate => 1000;
|
||||
BigInt get defaultFeeRate => BigInt.from(1000);
|
||||
}
|
||||
|
|
|
@ -257,5 +257,5 @@ class Namecoin extends Bip39HDCurrency with ElectrumXCurrencyInterface {
|
|||
int get transactionVersion => 1;
|
||||
|
||||
@override
|
||||
int get defaultFeeRate => 1000;
|
||||
BigInt get defaultFeeRate => BigInt.from(1000);
|
||||
}
|
||||
|
|
|
@ -235,5 +235,5 @@ class Particl extends Bip39HDCurrency with ElectrumXCurrencyInterface {
|
|||
int get transactionVersion => 1;
|
||||
|
||||
@override
|
||||
int get defaultFeeRate => 20000;
|
||||
BigInt get defaultFeeRate => BigInt.from(20000);
|
||||
}
|
||||
|
|
|
@ -259,5 +259,5 @@ class Peercoin extends Bip39HDCurrency with ElectrumXCurrencyInterface {
|
|||
int get transactionVersion => 3;
|
||||
|
||||
@override
|
||||
int get defaultFeeRate => 5000;
|
||||
BigInt get defaultFeeRate => BigInt.from(5000);
|
||||
}
|
||||
|
|
|
@ -4,5 +4,5 @@ mixin ElectrumXCurrencyInterface on Bip39HDCurrency {
|
|||
int get transactionVersion;
|
||||
|
||||
/// The default fee rate in satoshis per kilobyte.
|
||||
int get defaultFeeRate;
|
||||
BigInt get defaultFeeRate;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue