fix: dogecoin custom fee slider and possible absurd fees error

This commit is contained in:
julian 2023-07-04 10:25:13 -06:00
parent 2ff855d7d0
commit ab9e734b80
4 changed files with 20 additions and 5 deletions

View file

@ -2065,6 +2065,7 @@ class _SendViewState extends ConsumerState<SendView> {
top: 16, top: 16,
), ),
child: FeeSlider( child: FeeSlider(
coin: coin,
onSatVByteChanged: (rate) { onSatVByteChanged: (rate) {
customFeeRate = rate; customFeeRate = rate;
}, },

View file

@ -1564,6 +1564,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
top: 16, top: 16,
), ),
child: FeeSlider( child: FeeSlider(
coin: coin,
onSatVByteChanged: (rate) { onSatVByteChanged: (rate) {
customFeeRate = rate; customFeeRate = rate;
}, },

View file

@ -2665,7 +2665,10 @@ class DogecoinWallet extends CoinServiceAPI
Logging.instance Logging.instance
.log("Starting buildTransaction ----------", level: LogLevel.Info); .log("Starting buildTransaction ----------", level: LogLevel.Info);
final txb = TransactionBuilder(network: network); final txb = TransactionBuilder(
network: network,
maximumFeeRate: 2500000, // 1000x default value in bitcoindart lib
);
txb.setVersion(1); txb.setVersion(1);
// Add transaction inputs // Add transaction inputs

View file

@ -1,14 +1,17 @@
import 'dart:math'; import 'dart:math';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
class FeeSlider extends StatefulWidget { class FeeSlider extends StatefulWidget {
const FeeSlider({ const FeeSlider({
super.key, super.key,
required this.onSatVByteChanged, required this.onSatVByteChanged,
required this.coin,
}); });
final Coin coin;
final void Function(int) onSatVByteChanged; final void Function(int) onSatVByteChanged;
@override @override
@ -16,12 +19,12 @@ class FeeSlider extends StatefulWidget {
} }
class _FeeSliderState extends State<FeeSlider> { class _FeeSliderState extends State<FeeSlider> {
static const int min = 1; static const double min = 1;
static const int max = 4; static const double max = 4;
double sliderValue = 0; double sliderValue = 0;
int rate = min; int rate = min.toInt();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -45,7 +48,14 @@ class _FeeSliderState extends State<FeeSlider> {
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
sliderValue = value; sliderValue = value;
rate = pow(sliderValue * (max - min) + min, 4).toInt(); final number = pow(sliderValue * (max - min) + min, 4).toDouble();
switch (widget.coin) {
case Coin.dogecoin:
case Coin.dogecoinTestNet:
rate = (number * 1000).toInt();
default:
rate = number.toInt();
}
}); });
widget.onSatVByteChanged(rate); widget.onSatVByteChanged(rate);
}, },