named record params and clear variable names

This commit is contained in:
julian 2023-09-22 17:00:32 -06:00
parent ec6f40cf68
commit 593d2c7e7e
3 changed files with 31 additions and 19 deletions

@ -1 +1 @@
Subproject commit 929aedac530048ec23efcf23707506fcb0c79057 Subproject commit e4877ee7cad443623e1486e27cb27c8220a0f116

View file

@ -207,7 +207,7 @@ mixin FusionWalletInterface {
/// A `Future<void>` that resolves when the fusion operation is finished. /// A `Future<void>` that resolves when the fusion operation is finished.
Future<void> fuse() async { Future<void> fuse() async {
// Initial attempt for CashFusion integration goes here. // Initial attempt for CashFusion integration goes here.
Fusion mainFusionObject = Fusion( final mainFusionObject = Fusion(
getAddresses: () => getFusionAddresses(), getAddresses: () => getFusionAddresses(),
getTransactionsByAddress: (String address) => getTransactionsByAddress: (String address) =>
getTransactionsByAddress(address), getTransactionsByAddress(address),
@ -220,39 +220,46 @@ mixin FusionWalletInterface {
// Pass wallet functions to the Fusion object // Pass wallet functions to the Fusion object
mainFusionObject.initFusion( mainFusionObject.initFusion(
getAddresses: getFusionAddresses, getAddresses: getFusionAddresses,
getTransactionsByAddress: getTransactionsByAddress, getTransactionsByAddress: getTransactionsByAddress,
getInputsByAddress: getInputsByAddress, getInputsByAddress: getInputsByAddress,
/*createNewReservedChangeAddress: createNewReservedChangeAddress,*/ /*createNewReservedChangeAddress: createNewReservedChangeAddress,*/
getUnusedReservedChangeAddresses: getUnusedReservedChangeAddresses, getUnusedReservedChangeAddresses: getUnusedReservedChangeAddresses,
getSocksProxyAddress: getSocksProxyAddress); getSocksProxyAddress: getSocksProxyAddress,
);
// Add stack UTXOs. // Add stack UTXOs.
List<UTXO> utxos = await _db.getUTXOs(_walletId).findAll(); final List<UTXO> walletUtxos = await _db.getUTXOs(_walletId).findAll();
List<(String, int, int, List<int>)> coinList = []; final List<
({
String txid,
int vout,
int value,
List<int> pubKey,
})> coinList = [];
// Loop through UTXOs, checking and adding valid ones. // Loop through UTXOs, checking and adding valid ones.
for (var e in utxos) { for (final utxo in walletUtxos) {
// Check if address is available. // 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. // 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. // Find public key.
Map<String, dynamic> tx = Map<String, dynamic> tx =
await _getWalletCachedElectrumX().getTransaction( await _getWalletCachedElectrumX().getTransaction(
coin: _coin, coin: _coin,
txHash: e.txid, txHash: utxo.txid,
verbose: true, verbose: true,
); );
// Check if scriptPubKey is available. // Check if scriptPubKey is available.
final scriptPubKeyHex = final scriptPubKeyHex =
tx["vout"]?[e.vout]?["scriptPubKey"]?["hex"] as String?; tx["vout"]?[utxo.vout]?["scriptPubKey"]?["hex"] as String?;
if (scriptPubKeyHex == null) { if (scriptPubKeyHex == null) {
throw Exception( 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<int> pubKey = scriptPubKeyHex.toUint8ListFromHex; List<int> pubKey = scriptPubKeyHex.toUint8ListFromHex;
// Add UTXO to coinList. // 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. // Add Stack UTXOs.

View file

@ -1671,8 +1671,8 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
path: "." path: "."
ref: c8b97bc118c7bbfe1027d0442cfadea44dc285aa ref: "0a6888282f4e98401051a396e9d2293bd55ac2c2"
resolved-ref: c8b97bc118c7bbfe1027d0442cfadea44dc285aa resolved-ref: "0a6888282f4e98401051a396e9d2293bd55ac2c2"
url: "https://github.com/cypherstack/tor.git" url: "https://github.com/cypherstack/tor.git"
source: git source: git
version: "0.0.1" version: "0.0.1"