Versions in this module Expand all Collapse all v1 v1.0.2 Mar 23, 2022 v1.0.1 Mar 17, 2022 Changes in this version + const DefaultScriptVersion + const LockTimeThreshold + const MaxDataCarrierSize + const MaxOpsPerScript + const MaxPubKeysPerMultiSig + const MaxScriptElementSize + const OP_0 + const OP_0NOTEQUAL + const OP_1 + const OP_10 + const OP_11 + const OP_12 + const OP_13 + const OP_14 + const OP_15 + const OP_16 + const OP_1ADD + const OP_1NEGATE + const OP_1SUB + const OP_2 + const OP_2DIV + const OP_2DROP + const OP_2DUP + const OP_2MUL + const OP_2OVER + const OP_2ROT + const OP_2SWAP + const OP_3 + const OP_3DUP + const OP_4 + const OP_5 + const OP_6 + const OP_7 + const OP_8 + const OP_9 + const OP_ABS + const OP_ADD + const OP_AND + const OP_BLAKE256 + const OP_BOOLAND + const OP_BOOLOR + const OP_CAT + const OP_CHECKLOCKTIMEVERIFY + const OP_CHECKMULTISIG + const OP_CHECKMULTISIGVERIFY + const OP_CHECKSEQUENCEVERIFY + const OP_CHECKSIG + const OP_CHECKSIGALT + const OP_CHECKSIGALTVERIFY + const OP_CHECKSIGVERIFY + const OP_CODESEPARATOR + const OP_DATA_1 + const OP_DATA_10 + const OP_DATA_11 + const OP_DATA_12 + const OP_DATA_13 + const OP_DATA_14 + const OP_DATA_15 + const OP_DATA_16 + const OP_DATA_17 + const OP_DATA_18 + const OP_DATA_19 + const OP_DATA_2 + const OP_DATA_20 + const OP_DATA_21 + const OP_DATA_22 + const OP_DATA_23 + const OP_DATA_24 + const OP_DATA_25 + const OP_DATA_26 + const OP_DATA_27 + const OP_DATA_28 + const OP_DATA_29 + const OP_DATA_3 + const OP_DATA_30 + const OP_DATA_31 + const OP_DATA_32 + const OP_DATA_33 + const OP_DATA_34 + const OP_DATA_35 + const OP_DATA_36 + const OP_DATA_37 + const OP_DATA_38 + const OP_DATA_39 + const OP_DATA_4 + const OP_DATA_40 + const OP_DATA_41 + const OP_DATA_42 + const OP_DATA_43 + const OP_DATA_44 + const OP_DATA_45 + const OP_DATA_46 + const OP_DATA_47 + const OP_DATA_48 + const OP_DATA_49 + const OP_DATA_5 + const OP_DATA_50 + const OP_DATA_51 + const OP_DATA_52 + const OP_DATA_53 + const OP_DATA_54 + const OP_DATA_55 + const OP_DATA_56 + const OP_DATA_57 + const OP_DATA_58 + const OP_DATA_59 + const OP_DATA_6 + const OP_DATA_60 + const OP_DATA_61 + const OP_DATA_62 + const OP_DATA_63 + const OP_DATA_64 + const OP_DATA_65 + const OP_DATA_66 + const OP_DATA_67 + const OP_DATA_68 + const OP_DATA_69 + const OP_DATA_7 + const OP_DATA_70 + const OP_DATA_71 + const OP_DATA_72 + const OP_DATA_73 + const OP_DATA_74 + const OP_DATA_75 + const OP_DATA_8 + const OP_DATA_9 + const OP_DEPTH + const OP_DIV + const OP_DROP + const OP_DUP + const OP_ELSE + const OP_ENDIF + const OP_EQUAL + const OP_EQUALVERIFY + const OP_FALSE + const OP_FROMALTSTACK + const OP_GREATERTHAN + const OP_GREATERTHANOREQUAL + const OP_HASH160 + const OP_HASH256 + const OP_IF + const OP_IFDUP + const OP_INVALIDOPCODE + const OP_INVERT + const OP_LEFT + const OP_LESSTHAN + const OP_LESSTHANOREQUAL + const OP_LSHIFT + const OP_MAX + const OP_MIN + const OP_MOD + const OP_MUL + const OP_NEGATE + const OP_NIP + const OP_NOP + const OP_NOP1 + const OP_NOP10 + const OP_NOP2 + const OP_NOP3 + const OP_NOP4 + const OP_NOP5 + const OP_NOP6 + const OP_NOP7 + const OP_NOP8 + const OP_NOP9 + const OP_NOT + const OP_NOTIF + const OP_NUMEQUAL + const OP_NUMEQUALVERIFY + const OP_NUMNOTEQUAL + const OP_OR + const OP_OVER + const OP_PICK + const OP_PUBKEY + const OP_PUBKEYHASH + const OP_PUBKEYS + const OP_PUSHDATA1 + const OP_PUSHDATA2 + const OP_PUSHDATA4 + const OP_RESERVED + const OP_RETURN + const OP_RIGHT + const OP_RIPEMD160 + const OP_ROLL + const OP_ROT + const OP_ROTL + const OP_ROTR + const OP_RSHIFT + const OP_SHA1 + const OP_SHA256 + const OP_SIZE + const OP_SMALLDATA + const OP_SMALLINTEGER + const OP_SSGEN + const OP_SSRTX + const OP_SSTX + const OP_SSTXCHANGE + const OP_SUB + const OP_SUBSTR + const OP_SWAP + const OP_TOALTSTACK + const OP_TRUE + const OP_TUCK + const OP_UNKNOWN193 + const OP_UNKNOWN194 + const OP_UNKNOWN195 + const OP_UNKNOWN196 + const OP_UNKNOWN197 + const OP_UNKNOWN198 + const OP_UNKNOWN199 + const OP_UNKNOWN200 + const OP_UNKNOWN201 + const OP_UNKNOWN202 + const OP_UNKNOWN203 + const OP_UNKNOWN204 + const OP_UNKNOWN205 + const OP_UNKNOWN206 + const OP_UNKNOWN207 + const OP_UNKNOWN208 + const OP_UNKNOWN209 + const OP_UNKNOWN210 + const OP_UNKNOWN211 + const OP_UNKNOWN212 + const OP_UNKNOWN213 + const OP_UNKNOWN214 + const OP_UNKNOWN215 + const OP_UNKNOWN216 + const OP_UNKNOWN217 + const OP_UNKNOWN218 + const OP_UNKNOWN219 + const OP_UNKNOWN220 + const OP_UNKNOWN221 + const OP_UNKNOWN222 + const OP_UNKNOWN223 + const OP_UNKNOWN224 + const OP_UNKNOWN225 + const OP_UNKNOWN226 + const OP_UNKNOWN227 + const OP_UNKNOWN228 + const OP_UNKNOWN229 + const OP_UNKNOWN230 + const OP_UNKNOWN231 + const OP_UNKNOWN232 + const OP_UNKNOWN233 + const OP_UNKNOWN234 + const OP_UNKNOWN235 + const OP_UNKNOWN236 + const OP_UNKNOWN237 + const OP_UNKNOWN238 + const OP_UNKNOWN239 + const OP_UNKNOWN240 + const OP_UNKNOWN241 + const OP_UNKNOWN242 + const OP_UNKNOWN243 + const OP_UNKNOWN244 + const OP_UNKNOWN245 + const OP_UNKNOWN246 + const OP_UNKNOWN247 + const OP_UNKNOWN248 + const OP_UNKNOWN252 + const OP_VER + const OP_VERIF + const OP_VERIFY + const OP_VERNOTIF + const OP_WITHIN + const OP_XOR + const OpCondFalse + const OpCondSkip + const OpCondTrue + var ErrBadNumRequired = errors.New("more signatures required than keys present") + var ErrDivideByZero = errors.New("division by zero") + var ErrInvalidFlags = errors.New("invalid flags combination") + var ErrInvalidIndex = errors.New("invalid input index") + var ErrNegativeRotation = errors.New("rotation depth negative") + var ErrNegativeShift = errors.New("shift depth negative") + var ErrP2SHStakeOpCodes = errors.New("stake opcodes were found in a p2sh script") + var ErrRotationOverflow = errors.New("rotation depth out of bounds") + var ErrShiftOverflow = errors.New("shift depth out of bounds") + var ErrSighashSingleIdx = errors.New("invalid SIGHASH_SINGLE script index") + var ErrStackCleanStack = errors.New("stack is not clean") + var ErrStackEarlyReturn = errors.New("script returned early") + var ErrStackElementTooBig = errors.New("element in script too large") + var ErrStackEmptyStack = errors.New("stack empty at end of execution") + var ErrStackInvalidAddrOffset = errors.New("internal error: invalid offset found") + var ErrStackInvalidArgs = errors.New("invalid argument") + var ErrStackInvalidIndex = errors.New("invalid script index") + var ErrStackInvalidLowSSignature = errors.New("invalid low s signature") + var ErrStackInvalidOpcode = errors.New("invalid opcode") + var ErrStackInvalidParseType = errors.New("internal error: invalid parsetype found") + var ErrStackInvalidPubKey = errors.New("invalid strict pubkey") + var ErrStackLongScript = errors.New("script is longer than maximum allowed") + var ErrStackMinimalData = errors.New("non-minimally encoded script number") + var ErrStackMissingEndif = fmt.Errorf("execute fail, in conditional execution") + var ErrStackNoIf = errors.New("OP_ELSE or OP_ENDIF with no matching OP_IF") + var ErrStackNonPushOnly = errors.New("SigScript is non pushonly") + var ErrStackNumberTooBig = errors.New("number too big") + var ErrStackOpDisabled = errors.New("disabled opcode") + var ErrStackOverflow = errors.New("stack overflow") + var ErrStackP2SHNonPushOnly = errors.New(...) + var ErrStackReservedOpcode = errors.New("reserved opcode") + var ErrStackScriptFailed = errors.New("execute fail, fail on stack") + var ErrStackScriptUnfinished = errors.New("error check when script unfinished") + var ErrStackShortScript = errors.New("execute past end of script") + var ErrStackTooManyOperations = errors.New("too many operations in script") + var ErrStackTooManyPubKeys = errors.New("invalid pubkey count in OP_CHECKMULTISIG") + var ErrStackUnderflow = errors.New("stack underflow") + var ErrStackUnknownAddress = errors.New("non-recognised address") + var ErrStackVerifyFailed = errors.New("verify failed") + var ErrSubstrIdxNegative = errors.New(...) + var ErrSubstrIdxOutOfBounds = errors.New(...) + var ErrUnsupportedAddress = errors.New("unsupported address type") + var OpcodeByName = make(map[string]byte) + func AddressFromScriptSig(script []byte, chainParams *chaincfg.Params) (hcutil.Address, error) + func CalcMultiSigStats(script []byte) (int, int, error) + func CalcSignatureHash(script []parsedOpcode, hashType SigHashType, tx *wire.MsgTx, idx int, ...) ([]byte, error) + func CanonicalDataSize(data []byte) int + func ContainsStakeOpCodes(pkScript []byte) (bool, error) + func DisableLog() + func DisasmString(buf []byte) (string, error) + func ExtractP2XScriptSigType(sdb ScriptDB, chainParams *chaincfg.Params, pkScript []byte) ([]uint8, int, error) + func ExtractPkScriptAltSigType(pkScript []byte) (uint8, error) + func ExtractStakePkScriptAltSigType(pkScript []byte) (uint8, error) + func GenerateProvablyPruneableOut(data []byte) ([]byte, error) + func GenerateSSGenBlockRef(blockHash chainhash.Hash, height uint32) ([]byte, error) + func GenerateSSGenVotes(votebits uint16) ([]byte, error) + func GenerateSStxAddrPush(addr hcutil.Address, amount hcutil.Amount, limits uint16) ([]byte, error) + func GetMultisigMandN(script []byte) (uint8, uint8, error) + func GetNullDataContent(version uint16, pkScript []byte) ([]byte, error) + func GetPayLoadData(pkScript []byte) (bool, []byte) + func GetPreciseSigOpCount(scriptSig, scriptPubKey []byte, bip16 bool) int + func GetScriptHashFromP2SHScript(pkScript []byte) ([]byte, error) + func GetSigOpCount(script []byte) int + func HasP2SHScriptSigStakeOpCodes(version uint16, scriptSig, scriptPubKey []byte) error + func IsMultisigScript(script []byte) (bool, error) + func IsMultisigSigScript(script []byte) bool + func IsPayToScriptHash(script []byte) bool + func IsPushOnlyScript(script []byte) bool + func IsStakeOutput(pkScript []byte) bool + func IsUnspendable(amount int64, pkScript []byte) bool + func MultiSigScript(pubkeys []hcutil.Address, nrequired int) ([]byte, error) + func MultisigRedeemScriptFromScriptSig(script []byte) ([]byte, error) + func ParseScript(script []byte) ([]parsedOpcode, error) + func PayToAddrScript(addr hcutil.Address) ([]byte, error) + func PayToSSGen(addr hcutil.Address) ([]byte, error) + func PayToSSGenPKHDirect(pkh []byte, alType int) ([]byte, error) + func PayToSSGenSHDirect(sh []byte, _ int) ([]byte, error) + func PayToSSRtx(addr hcutil.Address) ([]byte, error) + func PayToSSRtxPKHDirect(pkh []byte, alType int) ([]byte, error) + func PayToSSRtxSHDirect(sh []byte, _ int) ([]byte, error) + func PayToSStx(addr hcutil.Address) ([]byte, error) + func PayToSStxChange(addr hcutil.Address) ([]byte, error) + func PayToScriptHashScript(scriptHash []byte) ([]byte, error) + func PushedData(script []byte) ([][]byte, error) + func RawTxInSignature(tx *wire.MsgTx, idx int, subScript []byte, hashType SigHashType, ...) ([]byte, error) + func RawTxInSignatureAlt(tx *wire.MsgTx, idx int, subScript []byte, hashType SigHashType, ...) ([]byte, error) + func ScriptFromScriptSig(script []byte) ([]byte, error) + func SignTxOutput(chainParams *chaincfg.Params, tx *wire.MsgTx, idx int, pkScript []byte, ...) ([]byte, error) + func SignatureScript(tx *wire.MsgTx, idx int, subscript []byte, hashType SigHashType, ...) ([]byte, error) + func SignatureScriptAlt(tx *wire.MsgTx, idx int, subscript []byte, hashType SigHashType, ...) ([]byte, error) + func UseLogger(logger btclog.Logger) + type AtomicSwapDataPushes struct + LockTime int64 + RecipientHash160 [20]byte + RefundHash160 [20]byte + SecretHash [20]byte + func ExtractAtomicSwapDataPushes(version uint16, pkScript []byte) (*AtomicSwapDataPushes, error) + type Engine struct + func NewEngine(scriptPubKey []byte, tx *wire.MsgTx, txIdx int, flags ScriptFlags, ...) (*Engine, error) + func (vm *Engine) CheckErrorCondition(finalScript bool) error + func (vm *Engine) DisasmPC() (string, error) + func (vm *Engine) DisasmScript(idx int) (string, error) + func (vm *Engine) Execute() (err error) + func (vm *Engine) GetAltStack() [][]byte + func (vm *Engine) GetStack() [][]byte + func (vm *Engine) SetAltStack(data [][]byte) + func (vm *Engine) SetStack(data [][]byte) + func (vm *Engine) Step() (done bool, err error) + type ErrScriptNotCanonical string + func (e ErrScriptNotCanonical) Error() string + type KeyClosure func(hcutil.Address) (chainec.PrivateKey, bool, error) + func (kc KeyClosure) GetKey(address hcutil.Address) (chainec.PrivateKey, bool, error) + type KeyDB interface + GetKey func(hcutil.Address) (chainec.PrivateKey, bool, error) + type ScriptBuilder struct + func NewScriptBuilder() *ScriptBuilder + func (b *ScriptBuilder) AddData(data []byte) *ScriptBuilder + func (b *ScriptBuilder) AddFullData(data []byte) *ScriptBuilder + func (b *ScriptBuilder) AddInt64(val int64) *ScriptBuilder + func (b *ScriptBuilder) AddOp(opcode byte) *ScriptBuilder + func (b *ScriptBuilder) AddOps(opcodes []byte) *ScriptBuilder + func (b *ScriptBuilder) Reset() *ScriptBuilder + func (b *ScriptBuilder) Script() ([]byte, error) + type ScriptClass byte + const MultiSigTy + const NonStandardTy + const NullDataTy + const PubKeyHashTy + const PubKeyTy + const PubkeyAltTy + const PubkeyHashAltTy + const ScriptHashTy + const StakeGenTy + const StakeRevocationTy + const StakeSubChangeTy + const StakeSubmissionTy + func ExtractPkScriptAddrs(version uint16, pkScript []byte, chainParams *chaincfg.Params) (ScriptClass, []hcutil.Address, int, error) + func GetScriptClass(version uint16, script []byte) ScriptClass + func GetStakeOutSubclass(pkScript []byte) (ScriptClass, error) + func (t ScriptClass) String() string + type ScriptClosure func(hcutil.Address) ([]byte, error) + func (sc ScriptClosure) GetScript(address hcutil.Address) ([]byte, error) + type ScriptDB interface + GetScript func(hcutil.Address) ([]byte, error) + type ScriptFlags uint32 + const ScriptBip16 + const ScriptDiscourageUpgradableNops + const ScriptStrictMultiSig + const ScriptVerifyCheckLockTimeVerify + const ScriptVerifyCheckSequenceVerify + const ScriptVerifyCleanStack + const ScriptVerifyDERSignatures + const ScriptVerifyLowS + const ScriptVerifyMinimalData + const ScriptVerifySHA256 + const ScriptVerifySigPushOnly + const ScriptVerifyStrictEncoding + type ScriptInfo struct + ExpectedInputs int + NumInputs int + PkScriptClass ScriptClass + SigOps int + func CalcScriptInfo(sigScript, pkScript []byte, bip16 bool) (*ScriptInfo, error) + type SigCache struct + func NewSigCache(maxEntries uint) *SigCache + func (s *SigCache) Add(sigHash chainhash.Hash, sig chainec.Signature, pubKey chainec.PublicKey) + func (s *SigCache) Exists(sigHash chainhash.Hash, sig chainec.Signature, pubKey chainec.PublicKey) bool + type SigHashType byte + const SigHashAll + const SigHashAllValue + const SigHashAnyOneCanPay + const SigHashNone + const SigHashOld + const SigHashSingle