From 593d2c7e7e4967fec0d1f9f7b64276d62a0ad17c Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 22 Sep 2023 17:00:32 -0600 Subject: [PATCH] named record params and clear variable names --- fusiondart | 2 +- .../mixins/fusion_wallet_interface.dart | 44 ++++++++++++------- pubspec.lock | 4 +- 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/fusiondart b/fusiondart index 929aedac5..e4877ee7c 160000 --- a/fusiondart +++ b/fusiondart @@ -1 +1 @@ -Subproject commit 929aedac530048ec23efcf23707506fcb0c79057 +Subproject commit e4877ee7cad443623e1486e27cb27c8220a0f116 diff --git a/lib/services/mixins/fusion_wallet_interface.dart b/lib/services/mixins/fusion_wallet_interface.dart index 76c4ddb91..df5893f24 100644 --- a/lib/services/mixins/fusion_wallet_interface.dart +++ b/lib/services/mixins/fusion_wallet_interface.dart @@ -207,7 +207,7 @@ mixin FusionWalletInterface { /// A `Future` that resolves when the fusion operation is finished. Future fuse() async { // Initial attempt for CashFusion integration goes here. - Fusion mainFusionObject = Fusion( + final mainFusionObject = Fusion( getAddresses: () => getFusionAddresses(), getTransactionsByAddress: (String address) => getTransactionsByAddress(address), @@ -220,39 +220,46 @@ mixin FusionWalletInterface { // Pass wallet functions to the Fusion object mainFusionObject.initFusion( - getAddresses: getFusionAddresses, - getTransactionsByAddress: getTransactionsByAddress, - getInputsByAddress: getInputsByAddress, - /*createNewReservedChangeAddress: createNewReservedChangeAddress,*/ - getUnusedReservedChangeAddresses: getUnusedReservedChangeAddresses, - getSocksProxyAddress: getSocksProxyAddress); + getAddresses: getFusionAddresses, + getTransactionsByAddress: getTransactionsByAddress, + getInputsByAddress: getInputsByAddress, + /*createNewReservedChangeAddress: createNewReservedChangeAddress,*/ + getUnusedReservedChangeAddresses: getUnusedReservedChangeAddresses, + getSocksProxyAddress: getSocksProxyAddress, + ); // Add stack UTXOs. - List utxos = await _db.getUTXOs(_walletId).findAll(); - List<(String, int, int, List)> coinList = []; + final List walletUtxos = await _db.getUTXOs(_walletId).findAll(); + final List< + ({ + String txid, + int vout, + int value, + List pubKey, + })> coinList = []; // Loop through UTXOs, checking and adding valid ones. - for (var e in utxos) { + for (final utxo in walletUtxos) { // Check if address is available. - if (e.address == null) { + if (utxo.address == null) { // TODO we could continue here (and below during scriptPubKey validation) instead of throwing. - throw Exception("UTXO ${e.txid}:${e.vout} address is null"); + throw Exception("UTXO ${utxo.txid}:${utxo.vout} address is null"); } // Find public key. Map tx = await _getWalletCachedElectrumX().getTransaction( coin: _coin, - txHash: e.txid, + txHash: utxo.txid, verbose: true, ); // Check if scriptPubKey is available. final scriptPubKeyHex = - tx["vout"]?[e.vout]?["scriptPubKey"]?["hex"] as String?; + tx["vout"]?[utxo.vout]?["scriptPubKey"]?["hex"] as String?; if (scriptPubKeyHex == null) { throw Exception( - "hex in scriptPubKey of vout index ${e.vout} in transaction is null", + "hex in scriptPubKey of vout index ${utxo.vout} in transaction is null", ); } @@ -260,7 +267,12 @@ mixin FusionWalletInterface { List pubKey = scriptPubKeyHex.toUint8ListFromHex; // Add UTXO to coinList. - coinList.add((e.txid, e.vout, e.value, pubKey)); + coinList.add(( + txid: utxo.txid, + vout: utxo.vout, + value: utxo.value, + pubKey: pubKey + )); } // Add Stack UTXOs. diff --git a/pubspec.lock b/pubspec.lock index e7599a701..8ac1525b0 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1671,8 +1671,8 @@ packages: dependency: "direct main" description: path: "." - ref: c8b97bc118c7bbfe1027d0442cfadea44dc285aa - resolved-ref: c8b97bc118c7bbfe1027d0442cfadea44dc285aa + ref: "0a6888282f4e98401051a396e9d2293bd55ac2c2" + resolved-ref: "0a6888282f4e98401051a396e9d2293bd55ac2c2" url: "https://github.com/cypherstack/tor.git" source: git version: "0.0.1"