use of com.sparrowwallet.drongo.crypto.ECDSASignature in project drongo by sparrowwallet.
the class PSBTInput method sign.
public boolean sign(ECKey privKey) {
SigHash localSigHash = getSigHash();
if (localSigHash == null) {
localSigHash = getDefaultSigHash();
}
if (getNonWitnessUtxo() != null || getWitnessUtxo() != null) {
Script signingScript = getSigningScript();
if (signingScript != null) {
Sha256Hash hash = getHashForSignature(signingScript, localSigHash);
if (isTaproot()) {
SchnorrSignature schnorrSignature = privKey.signSchnorr(hash);
tapKeyPathSignature = new TransactionSignature(schnorrSignature, localSigHash);
return true;
} else {
ECDSASignature ecdsaSignature = privKey.signEcdsa(hash);
TransactionSignature transactionSignature = new TransactionSignature(ecdsaSignature, localSigHash);
ECKey pubKey = ECKey.fromPublicOnly(privKey);
getPartialSignatures().put(pubKey, transactionSignature);
return true;
}
}
}
return false;
}
Aggregations