address

package
v0.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2024 License: MIT Imports: 9 Imported by: 8

Documentation

Index

Constants

View Source
const (
	P2Pkh = iota
	P2Sh
	ConfidentialP2Pkh
	ConfidentialP2Sh
	P2Wpkh
	P2Wsh
	ConfidentialP2Wpkh
	ConfidentialP2Wsh
	P2TR
	ConfidentialP2TR
)
View Source
const (
	P2PkhScript = iota + 1
	P2ShScript
	P2MultiSigScript
	P2WpkhScript
	P2WshScript
	P2TRScript
)
View Source
const (
	OP_SHA256INITIALIZE = 0xc4
	OP_SHA256UPDATE     = 0xc5
	OP_SHA256FINALIZE   = 0xc6

	// Introspection opcodes
	// inputs
	OP_INSPECTINPUTOUTPOINT     = 0xc7
	OP_INSPECTINPUTASSET        = 0xc8
	OP_INSPECTINPUTVALUE        = 0xc9
	OP_INSPECTINPUTSCRIPTPUBKEY = 0xca
	OP_INSPECTINPUTSEQUENCE     = 0xcb
	OP_INSPECTINPUTISSUANCE     = 0xcc
	OP_PUSHCURRENTINPUTINDEX    = 0xcd

	// outputs
	OP_INSPECTOUTPUTASSET        = 0xce
	OP_INSPECTOUTPUTVALUE        = 0xcf
	OP_INSPECTOUTPUTNONCE        = 0xd0
	OP_INSPECTOUTPUTSCRIPTPUBKEY = 0xd1

	// transaction
	OP_INSPECTVERSION    = 0xd2
	OP_INSPECTLOCKTIME   = 0xd3
	OP_INSPECTNUMINPUTS  = 0xd4
	OP_INSPECTNUMOUTPUTS = 0xd5
	OP_TXWEIGHT          = 0xd6

	// Arithmetic opcodes
	OP_ADD64                = 0xd7
	OP_SUB64                = 0xd8
	OP_MUL64                = 0xd9
	OP_DIV64                = 0xda
	OP_NEG64                = 0xdb
	OP_LESSTHAN64           = 0xdc
	OP_LESSTHANOREQUAL64    = 0xdd
	OP_GREATERTHAN64        = 0xde
	OP_GREATERTHANOREQUAL64 = 0xdf

	// Conversion opcodes
	OP_SCRIPTNUMTOLE64 = 0xe0
	OP_LE64TOSCRIPTNUM = 0xe1
	OP_LE32TOLE64      = 0xe2
)

elements tapscript opcodes

View Source
const (
	// MaxDataCarrierSize is the maximum number of bytes allowed in pushed
	// Data to be considered a nulldata transaction
	MaxDataCarrierSize = 80
)

Variables

This section is empty.

Functions

func DecodeType added in v0.0.3

func DecodeType(address string) (int, error)

DecodeType returns address type

func GetScriptType added in v0.0.4

func GetScriptType(script []byte) int

GetScriptType returns the type of the given script (p2pkh, p2sh, etc.)

func IsConfidential added in v0.1.0

func IsConfidential(address string) (bool, error)

IsConfidential checks whether the given address is confidential

func IsMultiSig added in v0.3.0

func IsMultiSig(pops []ParsedOpcode) bool

IsMultiSig returns true if the passed script is a multisig transaction, false otherwise.

func IsPubkey added in v0.3.0

func IsPubkey(pops []ParsedOpcode) bool

IsPubkey returns true if the script passed is a pay-to-pubkey transaction, false otherwise.

func IsPubkeyHash added in v0.3.0

func IsPubkeyHash(pops []ParsedOpcode) bool

IsPubkeyHash returns true if the script passed is a pay-to-pubkey-hash transaction, false otherwise.

func IsScriptHash added in v0.3.0

func IsScriptHash(pops []ParsedOpcode) bool

IsScriptHash returns true if the script passed is a pay-to-script-hash transaction, false otherwise.

func IsWitnessPubKeyHash added in v0.3.0

func IsWitnessPubKeyHash(pops []ParsedOpcode) bool

IsWitnessPubKeyHash returns true if the passed script is a pay-to-witness-pubkey-hash, and false otherwise.

func IsWitnessScriptHash added in v0.3.0

func IsWitnessScriptHash(pops []ParsedOpcode) bool

IsWitnessScriptHash returns true if the passed script is a pay-to-witness-script-hash transaction, false otherwise.

