fix custom rate issue (#1579)
Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
Serhii committed
Aug 10, 2024 at 00:49 UTC
acadee6ed54f58c8001b136ff4cf439894a8aed5
5 files changed
+19
-6
lib/bitcoin/cw_bitcoin.dart
+7
@@ -435,6 +435,13 @@ class CWBitcoin extends Bitcoin {
435
);
436
}
437
438
+ @override
439
+ int feeAmountWithFeeRate(Object wallet, int feeRate, int inputsCount, int outputsCount,
440
+ {int? size}) {
441
+ final bitcoinWallet = wallet as ElectrumWallet;
442
+ return bitcoinWallet.feeAmountWithFeeRate(feeRate, inputsCount, outputsCount, size: size);
443
+ }
444
+
445
@override
446
int getMaxCustomFeeRate(Object wallet) {
447
final bitcoinWallet = wallet as ElectrumWallet;
lib/src/screens/transaction_details/rbf_details_list_fee_picker_item.dart
+1
-1
@@ -17,7 +17,7 @@ class StandardPickerListItem<T> extends TransactionDetailsListItem {
17
final List<T> items;
18
final String Function(T item, double sliderValue) displayItem;
19
final Function(double) onSliderChanged;
20
- final Function(T) onItemSelected;
20
+ final Function(T item, double sliderValue) onItemSelected;
21
final int selectedIdx;
22
final double? maxValue;
23
final int customItemIndex;
lib/src/widgets/standard_picker_list.dart
+3
-2
@@ -23,7 +23,7 @@ class StandardPickerList<T> extends StatefulWidget {
23
final int customItemIndex;
24
final String Function(T item, double sliderValue) displayItem;
25
final Function(double) onSliderChanged;
26
- final Function(T) onItemSelected;
26
+ final Function(T item, double sliderValue) onItemSelected;
27
final String value;
28
final int selectedIdx;
29
final double customValue;
@@ -50,6 +50,7 @@ class _StandardPickerListState<T> extends State<StandardPickerList<T>> {
50
@override
51
Widget build(BuildContext context) {
52
String adaptedDisplayItem(T item) => widget.displayItem(item, customValue);
53
+ String adaptedOnItemSelected(T item) => widget.onItemSelected(item, customValue).toString();
54
55
return Column(
56
children: [
@@ -74,7 +75,7 @@ class _StandardPickerListState<T> extends State<StandardPickerList<T>> {
75
},
76
onItemSelected: (T item) {
77
setState(() => selectedIdx = widget.items.indexOf(item));
77
- value = widget.onItemSelected(item).toString();
78
+ value = adaptedOnItemSelected(item);
79
},
80
),
81
),
lib/view_model/transaction_details_view_model.dart
+7
-3
@@ -378,9 +378,9 @@ abstract class TransactionDetailsViewModelBase with Store {
378
sendViewModel.displayFeeRate(priority, sliderValue.round()),
379
onSliderChanged: (double newValue) =>
380
setNewFee(value: newValue, priority: transactionPriority!),
381
- onItemSelected: (dynamic item) {
381
+ onItemSelected: (dynamic item, double sliderValue) {
382
transactionPriority = item as TransactionPriority;
383
- return setNewFee(priority: transactionPriority!);
383
+ return setNewFee(value: sliderValue, priority: transactionPriority!);
384
}));
385
386
if (transactionInfo.inputAddresses != null) {
@@ -427,7 +427,11 @@ abstract class TransactionDetailsViewModelBase with Store {
427
428
String setNewFee({double? value, required TransactionPriority priority}) {
429
newFee = priority == bitcoin!.getBitcoinTransactionPriorityCustom() && value != null
430
- ? bitcoin!.getEstimatedFeeWithFeeRate(wallet, value.round(), transactionInfo.amount)
430
+ ? bitcoin!.feeAmountWithFeeRate(
431
+ wallet,
432
+ value.round(),
433
+ transactionInfo.inputAddresses?.length ?? 1,
434
+ transactionInfo.outputAddresses?.length ?? 1)
435
: bitcoin!.getFeeAmountForPriority(
436
wallet,
437
priority,
tool/configure.dart
+1
@@ -210,6 +210,7 @@ abstract class Bitcoin {
210
int getFeeAmountForPriority(Object wallet, TransactionPriority priority, int inputsCount, int outputsCount, {int? size});
211
int getEstimatedFeeWithFeeRate(Object wallet, int feeRate, int? amount,
212
{int? outputsCount, int? size});
213
+ int feeAmountWithFeeRate(Object wallet, int feeRate, int inputsCount, int outputsCount, {int? size});
214
int getHeightByDate({required DateTime date});
215
Future<void> rescan(Object wallet, {required int height, bool? doSingleScan});
216
Future<bool> getNodeIsElectrsSPEnabled(Object wallet);