TaprootSignatureHasher constructor

TaprootSignatureHasher({
  1. required Transaction tx,
  2. required int inputN,
  3. required List<Output> prevOuts,
  4. required SigHashType hashType,
  5. Uint8List? leafHash,
  6. 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",
    );
  }

}