Skip to content

Commit 6bdf43b

Browse files
Merge pull request #1159 from cypherstack/bug-fixes
Bug fixes
2 parents 2d90943 + a8dd5eb commit 6bdf43b

File tree

8 files changed

+63
-61
lines changed

8 files changed

+63
-61
lines changed

lib/pages/send_view/send_view.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,7 @@ class _SendViewState extends ConsumerState<SendView> {
12221222
),
12231223
) &&
12241224
ref.watch(pWallets).getWallet(walletId) is CoinControlInterface &&
1225-
balType == BalanceType.public;
1225+
(showPrivateBalance ? balType == BalanceType.public : true);
12261226

12271227
final isExchangeAddress = ref.watch(pIsExchangeAddress);
12281228

lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
10521052
),
10531053
) &&
10541054
ref.watch(pWallets).getWallet(walletId) is CoinControlInterface &&
1055-
balType == BalanceType.public;
1055+
(showPrivateBalance ? balType == BalanceType.public : true);
10561056

10571057
return Column(
10581058
crossAxisAlignment: CrossAxisAlignment.start,

lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send_fee_form.dart

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,15 @@ class _DesktopSendFeeFormState extends ConsumerState<DesktopSendFeeForm> {
5555

5656
bool get isEth => cryptoCurrency is Ethereum;
5757

58-
bool isCustomFee = false;
58+
bool _isCustomFeeValue = false;
59+
bool get _isCustomFee => _isCustomFeeValue;
60+
set _isCustomFee(bool newValue) {
61+
if (_isCustomFeeValue != newValue) {
62+
_isCustomFeeValue = newValue;
63+
widget.onCustomFeeOptionChanged.call(_isCustomFeeValue);
64+
}
65+
}
66+
5967
(FeeRateType, String?, String?)? feeSelectionResult;
6068

6169
@override
@@ -97,12 +105,12 @@ class _DesktopSendFeeFormState extends ConsumerState<DesktopSendFeeForm> {
97105
);
98106

99107
if (feeSelectionResult != null) {
100-
if (isCustomFee &&
108+
if (_isCustomFee &&
101109
feeSelectionResult!.$1 != FeeRateType.custom) {
102-
isCustomFee = false;
103-
} else if (!isCustomFee &&
110+
_isCustomFee = false;
111+
} else if (!_isCustomFee &&
104112
feeSelectionResult!.$1 == FeeRateType.custom) {
105-
isCustomFee = true;
113+
_isCustomFee = true;
106114
}
107115
}
108116

@@ -113,7 +121,7 @@ class _DesktopSendFeeFormState extends ConsumerState<DesktopSendFeeForm> {
113121
),
114122
child: Text(
115123
"Transaction fee"
116-
"${isCustomFee ? "" : " (${isEth ? "max" : "estimated"})"}",
124+
"${_isCustomFee ? "" : " (${isEth ? "max" : "estimated"})"}",
117125
style: STextStyles.desktopTextExtraSmall(context).copyWith(
118126
color:
119127
Theme.of(
@@ -124,7 +132,7 @@ class _DesktopSendFeeFormState extends ConsumerState<DesktopSendFeeForm> {
124132
),
125133
),
126134
const SizedBox(height: 10),
127-
if (!isCustomFee)
135+
if (!_isCustomFee)
128136
Padding(
129137
padding: const EdgeInsets.all(10),
130138
child:
@@ -275,7 +283,7 @@ class _DesktopSendFeeFormState extends ConsumerState<DesktopSendFeeForm> {
275283
],
276284
),
277285
),
278-
if (isCustomFee && isEth)
286+
if (_isCustomFee && isEth)
279287
EthFeeForm(
280288
minGasLimit:
281289
widget.isToken
@@ -284,7 +292,7 @@ class _DesktopSendFeeFormState extends ConsumerState<DesktopSendFeeForm> {
284292
stateChanged:
285293
(value) => widget.onCustomEip1559FeeOptionChanged?.call(value),
286294
),
287-
if (isCustomFee && !isEth)
295+
if (_isCustomFee && !isEth)
288296
Padding(
289297
padding: const EdgeInsets.only(bottom: 12, top: 16),
290298
child: FeeSlider(

lib/wallets/crypto_currency/coins/bitcoin_frost.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ class BitcoinFrost extends FrostCurrency {
255255
final clAddress = cl.Address.fromString(address, networkParams);
256256

257257
return switch (clAddress) {
258+
cl.P2TRAddress() => AddressType.p2tr,
258259
cl.P2PKHAddress() => AddressType.p2pkh,
259260
cl.P2WSHAddress() => AddressType.p2sh,
260261
cl.P2WPKHAddress() => AddressType.p2wpkh,

lib/wallets/crypto_currency/interfaces/electrumx_currency_interface.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ mixin ElectrumXCurrencyInterface on Bip39HDCurrency {
1818
cl.P2PKHAddress() => AddressType.p2pkh,
1919
cl.P2WSHAddress() => AddressType.p2sh,
2020
cl.P2WPKHAddress() => AddressType.p2wpkh,
21+
cl.P2TRAddress() => AddressType.p2tr,
2122
cl.MwebAddress() => AddressType.mweb,
2223
_ => null,
2324
};

lib/wallets/wallet/wallet_mixin_interfaces/mweb_interface.dart

Lines changed: 34 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,28 @@ mixin MwebInterface<T extends ElectrumXCurrencyInterface>
216216
(e) => e.outputId.equals(utxo.outputId),
217217
)).getSingleOrNull();
218218

219-
final newUtxo = MwebUtxosCompanion(
220-
outputId: Value(prev?.outputId ?? utxo.outputId),
221-
address: Value(prev?.address ?? utxo.address),
222-
value: Value(utxo.value.toInt()),
223-
height: Value(utxo.height),
224-
blockTime: Value(utxo.blockTime),
225-
blocked: Value(prev?.blocked ?? false),
226-
used: Value(prev?.used ?? false),
227-
);
219+
if (prev == null) {
220+
final newUtxo = MwebUtxosCompanion(
221+
outputId: Value(utxo.outputId),
222+
address: Value(utxo.address),
223+
value: Value(utxo.value.toInt()),
224+
height: Value(utxo.height),
225+
blockTime: Value(utxo.blockTime),
226+
blocked: const Value(false),
227+
used: const Value(false),
228+
);
228229

229-
await db.into(db.mwebUtxos).insertOnConflictUpdate(newUtxo);
230+
await db.into(db.mwebUtxos).insert(newUtxo);
231+
} else {
232+
await db
233+
.update(db.mwebUtxos)
234+
.replace(
235+
prev.copyWith(
236+
blockTime: utxo.blockTime,
237+
height: utxo.height,
238+
),
239+
);
240+
}
230241
});
231242

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

471482
// Update used mweb utxos as used in database
472-
await _checkSpentMwebUtxos();
483+
final usedMwebUtxos =
484+
txData.usedUTXOs!.whereType<MwebInput>().map((e) => e.utxo).toList();
485+
486+
Logging.instance.i("Used mweb inputs: $usedMwebUtxos");
487+
488+
if (usedMwebUtxos.isNotEmpty) {
489+
final db = Drift.get(walletId);
490+
await db.transaction(() async {
491+
for (final used in usedMwebUtxos) {
492+
await db.update(db.mwebUtxos).replace(used);
493+
}
494+
});
495+
}
473496

474497
return await updateSentCachedTxData(txData: txData);
475498
} catch (e, s) {
@@ -583,35 +606,6 @@ mixin MwebInterface<T extends ElectrumXCurrencyInterface>
583606
}
584607
}
585608

586-
Future<void> _checkSpentMwebUtxos() async {
587-
try {
588-
final db = Drift.get(walletId);
589-
final mwebUtxos = await db.select(db.mwebUtxos).get();
590-
591-
final client = await _client;
592-
593-
final spent = await client.spent(
594-
SpentRequest(outputId: mwebUtxos.map((e) => e.outputId)),
595-
);
596-
597-
await db.transaction(() async {
598-
for (final utxo in mwebUtxos) {
599-
await db
600-
.into(db.mwebUtxos)
601-
.insertOnConflictUpdate(
602-
utxo
603-
.toCompanion(false)
604-
.copyWith(
605-
used: Value(spent.outputId.contains(utxo.outputId)),
606-
),
607-
);
608-
}
609-
});
610-
} catch (e, s) {
611-
Logging.instance.e("_checkSpentMwebUtxos()", error: e, stackTrace: s);
612-
}
613-
}
614-
615609
Future<void> _checkAddresses() async {
616610
// check change first as it is index 0
617611
Address? changeAddress = await getMwebChangeAddress();
@@ -667,8 +661,6 @@ mixin MwebInterface<T extends ElectrumXCurrencyInterface>
667661
if (info.isMwebEnabled) {
668662
final start = DateTime.now();
669663
try {
670-
await _checkSpentMwebUtxos();
671-
672664
final currentHeight = await chainHeight;
673665
final db = Drift.get(walletId);
674666
final mwebUtxos =

pubspec.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -532,18 +532,18 @@ packages:
532532
dependency: "direct main"
533533
description:
534534
name: cs_salvium
535-
sha256: "5711a9b547e9e5ba1d91e1c6b37ba94803b0b7c6ef56baf245b270e2a637b839"
535+
sha256: "838a2f21b0ad567f68a5294360c4c96727b722037ae7bfdc26651c99d6c26bd3"
536536
url: "https://pub.dev"
537537
source: hosted
538-
version: "1.2.0"
538+
version: "1.2.1"
539539
cs_salvium_flutter_libs:
540540
dependency: "direct main"
541541
description:
542542
name: cs_salvium_flutter_libs
543-
sha256: cb2759e3d0829251cb13daa9e012f7821d9717ec1f1dedc9329c4012f99f386c
543+
sha256: d1e49ed67632f77d863ad3eafc78db8867f155cf9decf156345ec75c92e0d026
544544
url: "https://pub.dev"
545545
source: hosted
546-
version: "1.0.2"
546+
version: "1.0.4"
547547
cs_salvium_flutter_libs_android:
548548
dependency: transitive
549549
description:
@@ -580,10 +580,10 @@ packages:
580580
dependency: transitive
581581
description:
582582
name: cs_salvium_flutter_libs_ios
583-
sha256: "4c11cc7499ca7d3a8c0f2b29fcb4eaf4cd1475c5752f34856a3d4c0b721a6319"
583+
sha256: "54d18fbac60c8a602e4d0f967ea7d02fab71bff3e032f9576e159229ce372534"
584584
url: "https://pub.dev"
585585
source: hosted
586-
version: "1.0.1"
586+
version: "1.1.1"
587587
cs_salvium_flutter_libs_linux:
588588
dependency: transitive
589589
description:

scripts/app_config/templates/pubspec.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ dependencies:
222222
drift: ^2.22.1
223223
drift_flutter: ^0.2.3
224224
path: ^1.9.1
225-
cs_salvium: ^1.2.0
226-
cs_salvium_flutter_libs: ^1.0.2
225+
cs_salvium: ^1.2.1
226+
cs_salvium_flutter_libs: ^1.0.4
227227
flutter_mwebd: ^0.0.1-pre.6
228228
mweb_client: ^0.2.0
229229
fixnum: ^1.1.1

0 commit comments

Comments
 (0)