func ParseClaimNameScript(script []byte) (name string, value []byte, pubkeyscript []byte, err error) {
	nameBytesToRead := int(script[1])
	nameStart := 2
	if nameBytesToRead == opPushdata1 {
		nameBytesToRead = int(script[2])
		nameStart = 3
	} else if nameBytesToRead > opPushdata1 {
		panic(errors.Base("Bytes to read is more than next byte! "))
	}
	nameEnd := nameStart + nameBytesToRead
	name = string(script[nameStart:nameEnd])
	dataPushType := int(script[nameEnd])
	valueBytesToRead := int(script[nameEnd])
	valueStart := nameEnd + 1
	if dataPushType == opPushdata1 {
		valueBytesToRead = int(script[nameEnd+1])
		valueStart = nameEnd + 2
	} else if dataPushType == opPushdata2 {
		valueStart = nameEnd + 3
		valueBytesToRead = int(binary.LittleEndian.Uint16(script[nameEnd+1 : valueStart]))
	} else if dataPushType == opPushdata4 {
		valueStart = nameEnd + 5
		valueBytesToRead = int(binary.LittleEndian.Uint32(script[nameEnd+2 : valueStart]))
	}
	valueEnd := valueStart + valueBytesToRead
	value = script[valueStart:valueEnd]
	pksStart := valueEnd + 2          
	pubkeyscript = script[pksStart:]  
	return name, value, pubkeyscript, err
}
ParseClaimNameScript parses a script for the claim of a name.
package lbrycrd
import (
	"encoding/binary"
	"encoding/hex"
	"github.com/golang/protobuf/proto"
	"github.com/lbryio/chainquery/global"
	"github.com/lbryio/chainquery/util"
	"github.com/lbryio/lbry.go/extras/errors"
	"github.com/btcsuite/btcd/chaincfg"
	"github.com/btcsuite/btcd/txscript"
	"github.com/btcsuite/btcutil"
	pb "github.com/lbryio/types/v2/go"
	log "github.com/sirupsen/logrus"
)
const (
	opClaimName    = 0xb5  
	opSupportClaim = 0xb6  
	opUpdateClaim  = 0xb7  
	opReturn       = 0x6a  
	purchase       = 0x50  
	opDup          = 0x76  
	opChecksig     = 0xac  
	opEqualverify  = 0x88  
	opHash160      = 0xa9  
	opPushdata1    = 0x4c  
	opPushdata2    = 0x4d  
	opPushdata4    = 0x4e  
	p2SH   = "scripthash"             
	p2PK   = "pubkey"                 
	p2PKH  = "pubkeyhash"             
	p2WPKH = "witness_v0_keyhash"     
	p2WSH  = "witness_v0_scripthash"  
	NonStandard = "nonstandard"
	NullData = "nulldata"
	lbrycrdMainPubkeyPrefix    = byte(85)
	lbrycrdMainScriptPrefix    = byte(122)
	lbrycrdTestnetPubkeyPrefix = byte(111)
	lbrycrdTestnetScriptPrefix = byte(196)
	lbrycrdRegtestPubkeyPrefix = byte(111)
	lbrycrdRegtestScriptPrefix = byte(196)
	lbrycrdMain    = "lbrycrd_main"
	lbrycrdTestnet = "lbrycrd_testnet"
	lbrycrdRegtest = "lbrycrd_regtest"
)
var mainNetParams = chaincfg.Params{
	PubKeyHashAddrID: lbrycrdMainPubkeyPrefix,
	ScriptHashAddrID: lbrycrdMainScriptPrefix,
	PrivateKeyID:     0x1c,
	Bech32HRPSegwit:  "lbc",
}
var testNetParams = chaincfg.Params{
	PubKeyHashAddrID: lbrycrdTestnetPubkeyPrefix,
	ScriptHashAddrID: lbrycrdTestnetScriptPrefix,
	PrivateKeyID:     0x1c,
	Bech32HRPSegwit:  "tlbc",
}
var regTestNetParams = chaincfg.Params{
	PubKeyHashAddrID: lbrycrdRegtestPubkeyPrefix,
	ScriptHashAddrID: lbrycrdRegtestScriptPrefix,
	PrivateKeyID:     0x1c,
	Bech32HRPSegwit:  "rlbc",
}
var paramsMap = map[string]chaincfg.Params{lbrycrdMain: mainNetParams, lbrycrdTestnet: testNetParams, lbrycrdRegtest: regTestNetParams}
func GetChainParams() (*chaincfg.Params, error) {
	chainParams, ok := paramsMap[global.BlockChainName]
	if !ok {
		return nil, errors.Err("unknown chain name %s", global.BlockChainName)
	}
	return &chainParams, nil
}
func IsClaimScript(script []byte) bool {
	return script[0] == opSupportClaim ||
		script[0] == opClaimName ||
		script[0] == opUpdateClaim
}
func IsClaimNameScript(script []byte) bool {
	if len(script) > 0 {
		return script[0] == opClaimName
	}
	log.Error("script is nil or length 0!")
	return false
}
func IsClaimSupportScript(script []byte) bool {
	if len(script) > 0 {
		return script[0] == opSupportClaim
	}
	return false
}
func IsClaimUpdateScript(script []byte) bool {
	if len(script) > 0 {
		return script[0] == opUpdateClaim
	}
	return false
}
func IsPurchaseScript(script []byte) bool {
	if len(script) > 2 {
		if script[0] == opReturn && script[2] == purchase {
			_, err := ParsePurchaseScript(script)
			return err == nil
		}
	}
	return false
}