Documentation ¶
Index ¶
- Variables
- func DefaultCoinbaseProgram() ([]byte, error)
- func IsUnspendable(prog []byte) bool
- func P2PKHSigProgram(pubkeyHash []byte) ([]byte, error)
- func P2SHProgram(scriptHash []byte) ([]byte, error)
- func P2SPMultiSigProgram(pubkeys []ed25519.PublicKey, nrequired int) ([]byte, error)
- func P2WPKHProgram(hash []byte) ([]byte, error)
- func P2WSHProgram(hash []byte) ([]byte, error)
- func ParseP2SPMultiSigProgram(program []byte) ([]ed25519.PublicKey, int, error)
- type Builder
- func (b *Builder) AddData(data []byte) *Builder
- func (b *Builder) AddInt64(n int64) *Builder
- func (b *Builder) AddJump(target int) *Builder
- func (b *Builder) AddJumpIf(target int) *Builder
- func (b *Builder) AddOp(op vm.Op) *Builder
- func (b *Builder) AddRawBytes(data []byte) *Builder
- func (b *Builder) Build() ([]byte, error)
- func (b *Builder) NewJumpTarget() int
- func (b *Builder) SetJumpTarget(target int) *Builder
Constants ¶
This section is empty.
Variables ¶
var ( ErrBadValue = errors.New("bad value") ErrMultisigFormat = errors.New("bad multisig program format") )
pre-define errors
var ErrUnresolvedJump = errors.New("unresolved jump target")
Functions ¶
func DefaultCoinbaseProgram ¶ added in v0.4.0
DefaultCoinbaseProgram generates the script for contorl coinbase output
func IsUnspendable ¶
IsUnspendable checks if a contorl program is absolute failed
func P2PKHSigProgram ¶ added in v0.3.0
P2PKHSigProgram generates the script for control with pubkey hash
func P2SHProgram ¶ added in v0.4.0
P2SHProgram generates the script for control with script hash
func P2SPMultiSigProgram ¶
P2SPMultiSigProgram generates the script for contorl transaction output
func P2WPKHProgram ¶ added in v0.4.0
P2WPKHProgram return the segwit pay to public key hash
func P2WSHProgram ¶ added in v0.4.0
P2WSHProgram return the segwit pay to script hash
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func NewBuilder ¶
func NewBuilder() *Builder
func (*Builder) AddJump ¶
AddJump adds a JUMP opcode whose target is the given target number. The actual program location of the target does not need to be known yet, as long as SetJumpTarget is called before Build.
func (*Builder) AddJumpIf ¶
AddJump adds a JUMPIF opcode whose target is the given target number. The actual program location of the target does not need to be known yet, as long as SetJumpTarget is called before Build.
func (*Builder) AddRawBytes ¶
AddRawBytes simply appends the given bytes to the program. (It does not introduce a pushdata opcode.)
func (*Builder) Build ¶
Build produces the bytecode of the program. It first resolves any jumps in the program by filling in the addresses of their targets. This requires SetJumpTarget to be called prior to Build for each jump target used (in a call to AddJump or AddJumpIf). If any target's address hasn't been set in this way, this function produces ErrUnresolvedJump. There are no other error conditions.
func (*Builder) NewJumpTarget ¶
NewJumpTarget allocates a number that can be used as a jump target in AddJump and AddJumpIf. Call SetJumpTarget to associate the number with a program location.
func (*Builder) SetJumpTarget ¶
SetJumpTarget associates the given jump-target number with the current position in the program - namely, the program's length, such that the first instruction executed by a jump using this target will be whatever instruction is added next. It is legal for SetJumpTarget to be called at the end of the program, causing jumps using that target to fall off the end. There must be a call to SetJumpTarget for every jump target used before any call to Build.