decode hex

This commit is contained in:
julian 2023-09-22 14:25:38 -06:00
parent 04403d5e1e
commit 59ac1563bc

View file

@ -260,25 +260,20 @@ mixin FusionWalletInterface {
Map<String, dynamic> tx = await _cachedElectrumX.getTransaction( Map<String, dynamic> tx = await _cachedElectrumX.getTransaction(
coin: _coin, coin: _coin,
txHash: e.txid, txHash: e.txid,
verbose: true); // TODO is verbose needed? verbose: true,
);
// Check if scriptPubKey is available. // Check if scriptPubKey is available.
if (tx["vout"] == null) { final scriptPubKeyHex =
throw Exception("Vout in transaction ${e.txid} is null"); tx["vout"]?[e.vout]?["scriptPubKey"]?["hex"] as String?;
} if (scriptPubKeyHex == null) {
if (tx["vout"][e.vout] == null) { throw Exception(
throw Exception("Vout index ${e.vout} in transaction is null"); "hex in scriptPubKey of vout index ${e.vout} in transaction is null",
} );
if (tx["vout"][e.vout]["scriptPubKey"] == null) {
throw Exception("scriptPubKey at vout index ${e.vout} is null");
}
if (tx["vout"][e.vout]["scriptPubKey"]["hex"] == null) {
throw Exception("hex in scriptPubKey at vout index ${e.vout} is null");
} }
// Assign scriptPubKey to pubKey. TODO verify this is correct. // Assign scriptPubKey to pubKey. TODO verify this is correct.
List<int> pubKey = List<int> pubKey = scriptPubKeyHex.toUint8ListFromHex;
utf8.encode("${tx["vout"][e.vout]["scriptPubKey"]["hex"]}");
// Add UTXO to coinList. // Add UTXO to coinList.
coinList.add((e.txid, e.vout, e.value, pubKey)); coinList.add((e.txid, e.vout, e.value, pubKey));