MCPcopy Create free account
hub / github.com/btcsuite/btcd / extractScriptHash

Function extractScriptHash

txscript/standard.go:195–207  ·  view source on GitHub ↗

extractScriptHash extracts the script hash from the passed script if it is a standard pay-to-script-hash script. It will return nil otherwise. NOTE: This function is only valid for version 0 opcodes. Since the function does not accept a script version, the results are undefined for other script v

(script []byte)

Source from the content-addressed store, hash-verified

193// does not accept a script version, the results are undefined for other script
194// versions.
195func extractScriptHash(script []byte) []byte {
196 // A pay-to-script-hash script is of the form:
197 // OP_HASH160 OP_DATA_20 <20-byte scripthash> OP_EQUAL
198 if len(script) == 23 &&
199 script[0] == OP_HASH160 &&
200 script[1] == OP_DATA_20 &&
201 script[22] == OP_EQUAL {
202
203 return script[2:22]
204 }
205
206 return nil
207}
208
209// isScriptHashScript returns whether or not the passed script is a standard
210// pay-to-script-hash script.

Callers 2

isScriptHashScriptFunction · 0.85
ExtractPkScriptAddrsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…