Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/pages/send_view/send_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ class _SendViewState extends ConsumerState<SendView> {
),
) &&
ref.watch(pWallets).getWallet(walletId) is CoinControlInterface &&
balType == BalanceType.public;
(showPrivateBalance ? balType == BalanceType.public : true);

final isExchangeAddress = ref.watch(pIsExchangeAddress);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
),
) &&
ref.watch(pWallets).getWallet(walletId) is CoinControlInterface &&
balType == BalanceType.public;
(showPrivateBalance ? balType == BalanceType.public : true);

return Column(
crossAxisAlignment: CrossAxisAlignment.start,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,15 @@ class _DesktopSendFeeFormState extends ConsumerState<DesktopSendFeeForm> {

bool get isEth => cryptoCurrency is Ethereum;

bool isCustomFee = false;
bool _isCustomFeeValue = false;
bool get _isCustomFee => _isCustomFeeValue;
set _isCustomFee(bool newValue) {
if (_isCustomFeeValue != newValue) {
_isCustomFeeValue = newValue;
widget.onCustomFeeOptionChanged.call(_isCustomFeeValue);
}
}

(FeeRateType, String?, String?)? feeSelectionResult;

@override
Expand Down Expand Up @@ -97,12 +105,12 @@ class _DesktopSendFeeFormState extends ConsumerState<DesktopSendFeeForm> {
);

if (feeSelectionResult != null) {
if (isCustomFee &&
if (_isCustomFee &&
feeSelectionResult!.$1 != FeeRateType.custom) {
isCustomFee = false;
} else if (!isCustomFee &&
_isCustomFee = false;
} else if (!_isCustomFee &&
feeSelectionResult!.$1 == FeeRateType.custom) {
isCustomFee = true;
_isCustomFee = true;
}
}

Expand All @@ -113,7 +121,7 @@ class _DesktopSendFeeFormState extends ConsumerState<DesktopSendFeeForm> {
),
child: Text(
"Transaction fee"
"${isCustomFee ? "" : " (${isEth ? "max" : "estimated"})"}",
"${_isCustomFee ? "" : " (${isEth ? "max" : "estimated"})"}",
style: STextStyles.desktopTextExtraSmall(context).copyWith(
color:
Theme.of(
Expand All @@ -124,7 +132,7 @@ class _DesktopSendFeeFormState extends ConsumerState<DesktopSendFeeForm> {
),
),
const SizedBox(height: 10),
if (!isCustomFee)
if (!_isCustomFee)
Padding(
padding: const EdgeInsets.all(10),
child:
Expand Down Expand Up @@ -275,7 +283,7 @@ class _DesktopSendFeeFormState extends ConsumerState<DesktopSendFeeForm> {
],
),
),
if (isCustomFee && isEth)
if (_isCustomFee && isEth)
EthFeeForm(
minGasLimit:
widget.isToken
Expand All @@ -284,7 +292,7 @@ class _DesktopSendFeeFormState extends ConsumerState<DesktopSendFeeForm> {
stateChanged:
(value) => widget.onCustomEip1559FeeOptionChanged?.call(value),
),
if (isCustomFee && !isEth)
if (_isCustomFee && !isEth)
Padding(
padding: const EdgeInsets.only(bottom: 12, top: 16),
child: FeeSlider(
Expand Down
1 change: 1 addition & 0 deletions lib/wallets/crypto_currency/coins/bitcoin_frost.dart
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ class BitcoinFrost extends FrostCurrency {
final clAddress = cl.Address.fromString(address, networkParams);

return switch (clAddress) {
cl.P2TRAddress() => AddressType.p2tr,
cl.P2PKHAddress() => AddressType.p2pkh,
cl.P2WSHAddress() => AddressType.p2sh,
cl.P2WPKHAddress() => AddressType.p2wpkh,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ mixin ElectrumXCurrencyInterface on Bip39HDCurrency {
cl.P2PKHAddress() => AddressType.p2pkh,
cl.P2WSHAddress() => AddressType.p2sh,
cl.P2WPKHAddress() => AddressType.p2wpkh,
cl.P2TRAddress() => AddressType.p2tr,
cl.MwebAddress() => AddressType.mweb,
_ => null,
};
Expand Down
76 changes: 34 additions & 42 deletions lib/wallets/wallet/wallet_mixin_interfaces/mweb_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,28 @@ mixin MwebInterface<T extends ElectrumXCurrencyInterface>
(e) => e.outputId.equals(utxo.outputId),
)).getSingleOrNull();

final newUtxo = MwebUtxosCompanion(
outputId: Value(prev?.outputId ?? utxo.outputId),
address: Value(prev?.address ?? utxo.address),
value: Value(utxo.value.toInt()),
height: Value(utxo.height),
blockTime: Value(utxo.blockTime),
blocked: Value(prev?.blocked ?? false),
used: Value(prev?.used ?? false),
);
if (prev == null) {
final newUtxo = MwebUtxosCompanion(
outputId: Value(utxo.outputId),
address: Value(utxo.address),
value: Value(utxo.value.toInt()),
height: Value(utxo.height),
blockTime: Value(utxo.blockTime),
blocked: const Value(false),
used: const Value(false),
);

await db.into(db.mwebUtxos).insertOnConflictUpdate(newUtxo);
await db.into(db.mwebUtxos).insert(newUtxo);
} else {
await db
.update(db.mwebUtxos)
.replace(
prev.copyWith(
blockTime: utxo.blockTime,
height: utxo.height,
),
);
}
});

Address? addr = await mainDB.getAddress(walletId, utxo.address);
Expand Down Expand Up @@ -469,7 +480,19 @@ mixin MwebInterface<T extends ElectrumXCurrencyInterface>
);

// Update used mweb utxos as used in database
await _checkSpentMwebUtxos();
final usedMwebUtxos =
txData.usedUTXOs!.whereType<MwebInput>().map((e) => e.utxo).toList();

Logging.instance.i("Used mweb inputs: $usedMwebUtxos");

if (usedMwebUtxos.isNotEmpty) {
final db = Drift.get(walletId);
await db.transaction(() async {
for (final used in usedMwebUtxos) {
await db.update(db.mwebUtxos).replace(used);
}
});
}

return await updateSentCachedTxData(txData: txData);
} catch (e, s) {
Expand Down Expand Up @@ -583,35 +606,6 @@ mixin MwebInterface<T extends ElectrumXCurrencyInterface>
}
}

Future<void> _checkSpentMwebUtxos() async {
try {
final db = Drift.get(walletId);
final mwebUtxos = await db.select(db.mwebUtxos).get();

final client = await _client;

final spent = await client.spent(
SpentRequest(outputId: mwebUtxos.map((e) => e.outputId)),
);

await db.transaction(() async {
for (final utxo in mwebUtxos) {
await db
.into(db.mwebUtxos)
.insertOnConflictUpdate(
utxo
.toCompanion(false)
.copyWith(
used: Value(spent.outputId.contains(utxo.outputId)),
),
);
}
});
} catch (e, s) {
Logging.instance.e("_checkSpentMwebUtxos()", error: e, stackTrace: s);
}
}

Future<void> _checkAddresses() async {
// check change first as it is index 0
Address? changeAddress = await getMwebChangeAddress();
Expand Down Expand Up @@ -667,8 +661,6 @@ mixin MwebInterface<T extends ElectrumXCurrencyInterface>
if (info.isMwebEnabled) {
final start = DateTime.now();
try {
await _checkSpentMwebUtxos();

final currentHeight = await chainHeight;
final db = Drift.get(walletId);
final mwebUtxos =
Expand Down
12 changes: 6 additions & 6 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -532,18 +532,18 @@ packages:
dependency: "direct main"
description:
name: cs_salvium
sha256: "5711a9b547e9e5ba1d91e1c6b37ba94803b0b7c6ef56baf245b270e2a637b839"
sha256: "838a2f21b0ad567f68a5294360c4c96727b722037ae7bfdc26651c99d6c26bd3"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
version: "1.2.1"
cs_salvium_flutter_libs:
dependency: "direct main"
description:
name: cs_salvium_flutter_libs
sha256: cb2759e3d0829251cb13daa9e012f7821d9717ec1f1dedc9329c4012f99f386c
sha256: d1e49ed67632f77d863ad3eafc78db8867f155cf9decf156345ec75c92e0d026
url: "https://pub.dev"
source: hosted
version: "1.0.2"
version: "1.0.4"
cs_salvium_flutter_libs_android:
dependency: transitive
description:
Expand Down Expand Up @@ -580,10 +580,10 @@ packages:
dependency: transitive
description:
name: cs_salvium_flutter_libs_ios
sha256: "4c11cc7499ca7d3a8c0f2b29fcb4eaf4cd1475c5752f34856a3d4c0b721a6319"
sha256: "54d18fbac60c8a602e4d0f967ea7d02fab71bff3e032f9576e159229ce372534"
url: "https://pub.dev"
source: hosted
version: "1.0.1"
version: "1.1.1"
cs_salvium_flutter_libs_linux:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions scripts/app_config/templates/pubspec.template
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ dependencies:
drift: ^2.22.1
drift_flutter: ^0.2.3
path: ^1.9.1
cs_salvium: ^1.2.0
cs_salvium_flutter_libs: ^1.0.2
cs_salvium: ^1.2.1
cs_salvium_flutter_libs: ^1.0.4
flutter_mwebd: ^0.0.1-pre.6
mweb_client: ^0.2.0
fixnum: ^1.1.1
Expand Down
Loading