mirror of
https://github.com/FlipsideCrypto/dcrd.git
synced 2026-02-06 10:56:47 +00:00
txscript: Use raw scripts in RawTxInSignatureAlt.
This converts RawTxInSignatureAlt to make use of the recently converted CalcSignatureHash function that works with raw scripts in order to remove the reliance on parsed opcodes as a step towards utlimately removing them altogether and updates the comment to explicitly call out the script version semantics. It is worth noting that this has the side effect of optimizing the function as well, however, since this change is not focused on the optimization aspects, no benchmarks are provided.
This commit is contained in:
parent
7cf42b0a70
commit
706b3a1fcd
@ -41,15 +41,15 @@ func RawTxInSignature(tx *wire.MsgTx, idx int, subScript []byte,
|
||||
|
||||
// RawTxInSignatureAlt returns the serialized ECDSA signature for the input idx of
|
||||
// the given transaction, with hashType appended to it.
|
||||
//
|
||||
// NOTE: This function is only valid for version 0 scripts. Since the function
|
||||
// does not accept a script version, the results are undefined for other script
|
||||
// versions.
|
||||
func RawTxInSignatureAlt(tx *wire.MsgTx, idx int, subScript []byte,
|
||||
hashType SigHashType, key chainec.PrivateKey, sigType dcrec.SignatureType) ([]byte,
|
||||
error) {
|
||||
|
||||
parsedScript, err := parseScript(subScript)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot parse output script: %v", err)
|
||||
}
|
||||
hash, err := calcSignatureHash(parsedScript, hashType, tx, idx, nil)
|
||||
hash, err := CalcSignatureHash(subScript, hashType, tx, idx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user