TaprootSignatureHasher constructor
TaprootSignatureHasher({
- required Transaction tx,
- required int inputN,
- required List<
Output> prevOuts, - required SigHashType hashType,
- Uint8List? leafHash,
- int codeSeperatorPos = 0xFFFFFFFF,
Produces the hash for a Taproot input signature at inputN.
Unless SigHashType.anyOneCanPay is true, prevOuts must contain the
full list of previous outputs being spent.
The hashType controls what data is included. If ommitted it will be
treated as SIGHASH_DEFAULT which includes the same data as SIGHASH_ALL but
produces distinct signatures.
If an input is being signed for a tapscript, the leafHash must be
provided. codeSeperatorPos must be provided with the position of the
last executed CODESEPARATOR unless none have been executed in the script
Implementation
TaprootSignatureHasher({
required this.tx,
required this.inputN,
required this.prevOuts,
required this.hashType,
this.leafHash,
this.codeSeperatorPos = 0xFFFFFFFF,
}) : txHashes = TransactionSignatureHashes(tx),
prevOutHashes = PrevOutSignatureHashes(prevOuts) {
SignatureHasher.checkInputN(tx, inputN);
if (hashType.single && inputN >= tx.outputs.length) {
throw ArgumentError.value(
inputN, "inputN", "has no corresponing output for SIGHASH_SINGLE",
);
}
if (prevOuts.length != tx.inputs.length) {
throw ArgumentError.value(
prevOuts.length, "prevOuts.length", "must be same length as inputs",
);
}
}