legacySigHash method
Implementation
Uint8List legacySigHash({
required int index,
required Uint8List prevScriptPubKey,
required int hashType,
}) {
final copy = createCopy();
// clear all scriptSigs
for (int i = 0; i < copy.inputs.length; i++) {
copy.inputs[i] = copy.inputs[i].addScript(
scriptSig: Uint8List.fromList([]),
);
}
// set scriptSig for inputIndex to prevScriptPubKeyHex
copy.inputs[index] = copy.inputs[index].addScript(
scriptSig: prevScriptPubKey,
);
final bytes = copy is EC8RawTransaction ? copy.bytesForSigning : copy.bytes;
final buffer = Uint8List(bytes.length + 4);
var offset = 0;
offset += buffer.writeSlice(0, bytes);
offset += buffer.bytes.writeUint32(offset, hashType);
final hash = sha256Sha256Hash(buffer);
return hash;
}