signWithHashType method
Sign with an explicit sighash type, keeping the digest's committed hashType consistent with the hashType byte the caller will embed in the final signature (GSPL callers compute both from the same value).
Implementation
String signWithHashType(String message, int hashType) {
final ecPrivateKey = ECPrivate.fromBytes(privateKey);
if (isTaproot) {
// Keep the signer/serializer boundary unambiguous: return the raw
// 64-byte Schnorr signature here. The GSPL transaction serializer is
// the single place that appends a non-default sighash byte to witness.
return ecPrivateKey.signTapRoot(message.toUint8List()).toHex();
} else {
return ecPrivateKey
.signInput(message.toUint8List(), sigHash: hashType)
.toHex();
}
}