func NetworkForAddress added in v0.0.4

func NetworkForAddress(address string) (*network.Network, error)

NetworkForAddress returns the network based on the prefix of the given address

func ToBase58

func ToBase58(b *Base58) string

ToBase58 prepends a version byte and appends a four byte checksum.

func ToBase58Confidential added in v0.0.4

func ToBase58Confidential(b *Base58Confidential) string

ToBase58Confidential prepends a version byte and appends a four byte checksum.

func ToBech32

func ToBech32(bc *Bech32) (string, error)

ToBech32 encodes a byte slice into a bech32 string with the human-readable part hrb. Note that the bytes must each encode 5 bits

func ToBlech32 added in v0.0.2

func ToBlech32(bl *Blech32) (string, error)

ToBlech32 encodes a byte slice into a blech32 string

func ToConfidential added in v0.0.4

func ToConfidential(ca *AddressInfo) (string, error)

ToConfidential returns the confidential address formed by the given unconfidential address and blinding public key

func ToOutputScript added in v0.0.3

func ToOutputScript(address string) ([]byte, error)

ToOutputScript creates a new script to pay a transaction output to a the specified address

Types

type AddressInfo added in v0.4.1

type AddressInfo struct {
	Address     string
	Script      []byte
	BlindingKey []byte
}

AddressInfo holds info about a receiving address.

func FromConfidential added in v0.0.4

func FromConfidential(address string) (*AddressInfo, error)

FromConfidential returns the unconfidential address and the blinding public key that form the confidential address

type Base58

type Base58 struct {
	Version byte
	Data    []byte
}

Base58 type defines the structure of a legacy or wrapped segwit address

func FromBase58

func FromBase58(address string) (*Base58, error)

FromBase58 decodes a string that was base58 encoded and verifies the checksum.

type Base58Confidential added in v0.0.4

type Base58Confidential struct {
	Base58
	Version   byte
	PublicKey []byte
}

Base58Confidential type defines the structure of a legacy or wrapped segwit confidential address

func FromBase58Confidential added in v0.0.4

func FromBase58Confidential(address string) (*Base58Confidential, error)

FromBase58Confidential decodes a confidenail address that was base58 encoded and verifies the checksum.

type Bech32

type Bech32 struct {
	Prefix  string
	Version byte
	Program []byte
}

Bech32 defines the structure of an address native segwit

func FromBech32

func FromBech32(address string) (*Bech32, error)

FromBech32 decodes a bech32 encoded string, returning the human-readable part and the Data part excluding the checksum.

type Blech32

type Blech32 struct {
	Prefix    string
	Version   byte
	PublicKey []byte
	Program   []byte
}

Blech32 defines the structure of a confidential address native segwit

func FromBlech32 added in v0.0.2

func FromBlech32(address string) (*Blech32, error)

FromBlech32 decodes a blech32 encoded string, returning the human-readable part and the Data part excluding the checksum.

type Opcode added in v0.3.0

type Opcode struct {
	Value  byte
	Name   string
	Length int
}

An Opcode defines the information related to a txscript Opcode. opfunc, if present, is the function to call to perform the Opcode on the script. The current script is passed in as a slice with the first member being the Opcode itself.

type ParsedOpcode added in v0.3.0

type ParsedOpcode struct {
	Opcode *Opcode
	Data   []byte
}

ParsedOpcode represents an Opcode that has been parsed and includes any potential Data associated with it.

func ParseScript added in v0.3.0

func ParseScript(script []byte) ([]ParsedOpcode, error)

parseScript preparses the script in bytes into a list of parsedOpcodes while applying a number of sanity checks.

type ScriptClass added in v0.3.0

type ScriptClass byte

ScriptClass is an enumeration for the list of standard types of script.

const (
	NonStandardTy         ScriptClass = iota // None of the recognized forms.
	PubKeyTy                                 // Pay pubkey.
	PubKeyHashTy                             // Pay pubkey hash.
	WitnessV0PubKeyHashTy                    // Pay witness pubkey hash.
	ScriptHashTy                             // Pay to script hash.
	WitnessV0ScriptHashTy                    // Pay to witness script hash.
	MultiSigTy                               // Multi signature.
	NullDataTy                               // Empty Data-only (provably prunable).
)

Classes of script payment known about in the blockchain.

func TypeOfScript added in v0.3.0

func TypeOfScript(pops []ParsedOpcode) ScriptClass

scriptType returns the type of the script being inspected from the known standard types.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL