Skip to content

Instantly share code, notes, and snippets.

@mahdiidarabi
Created December 4, 2020 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahdiidarabi/4941fa558f85d917954a2ebcc2b7951a to your computer and use it in GitHub Desktop.
Save mahdiidarabi/4941fa558f85d917954a2ebcc2b7951a to your computer and use it in GitHub Desktop.
dis asemble a bitcoin script to human readable one in go
package main
import (
"encoding/hex"
"github.com/btcsuite/btcd/txscript"
)
func DisAsembleScript() (string, error) {
// you can provide your locking script to dis asemble
lockingScript := "a914f63e2cbcc678236f683d267e7bb298ffdcd57b0487"
script, err := hex.DecodeString(lockingScript)
if err != nil {
return "", err
}
scriptStr, err := txscript.DisasmString(script)
if err != nil {
return "", err
}
return scriptStr, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment