mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 19:49:22 +00:00
fix custom rate issue (#1579)
Some checks are pending
Cache Dependencies / test (push) Waiting to run
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:
parent
14e99daa73
commit
acadee6ed5
5 changed files with 19 additions and 6 deletions
|
@ -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
|
@override
|
||||||
int getMaxCustomFeeRate(Object wallet) {
|
int getMaxCustomFeeRate(Object wallet) {
|
||||||
final bitcoinWallet = wallet as ElectrumWallet;
|
final bitcoinWallet = wallet as ElectrumWallet;
|
||||||
|
|
|
@ -17,7 +17,7 @@ class StandardPickerListItem<T> extends TransactionDetailsListItem {
|
||||||
final List<T> items;
|
final List<T> items;
|
||||||
final String Function(T item, double sliderValue) displayItem;
|
final String Function(T item, double sliderValue) displayItem;
|
||||||
final Function(double) onSliderChanged;
|
final Function(double) onSliderChanged;
|
||||||
final Function(T) onItemSelected;
|
final Function(T item, double sliderValue) onItemSelected;
|
||||||
final int selectedIdx;
|
final int selectedIdx;
|
||||||
final double? maxValue;
|
final double? maxValue;
|
||||||
final int customItemIndex;
|
final int customItemIndex;
|
||||||
|
|
|
@ -23,7 +23,7 @@ class StandardPickerList<T> extends StatefulWidget {
|
||||||
final int customItemIndex;
|
final int customItemIndex;
|
||||||
final String Function(T item, double sliderValue) displayItem;
|
final String Function(T item, double sliderValue) displayItem;
|
||||||
final Function(double) onSliderChanged;
|
final Function(double) onSliderChanged;
|
||||||
final Function(T) onItemSelected;
|
final Function(T item, double sliderValue) onItemSelected;
|
||||||
final String value;
|
final String value;
|
||||||
final int selectedIdx;
|
final int selectedIdx;
|
||||||
final double customValue;
|
final double customValue;
|
||||||
|
@ -50,6 +50,7 @@ class _StandardPickerListState<T> extends State<StandardPickerList<T>> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
String adaptedDisplayItem(T item) => widget.displayItem(item, customValue);
|
String adaptedDisplayItem(T item) => widget.displayItem(item, customValue);
|
||||||
|
String adaptedOnItemSelected(T item) => widget.onItemSelected(item, customValue).toString();
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
|
@ -74,7 +75,7 @@ class _StandardPickerListState<T> extends State<StandardPickerList<T>> {
|
||||||
},
|
},
|
||||||
onItemSelected: (T item) {
|
onItemSelected: (T item) {
|
||||||
setState(() => selectedIdx = widget.items.indexOf(item));
|
setState(() => selectedIdx = widget.items.indexOf(item));
|
||||||
value = widget.onItemSelected(item).toString();
|
value = adaptedOnItemSelected(item);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -378,9 +378,9 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||||
sendViewModel.displayFeeRate(priority, sliderValue.round()),
|
sendViewModel.displayFeeRate(priority, sliderValue.round()),
|
||||||
onSliderChanged: (double newValue) =>
|
onSliderChanged: (double newValue) =>
|
||||||
setNewFee(value: newValue, priority: transactionPriority!),
|
setNewFee(value: newValue, priority: transactionPriority!),
|
||||||
onItemSelected: (dynamic item) {
|
onItemSelected: (dynamic item, double sliderValue) {
|
||||||
transactionPriority = item as TransactionPriority;
|
transactionPriority = item as TransactionPriority;
|
||||||
return setNewFee(priority: transactionPriority!);
|
return setNewFee(value: sliderValue, priority: transactionPriority!);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (transactionInfo.inputAddresses != null) {
|
if (transactionInfo.inputAddresses != null) {
|
||||||
|
@ -427,7 +427,11 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||||
|
|
||||||
String setNewFee({double? value, required TransactionPriority priority}) {
|
String setNewFee({double? value, required TransactionPriority priority}) {
|
||||||
newFee = priority == bitcoin!.getBitcoinTransactionPriorityCustom() && value != null
|
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(
|
: bitcoin!.getFeeAmountForPriority(
|
||||||
wallet,
|
wallet,
|
||||||
priority,
|
priority,
|
||||||
|
|
|
@ -210,6 +210,7 @@ abstract class Bitcoin {
|
||||||
int getFeeAmountForPriority(Object wallet, TransactionPriority priority, int inputsCount, int outputsCount, {int? size});
|
int getFeeAmountForPriority(Object wallet, TransactionPriority priority, int inputsCount, int outputsCount, {int? size});
|
||||||
int getEstimatedFeeWithFeeRate(Object wallet, int feeRate, int? amount,
|
int getEstimatedFeeWithFeeRate(Object wallet, int feeRate, int? amount,
|
||||||
{int? outputsCount, int? size});
|
{int? outputsCount, int? size});
|
||||||
|
int feeAmountWithFeeRate(Object wallet, int feeRate, int inputsCount, int outputsCount, {int? size});
|
||||||
int getHeightByDate({required DateTime date});
|
int getHeightByDate({required DateTime date});
|
||||||
Future<void> rescan(Object wallet, {required int height, bool? doSingleScan});
|
Future<void> rescan(Object wallet, {required int height, bool? doSingleScan});
|
||||||
Future<bool> getNodeIsElectrsSPEnabled(Object wallet);
|
Future<bool> getNodeIsElectrsSPEnabled(Object wallet);
|
||||||
|
|
Loading…
Reference in a new issue