mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-09-29 18:01:06 +00:00
no need to fetch address if it already exists
This commit is contained in:
parent
c0389d2da7
commit
86c33d4cb5
1 changed files with 21 additions and 19 deletions
|
@ -2668,28 +2668,30 @@ class BitcoinCashWallet extends CoinServiceAPI
|
||||||
try {
|
try {
|
||||||
// Populating the addresses to check
|
// Populating the addresses to check
|
||||||
for (var i = 0; i < utxosToUse.length; i++) {
|
for (var i = 0; i < utxosToUse.length; i++) {
|
||||||
final txid = utxosToUse[i].txid;
|
if (utxosToUse[i].address == null) {
|
||||||
final tx = await _cachedElectrumXClient.getTransaction(
|
final txid = utxosToUse[i].txid;
|
||||||
txHash: txid,
|
final tx = await _cachedElectrumXClient.getTransaction(
|
||||||
coin: coin,
|
txHash: txid,
|
||||||
);
|
coin: coin,
|
||||||
|
);
|
||||||
|
|
||||||
for (final output in tx["vout"] as List) {
|
for (final output in tx["vout"] as List) {
|
||||||
final n = output["n"];
|
final n = output["n"];
|
||||||
if (n != null && n == utxosToUse[i].vout) {
|
if (n != null && n == utxosToUse[i].vout) {
|
||||||
String address =
|
String address =
|
||||||
output["scriptPubKey"]?["addresses"]?[0] as String? ??
|
output["scriptPubKey"]?["addresses"]?[0] as String? ??
|
||||||
output["scriptPubKey"]["address"] as String;
|
output["scriptPubKey"]["address"] as String;
|
||||||
if (bitbox.Address.detectFormat(address) !=
|
if (bitbox.Address.detectFormat(address) !=
|
||||||
bitbox.Address.formatCashAddr) {
|
bitbox.Address.formatCashAddr) {
|
||||||
try {
|
try {
|
||||||
address = bitbox.Address.toCashAddress(address);
|
address = bitbox.Address.toCashAddress(address);
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
rethrow;
|
rethrow;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
utxosToUse[i] = utxosToUse[i].copyWith(address: address);
|
utxosToUse[i] = utxosToUse[i].copyWith(address: address);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue