Documentation
¶
Overview ¶
Package txscript provides compat stubs for the removed Bitcoin script engine.
Index ¶
- Constants
- Variables
- func CalcMultiSigStats(script []byte) (int, int, error)
- func ComputeTaprootKeyNoScript(internalKey *nogoec.PublicKey) *nogoec.PublicKey
- func ComputeTaprootOutputKey(internalKey *nogoec.PublicKey, scriptRoot []byte) *nogoec.PublicKey
- func DisasmString(script []byte) (string, error)
- func GetKey(s SecretsSource, addr address.Address) (*nogoec.PrivateKey, bool, error)
- func GetPreciseSigOpCount(a, b []byte, c bool) int
- func GetSigOpCount(script []byte) int
- func Hash160(data []byte) []byte
- func IsCoinBaseTx(tx *wire.MsgTx) bool
- func IsPayToAnchorScript(script []byte) bool
- func IsPayToScriptHash(script []byte) bool
- func IsPayToTaproot(script []byte) bool
- func IsPayToWitnessPubKeyHash(script []byte) bool
- func IsPushOnlyScript(script []byte) bool
- func IsUnspendable(script []byte) bool
- func IsWitnessProgram(script []byte) bool
- func MultiSigScript(pubKeys interface{}, nRequired int) ([]byte, error)
- func PayToAddrScript(addr address.Address) ([]byte, error)
- func PushedData(script []byte) ([][]byte, error)
- func RawTxInSignature(tx *wire.MsgTx, idx int, subScript []byte, hashType SigHashType, ...) ([]byte, error)
- func SignTxOutput(chainParams *chaincfg.Params, tx *wire.MsgTx, idx int, pkScript []byte, ...) ([]byte, error)
- func TaprootWitnessSignature(tx *wire.MsgTx, sigHashes *TxSigHashes, idx int, amt int64, pkScript []byte, ...) ([][]byte, error)
- func ValidateTransactionScripts(tx *wire.MsgTx, view *UtxoViewpoint, flags int, sigCache *SigCache, ...) error
- func WitnessSignature(tx *wire.MsgTx, sigHashes *TxSigHashes, idx int, amt int64, subscript []byte, ...) ([][]byte, error)
- type ComputedPkScript
- type ControlBlock
- type Engine
- type HashCache
- type KeyClosure
- type KeyDB
- type MultiPrevOutFetcher
- type PrevOutputFetcher
- type ScriptBuilder
- type ScriptClass
- type ScriptClosure
- type ScriptDB
- type ScriptFlags
- type SecretsSource
- type SigCache
- type SigHashType
- type TapLeaf
- type TapscriptType
- type TxSigHashes
- type UtxoViewpoint
Constants ¶
const ( SigHashAll SigHashType = 1 SigHashDefault SigHashType = 0 StandardVerifyFlags = 0 NonStandardTy ScriptClass = 0 PubKeyTy ScriptClass = 1 PubKeyHashTy ScriptClass = 2 WitnessV0PubKeyHashTy ScriptClass = 3 ScriptHashTy ScriptClass = 4 WitnessV0ScriptHashTy ScriptClass = 5 MultiSigTy ScriptClass = 6 NullDataTy ScriptClass = 7 WitnessV1TaprootTy ScriptClass = 8 TapscriptLeafVersion uint8 = 0xc0 TapscriptTypeFullTree TapscriptType = 0 )
const ( OP_0 = 0x00 OP_FALSE = 0x00 OP_PUSHDATA1 = 0x4c OP_PUSHDATA2 = 0x4d OP_PUSHDATA4 = 0x4e OP_1 = 0x51 OP_TRUE = 0x51 OP_IF = 0x63 OP_ELSE = 0x67 OP_ENDIF = 0x68 OP_RETURN = 0x6a OP_DUP = 0x76 OP_EQUAL = 0x87 OP_EQUALVERIFY = 0x88 OP_2DUP = 0x6e OP_HASH160 = 0xa9 OP_CHECKSIG = 0xac OP_CHECKSIGVERIFY = 0xad OP_CHECKMULTISIG = 0xae OP_CHECKMULTISIGVERIFY = 0xaf OP_INVALIDOPCODE = 0xff // SigHash types SigHashSingle SigHashType = 3 SigHashNone SigHashType = 2 SigHashAnyOneCanPay SigHashType = 0x80 )
--- OP codes ---
Variables ¶
var ErrUnsupportedScriptType = fmt.Errorf("unsupported script type")
Functions ¶
func ComputeTaprootOutputKey ¶
func DisasmString ¶
DisasmString returns a human-readable disassembly of the script. Compat stub — script validation is removed per NogoCore design.
func GetKey ¶
func GetKey(s SecretsSource, addr address.Address) (*nogoec.PrivateKey, bool, error)
func GetPreciseSigOpCount ¶
func GetSigOpCount ¶
GetSigOpCount returns the number of signature operations in a script. Compat stub.
func IsCoinBaseTx ¶
func IsPayToAnchorScript ¶
func IsPayToScriptHash ¶
func IsPayToTaproot ¶
func IsPushOnlyScript ¶
func IsUnspendable ¶
func IsWitnessProgram ¶
func MultiSigScript ¶
MultiSigScript creates a multisig script. Compat stub.
func PushedData ¶
PushedData extracts all data pushed in a script. Compat stub.
func RawTxInSignature ¶
func RawTxInSignature(tx *wire.MsgTx, idx int, subScript []byte, hashType SigHashType, key *nogoec.PrivateKey) ([]byte, error)
RawTxInSignature generates a raw signature for the transaction input. Compat stub.
func SignTxOutput ¶
func TaprootWitnessSignature ¶
func TaprootWitnessSignature(tx *wire.MsgTx, sigHashes *TxSigHashes, idx int, amt int64, pkScript []byte, hashType SigHashType, privKey *nogoec.PrivateKey) ([][]byte, error)
TaprootWitnessSignature returns a valid witness stack that can be used to spend the key-spend path of a taproot output. Compat wrapper stub.
func WitnessSignature ¶
func WitnessSignature(tx *wire.MsgTx, sigHashes *TxSigHashes, idx int, amt int64, subscript []byte, hashType SigHashType, privKey *nogoec.PrivateKey, compress bool) ([][]byte, error)
WitnessSignature creates an input witness stack for tx to spend BTC sent to a P2WPKH / P2WSH output. Compat wrapper stub.
Types ¶
type ComputedPkScript ¶
type ComputedPkScript struct {
// contains filtered or unexported fields
}
ComputedPkScript wraps the result of ComputePkScript, providing an Address() method compatible with newer btcd API.
func ComputePkScript ¶
func ComputePkScript(sigScript []byte, witness wire.TxWitness) (*ComputedPkScript, error)
ComputePkScript reconstructs the pkScript from a signature script and optional witness data. Compat stub.
type ControlBlock ¶
func AssembleTaprootScriptTree ¶
func AssembleTaprootScriptTree(leaves ...TapLeaf) *ControlBlock
func ParseControlBlock ¶
func ParseControlBlock(b []byte) (*ControlBlock, error)
func (*ControlBlock) RootHash ¶
func (c *ControlBlock) RootHash(script []byte) []byte
func (*ControlBlock) ToBytes ¶
func (c *ControlBlock) ToBytes() ([]byte, error)
type Engine ¶
type Engine struct{}
Engine represents a virtual machine that executes scripts. Compat stub.
func NewEngine ¶
func NewEngine(scriptPubKey []byte, tx *wire.MsgTx, txIdx int, flags ScriptFlags, sigCache *SigCache, hashCache *TxSigHashes, inputAmount int64, prevOutFetcher PrevOutputFetcher) (*Engine, error)
NewEngine returns a new script engine. Compat stub.
type KeyClosure ¶
KeyClosure is a closure function type that provides keys.
type MultiPrevOutFetcher ¶
type MultiPrevOutFetcher struct {
// contains filtered or unexported fields
}
func NewMultiPrevOutFetcher ¶
func NewMultiPrevOutFetcher(tx *wire.MsgTx) *MultiPrevOutFetcher
func (*MultiPrevOutFetcher) AddPrevOut ¶
func (f *MultiPrevOutFetcher) AddPrevOut(op wire.OutPoint, txOut *wire.TxOut)
func (*MultiPrevOutFetcher) FetchPrevOutput ¶
func (f *MultiPrevOutFetcher) FetchPrevOutput(op wire.OutPoint) *wire.TxOut
type PrevOutputFetcher ¶
PrevOutputFetcher defines an interface for fetching previous output info.
type ScriptBuilder ¶
type ScriptBuilder []byte
func NewScriptBuilder ¶
func NewScriptBuilder() *ScriptBuilder
NewScriptBuilder returns a new ScriptBuilder.
func (*ScriptBuilder) AddData ¶
func (b *ScriptBuilder) AddData(data []byte) *ScriptBuilder
AddData adds the passed data as a data push to the script builder.
func (*ScriptBuilder) AddOp ¶
func (b *ScriptBuilder) AddOp(op byte) *ScriptBuilder
AddOp adds the passed opcode to the script builder.
func (*ScriptBuilder) Script ¶
func (b *ScriptBuilder) Script() ([]byte, error)
Script returns the built script. Compat stub.
type ScriptClass ¶
type ScriptClass int
func ExtractPkScriptAddrs ¶
func GetScriptClass ¶
func GetScriptClass(script []byte) (ScriptClass, error)
GetScriptClass returns the class of the script. Compat stub.
func (ScriptClass) String ¶
func (s ScriptClass) String() string
String returns the string representation of the ScriptClass.
type ScriptClosure ¶
ScriptClosure is a closure function type that provides scripts.
type SecretsSource ¶
type SigHashType ¶
type SigHashType uint32
type TapscriptType ¶
type TapscriptType uint8
type TxSigHashes ¶
type TxSigHashes struct{}
func NewTxSigHashes ¶
func NewTxSigHashes(tx *wire.MsgTx, fetcher PrevOutputFetcher) *TxSigHashes
type UtxoViewpoint ¶
type UtxoViewpoint struct{}