fix custom rate issue (#1579)
Some checks are pending
Cache Dependencies / test (push) Waiting to run

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
Serhii 2024-08-10 00:49:27 +03:00 committed by GitHub
parent 14e99daa73
commit acadee6ed5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 19 additions and 6 deletions

View file

@ -435,6 +435,13 @@ class CWBitcoin extends Bitcoin {
);
}
@override
int feeAmountWithFeeRate(Object wallet, int feeRate, int inputsCount, int outputsCount,
{int? size}) {
final bitcoinWallet = wallet as ElectrumWallet;
return bitcoinWallet.feeAmountWithFeeRate(feeRate, inputsCount, outputsCount, size: size);
}
@override
int getMaxCustomFeeRate(Object wallet) {
final bitcoinWallet = wallet as ElectrumWallet;

View file

@ -17,7 +17,7 @@ class StandardPickerListItem<T> extends TransactionDetailsListItem {
final List<T> items;
final String Function(T item, double sliderValue) displayItem;
final Function(double) onSliderChanged;
final Function(T) onItemSelected;
final Function(T item, double sliderValue) onItemSelected;
final int selectedIdx;
final double? maxValue;
final int customItemIndex;

View file

@ -23,7 +23,7 @@ class StandardPickerList<T> extends StatefulWidget {
final int customItemIndex;
final String Function(T item, double sliderValue) displayItem;
final Function(double) onSliderChanged;
final Function(T) onItemSelected;
final Function(T item, double sliderValue) onItemSelected;
final String value;
final int selectedIdx;
final double customValue;
@ -50,6 +50,7 @@ class _StandardPickerListState<T> extends State<StandardPickerList<T>> {
@override
Widget build(BuildContext context) {
String adaptedDisplayItem(T item) => widget.displayItem(item, customValue);
String adaptedOnItemSelected(T item) => widget.onItemSelected(item, customValue).toString();
return Column(
children: [
@ -74,7 +75,7 @@ class _StandardPickerListState<T> extends State<StandardPickerList<T>> {
},
onItemSelected: (T item) {
setState(() => selectedIdx = widget.items.indexOf(item));
value = widget.onItemSelected(item).toString();
value = adaptedOnItemSelected(item);
},
),
),

View file

@ -378,9 +378,9 @@ abstract class TransactionDetailsViewModelBase with Store {
sendViewModel.displayFeeRate(priority, sliderValue.round()),
onSliderChanged: (double newValue) =>
setNewFee(value: newValue, priority: transactionPriority!),
onItemSelected: (dynamic item) {
onItemSelected: (dynamic item, double sliderValue) {
transactionPriority = item as TransactionPriority;
return setNewFee(priority: transactionPriority!);
return setNewFee(value: sliderValue, priority: transactionPriority!);
}));
if (transactionInfo.inputAddresses != null) {
@ -427,7 +427,11 @@ abstract class TransactionDetailsViewModelBase with Store {
String setNewFee({double? value, required TransactionPriority priority}) {
newFee = priority == bitcoin!.getBitcoinTransactionPriorityCustom() && value != null
? bitcoin!.getEstimatedFeeWithFeeRate(wallet, value.round(), transactionInfo.amount)
? bitcoin!.feeAmountWithFeeRate(
wallet,
value.round(),
transactionInfo.inputAddresses?.length ?? 1,
transactionInfo.outputAddresses?.length ?? 1)
: bitcoin!.getFeeAmountForPriority(
wallet,
priority,

View file

@ -210,6 +210,7 @@ abstract class Bitcoin {
int getFeeAmountForPriority(Object wallet, TransactionPriority priority, int inputsCount, int outputsCount, {int? size});
int getEstimatedFeeWithFeeRate(Object wallet, int feeRate, int? amount,
{int? outputsCount, int? size});
int feeAmountWithFeeRate(Object wallet, int feeRate, int inputsCount, int outputsCount, {int? size});
int getHeightByDate({required DateTime date});
Future<void> rescan(Object wallet, {required int height, bool? doSingleScan});
Future<bool> getNodeIsElectrsSPEnabled(Object wallet);