Enable txindex=1 as default #37
2 changed files with 23 additions and 5 deletions
|
@ -100,11 +100,7 @@ func isWitnessScriptHash(pops []parsedOpcode) bool {
|
|||
// IsPayToWitnessScriptHash returns true if the is in the standard
|
||||
// pay-to-witness-script-hash (P2WSH) format, false otherwise.
|
||||
func IsPayToWitnessScriptHash(script []byte) bool {
|
||||
pops, err := parseScript(script)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return isWitnessScriptHash(pops)
|
||||
return isWitnessScriptHashScript(script)
|
||||
}
|
||||
|
||||
// IsPayToWitnessPubKeyHash returns true if the is in the standard
|
||||
|
|
|
@ -421,6 +421,28 @@ func isWitnessPubKeyHashScript(script []byte) bool {
|
|||
return extractWitnessPubKeyHash(script) != nil
|
||||
}
|
||||
|
||||
// extractWitnessScriptHash extracts the witness script hash from the passed
|
||||
// script if it is standard pay-to-witness-script-hash script. It will return
|
||||
// nil otherwise.
|
||||
func extractWitnessScriptHash(script []byte) []byte {
|
||||
// A pay-to-witness-script-hash script is of the form:
|
||||
// OP_0 OP_DATA_32 <32-byte-hash>
|
||||
if len(script) == 34 &&
|
||||
script[0] == OP_0 &&
|
||||
script[1] == OP_DATA_32 {
|
||||
|
||||
return script[2:34]
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// isWitnessScriptHashScript returns whether or not the passed script is a
|
||||
// standard pay-to-witness-script-hash script.
|
||||
func isWitnessScriptHashScript(script []byte) bool {
|
||||
return extractWitnessScriptHash(script) != nil
|
||||
}
|
||||
|
||||
// isNullData returns true if the passed script is a null data transaction,
|
||||
// false otherwise.
|
||||
func isNullData(pops []parsedOpcode) bool {
|
||||
|
|
Loading…
Reference in a new issue