mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-11-27 11:24:14 +01:00
rbf-fixes-recomended-fee-rate (#1684)
* rbf fixes * Revert "rbf fixes" * fix replaced transactions * re-format electrum_wallet.dart [skip ci] * minor fixes [skip ci] --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
This commit is contained in:
@@ -764,6 +764,16 @@ abstract class DashboardViewModelBase with Store {
|
||||
}
|
||||
}
|
||||
|
||||
String getTransactionType(TransactionInfo tx) {
|
||||
if (wallet.type == WalletType.bitcoin) {
|
||||
if (tx.isReplaced == true) return ' (replaced)';
|
||||
}
|
||||
|
||||
if (wallet.type == WalletType.ethereum && tx.evmSignatureName == 'approval')
|
||||
return ' (${tx.evmSignatureName})';
|
||||
return '';
|
||||
}
|
||||
|
||||
Future<void> refreshDashboard() async {
|
||||
reconnect();
|
||||
}
|
||||
|
||||
@@ -36,7 +36,8 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||
required this.transactionDescriptionBox,
|
||||
required this.wallet,
|
||||
required this.settingsStore,
|
||||
required this.sendViewModel})
|
||||
required this.sendViewModel,
|
||||
this.canReplaceByFee = false})
|
||||
: items = [],
|
||||
RBFListItems = [],
|
||||
newFee = 0,
|
||||
@@ -51,8 +52,7 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||
break;
|
||||
case WalletType.bitcoin:
|
||||
_addElectrumListItems(tx, dateFormat);
|
||||
_addBumpFeesListItems(tx);
|
||||
_checkForRBF(tx);
|
||||
if(!canReplaceByFee)_checkForRBF(tx);
|
||||
break;
|
||||
case WalletType.litecoin:
|
||||
case WalletType.bitcoinCash:
|
||||
@@ -139,13 +139,11 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||
bool showRecipientAddress;
|
||||
bool isRecipientAddressShown;
|
||||
int newFee;
|
||||
String? rawTransaction;
|
||||
TransactionPriority? transactionPriority;
|
||||
|
||||
@observable
|
||||
bool _canReplaceByFee = false;
|
||||
|
||||
@computed
|
||||
bool get canReplaceByFee => _canReplaceByFee /*&& transactionInfo.confirmations <= 0*/;
|
||||
bool canReplaceByFee;
|
||||
|
||||
String _explorerUrl(WalletType type, String txId) {
|
||||
switch (type) {
|
||||
@@ -347,7 +345,7 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||
items.addAll(_items);
|
||||
}
|
||||
|
||||
void _addBumpFeesListItems(TransactionInfo tx) {
|
||||
void addBumpFeesListItems(TransactionInfo tx, String rawTransaction) {
|
||||
transactionPriority = bitcoin!.getBitcoinTransactionPriorityMedium();
|
||||
final inputsCount = (transactionInfo.inputAddresses?.isEmpty ?? true)
|
||||
? 1
|
||||
@@ -361,6 +359,14 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||
|
||||
RBFListItems.add(StandartListItem(title: S.current.old_fee, value: tx.feeFormatted() ?? '0.0'));
|
||||
|
||||
if (transactionInfo.fee != null && rawTransaction.isNotEmpty) {
|
||||
final size = bitcoin!.getTransactionVSize(wallet, rawTransaction);
|
||||
final recommendedRate = (transactionInfo.fee! / size).round() + 1;
|
||||
|
||||
RBFListItems.add(
|
||||
StandartListItem(title: 'New recommended fee rate', value: '$recommendedRate sat/byte'));
|
||||
}
|
||||
|
||||
final priorities = priorityForWalletType(wallet.type);
|
||||
final selectedItem = priorities.indexOf(sendViewModel.transactionPriority);
|
||||
final customItem = priorities
|
||||
@@ -429,8 +435,9 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||
Future<void> _checkForRBF(TransactionInfo tx) async {
|
||||
if (wallet.type == WalletType.bitcoin &&
|
||||
transactionInfo.direction == TransactionDirection.outgoing) {
|
||||
if (await bitcoin!.canReplaceByFee(wallet, tx)) {
|
||||
_canReplaceByFee = true;
|
||||
rawTransaction = await bitcoin!.canReplaceByFee(wallet, tx);
|
||||
if (rawTransaction != null) {
|
||||
canReplaceByFee = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user