mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 20:09:23 +00:00
update ref and check for lolcashaddr formatting
This commit is contained in:
parent
c6010c00ae
commit
761d914bca
2 changed files with 22 additions and 10 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 2908a9599c0f15e04e14d90e3303bb84e83de121
|
Subproject commit 418d07c870c36ddf89398f58c3e57893e3efee79
|
|
@ -2,6 +2,7 @@ import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
|
import 'package:bitbox/bitbox.dart' as bitbox;
|
||||||
import 'package:bitcoindart/bitcoindart.dart' as btcdart;
|
import 'package:bitcoindart/bitcoindart.dart' as btcdart;
|
||||||
import 'package:fusiondart/fusiondart.dart' as fusion;
|
import 'package:fusiondart/fusiondart.dart' as fusion;
|
||||||
import 'package:isar/isar.dart';
|
import 'package:isar/isar.dart';
|
||||||
|
@ -12,6 +13,7 @@ import 'package:stackwallet/models/isar/models/isar_models.dart';
|
||||||
import 'package:stackwallet/services/fusion_tor_service.dart';
|
import 'package:stackwallet/services/fusion_tor_service.dart';
|
||||||
import 'package:stackwallet/utilities/bip32_utils.dart';
|
import 'package:stackwallet/utilities/bip32_utils.dart';
|
||||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
|
import 'package:stackwallet/utilities/logger.dart';
|
||||||
import 'package:stackwallet/utilities/stack_file_system.dart';
|
import 'package:stackwallet/utilities/stack_file_system.dart';
|
||||||
|
|
||||||
const String kReservedFusionAddress = "reserved_fusion_address";
|
const String kReservedFusionAddress = "reserved_fusion_address";
|
||||||
|
@ -285,22 +287,32 @@ mixin FusionWalletInterface {
|
||||||
|
|
||||||
// Loop through UTXOs, checking and adding valid ones.
|
// Loop through UTXOs, checking and adding valid ones.
|
||||||
for (final utxo in walletUtxos) {
|
for (final utxo in walletUtxos) {
|
||||||
// Check if address is available.
|
final String addressString = utxo.address!;
|
||||||
if (utxo.address == null) {
|
final List<String> possibleAddresses = [addressString];
|
||||||
// A utxo object should always have a non null address.
|
|
||||||
throw Exception("UTXO ${utxo.txid}:${utxo.vout} address is null");
|
if (bitbox.Address.detectFormat(addressString) ==
|
||||||
|
bitbox.Address.formatCashAddr) {
|
||||||
|
possibleAddresses.add(bitbox.Address.toLegacyAddress(addressString));
|
||||||
|
} else {
|
||||||
|
possibleAddresses.add(bitbox.Address.toCashAddress(addressString));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find public key.
|
// Find public key.
|
||||||
final addr = await _db.getAddress(_walletId, utxo.address!);
|
final addr = await _db
|
||||||
|
.getAddresses(_walletId)
|
||||||
|
.filter()
|
||||||
|
.anyOf<String, QueryBuilder<Address, Address, QAfterFilterCondition>>(
|
||||||
|
possibleAddresses, (q, e) => q.valueEqualTo(e))
|
||||||
|
.findFirst();
|
||||||
|
|
||||||
if (addr == null) {
|
if (addr == null) {
|
||||||
// A utxo object should always have a non null address.
|
// A utxo object should always have a non null address.
|
||||||
fusion.Utilities.debugPrint(
|
// If non found then just ignore the UTXO (aka don't fuse it)
|
||||||
"UTXO ${utxo.txid}:${utxo.vout} address not found. TODO calculate it instead of continuing.",
|
Logging.instance.log(
|
||||||
|
"Missing address=\"$addressString\" while selecting UTXOs for Fusion",
|
||||||
|
level: LogLevel.Warning,
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
throw Exception("UTXO ${utxo.txid}:${utxo.vout} address not found");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final dto = fusion.UtxoDTO(
|
final dto = fusion.UtxoDTO(
|
||||||
|
@ -308,7 +320,7 @@ mixin FusionWalletInterface {
|
||||||
vout: utxo.vout,
|
vout: utxo.vout,
|
||||||
value: utxo.value,
|
value: utxo.value,
|
||||||
address: utxo.address!,
|
address: utxo.address!,
|
||||||
pubKey: addr!.publicKey,
|
pubKey: addr.publicKey,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add UTXO to coinList.
|
// Add UTXO to coinList.
|
||||||
|
|
Loading…
Reference in a new issue