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)
| 193 | // does not accept a script version, the results are undefined for other script |
| 194 | // versions. |
| 195 | func 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. |
no outgoing calls
no test coverage detected
searching dependent graphs…