createScriptSignature function
Implementation
Uint8List createScriptSignature({
required RawTransaction tx,
required int i,
required ElectrumOutput output,
required HDWalletPurpose walletPurpose,
required UTXONetworkType networkType,
required BIP32 node,
}) {
final hashType = networkType.sighash.all;
final prevScriptPubKey = output.scriptPubKey.lockingScript;
final sigHash = switch (networkType) {
BITCOINCASH_NETWORK() ||
ZENIQ_NETWORK() when tx is BTCRawTransaction =>
tx.bip143sigHash(
index: i,
prevScriptPubKey: prevScriptPubKey,
output: output,
hashType: hashType,
),
LITECOIN_NETWORK() ||
BITCOIN_NETWORK() ||
EUROCOIN_NETWORK() =>
tx.legacySigHash(
index: i,
prevScriptPubKey: prevScriptPubKey,
hashType: hashType,
),
_ =>
throw SendFailure("Could not find sigHash for networkType $networkType"),
};
final sig = signInput(bip32: node, sigHash: sigHash);
final scriptSig = encodeSignature(sig, hashType);
final unlockingScript = constructScriptSig(
walletPurpose: walletPurpose,
signature: scriptSig,
publicKey: node.publicKey,
);
return unlockingScript;
}