WIP: next hard fork #5
2 changed files with 25 additions and 0 deletions
|
@ -312,3 +312,18 @@ func BenchmarkIsWitnessScriptHash(b *testing.B) {
|
|||
_ = IsPayToWitnessScriptHash(script)
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkIsNullDataScript benchmarks how long it takes to analyze a very
|
||||
// large script to determine if it is a standard nulldata script.
|
||||
func BenchmarkIsNullDataScript(b *testing.B) {
|
||||
script, err := genComplexScript()
|
||||
if err != nil {
|
||||
b.Fatalf("failed to create benchmark script: %v", err)
|
||||
}
|
||||
|
||||
b.ResetTimer()
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = IsNullData(script)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,6 +151,16 @@ func isWitnessProgram(pops []parsedOpcode) bool {
|
|||
(len(pops[1].data) >= 2 && len(pops[1].data) <= 40)
|
||||
}
|
||||
|
||||
// IsNullData returns true if the passed script is a null data script, false
|
||||
// otherwise.
|
||||
func IsNullData(script []byte) bool {
|
||||
pops, err := parseScript(script)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return isNullData(pops)
|
||||
}
|
||||
|
||||
// ExtractWitnessProgramInfo attempts to extract the witness program version,
|
||||
// as well as the witness program itself from the passed script.
|
||||
func ExtractWitnessProgramInfo(script []byte) (int, []byte, error) {
|
||||
|
|
Loading…
Reference in a new issue