prevent transactions with < 6 confirmations from being used + hide mweb balances if mweb is off

This commit is contained in:
Matthew Fosse 2024-09-19 17:15:37 -07:00
parent 0cd21f2fb6
commit 7ee8949a71
3 changed files with 35 additions and 4 deletions

View file

@ -859,6 +859,36 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
feeRatePerKb: Int64.parseInt(tx.feeRate) * 1000,
));
final tx2 = BtcTransaction.fromRaw(hex.encode(resp.rawTx));
// check if any of the inputs of this transaction are hog-ex:
tx2.inputs.forEach((txInput) {
bool isHogEx = true;
final utxo = unspentCoins
.firstWhere((utxo) => utxo.hash == txInput.txId && utxo.vout == txInput.txIndex);
if (txInput.sequence.isEmpty) {
isHogEx = false;
}
// TODO: detect actual hog-ex inputs
// print(txInput.sequence);
// print(txInput.txIndex);
// print(utxo.value);
if (!isHogEx) {
return;
}
int confirmations = utxo.confirmations ?? 0;
if (confirmations < 6) {
throw Exception(
"A transaction input has less than 6 confirmations, please try again later.");
}
});
throw Exception("Not finished!");
tx.hexOverride = tx2
.copyWith(
witnesses: tx2.inputs.asMap().entries.map((e) {

View file

@ -369,14 +369,14 @@ abstract class BalanceViewModelBase with Store {
}
bool _hasSecondAdditionalBalanceForWalletType(WalletType type) {
if (wallet.type == WalletType.litecoin /*&& settingsStore.mwebEnabled*/) {
if (wallet.type == WalletType.litecoin && settingsStore.mwebEnabled) {
return true;
}
return false;
}
bool _hasSecondAvailableBalanceForWalletType(WalletType type) {
if (wallet.type == WalletType.litecoin /*&& settingsStore.mwebEnabled*/) {
if (wallet.type == WalletType.litecoin && settingsStore.mwebEnabled) {
return true;
}
return false;

View file

@ -132,8 +132,8 @@ abstract class DashboardViewModelBase with Store {
FilterItem(
value: () => tradeFilterStore.displayLetsExchange,
caption: ExchangeProviderDescription.letsExchange.title,
onChanged: () =>
tradeFilterStore.toggleDisplayExchange(ExchangeProviderDescription.letsExchange)),
onChanged: () => tradeFilterStore
.toggleDisplayExchange(ExchangeProviderDescription.letsExchange)),
FilterItem(
value: () => tradeFilterStore.displayStealthEx,
caption: ExchangeProviderDescription.stealthEx.title,
@ -443,6 +443,7 @@ abstract class DashboardViewModelBase with Store {
settingsStore.hasEnabledMwebBefore = true;
}
settingsStore.mwebEnabled = active;
mwebScanningActive = active;
bitcoin!.setMwebEnabled(wallet, active);
}