buildInput function
Implementation
Input buildInput({
required String txidHex,
required Set<String> usedUTXO,
required ElectrumOutput utxo,
required UTXONetworkType networkType,
}) {
final vout = utxo.n;
final txid = Uint8List.fromList(
hex.decode(txidHex).reversed.toList(),
); // Use 'txid' instead of 'hash'
final prevTxOut = '$txidHex:$vout';
if (usedUTXO.contains(prevTxOut)) {
throw const SendFailure("double spend");
}
/// Check if utxo has a ScriptSig => Input should also have a ScriptSig
/// Check if utxo has a WitnessScript => Input should also have a WitnessScript
///
return switch (networkType) {
BITCOIN_NETWORK() ||
BITCOINCASH_NETWORK() ||
ZENIQ_NETWORK() ||
LITECOIN_NETWORK() =>
BTCInput(
txid: txid,
vout: vout,
value: utxo.value,
prevScriptPubKey: utxo.scriptPubKey.lockingScript,
),
EUROCOIN_NETWORK() => EC8Input(
txid: txid,
vout: vout,
value: utxo.value,
prevScriptPubKey: utxo.scriptPubKey.lockingScript,
),
};
}