From ab9e734b8056a72982ab450283c7a2b788834f62 Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 4 Jul 2023 10:25:13 -0600 Subject: [PATCH] fix: dogecoin custom fee slider and possible absurd fees error --- lib/pages/send_view/send_view.dart | 1 + .../wallet_view/sub_widgets/desktop_send.dart | 1 + .../coins/dogecoin/dogecoin_wallet.dart | 5 ++++- lib/widgets/fee_slider.dart | 18 ++++++++++++++---- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/pages/send_view/send_view.dart b/lib/pages/send_view/send_view.dart index 0f503588c..1570ea01d 100644 --- a/lib/pages/send_view/send_view.dart +++ b/lib/pages/send_view/send_view.dart @@ -2065,6 +2065,7 @@ class _SendViewState extends ConsumerState { top: 16, ), child: FeeSlider( + coin: coin, onSatVByteChanged: (rate) { customFeeRate = rate; }, diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart index a6d58c667..0488358a7 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart @@ -1564,6 +1564,7 @@ class _DesktopSendState extends ConsumerState { top: 16, ), child: FeeSlider( + coin: coin, onSatVByteChanged: (rate) { customFeeRate = rate; }, diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index bfb8251bc..754834ad1 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -2665,7 +2665,10 @@ class DogecoinWallet extends CoinServiceAPI Logging.instance .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); // Add transaction inputs diff --git a/lib/widgets/fee_slider.dart b/lib/widgets/fee_slider.dart index 118cd7a85..d125988f3 100644 --- a/lib/widgets/fee_slider.dart +++ b/lib/widgets/fee_slider.dart @@ -1,14 +1,17 @@ import 'dart:math'; import 'package:flutter/material.dart'; +import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/text_styles.dart'; class FeeSlider extends StatefulWidget { const FeeSlider({ super.key, required this.onSatVByteChanged, + required this.coin, }); + final Coin coin; final void Function(int) onSatVByteChanged; @override @@ -16,12 +19,12 @@ class FeeSlider extends StatefulWidget { } class _FeeSliderState extends State { - static const int min = 1; - static const int max = 4; + static const double min = 1; + static const double max = 4; double sliderValue = 0; - int rate = min; + int rate = min.toInt(); @override Widget build(BuildContext context) { @@ -45,7 +48,14 @@ class _FeeSliderState extends State { onChanged: (value) { setState(() { 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); },