zcash

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// MainNetParams defines the mainnet configuration.
	MainNetParams = Params{
		Params: &chaincfg.MainNetParams,

		P2PKHPrefix: []byte{0x1C, 0xB8},
		P2SHPrefix:  []byte{0x1C, 0xBD},
		Upgrades: []ParamsUpgrade{
			{0, []byte{0x00, 0x00, 0x00, 0x00}},
			{347500, []byte{0x19, 0x1B, 0xA8, 0x5B}},
			{419200, []byte{0xBB, 0x09, 0xB8, 0x76}},
			{653600, []byte{0x60, 0x0E, 0xB4, 0x2B}},
			{903000, []byte{0x0B, 0x23, 0xB9, 0xF5}},
			{1046400, []byte{0xA6, 0x75, 0xff, 0xe9}},
		},
	}

	// TestNet3Params defines the testnet configuration.
	TestNet3Params = Params{
		Params: &chaincfg.TestNet3Params,

		P2PKHPrefix: []byte{0x1D, 0x25},
		P2SHPrefix:  []byte{0x1C, 0xBA},
		Upgrades: []ParamsUpgrade{
			{0, []byte{0x00, 0x00, 0x00, 0x00}},
			{207500, []byte{0x19, 0x1B, 0xA8, 0x5B}},
			{280000, []byte{0xBB, 0x09, 0xB8, 0x76}},
			{584000, []byte{0x60, 0x0E, 0xB4, 0x2B}},
			{903800, []byte{0x0B, 0x23, 0xB9, 0xF5}},
			{1028500, []byte{0xA6, 0x75, 0xff, 0xe9}},
		},
	}

	// RegressionNetParams defines a devet/regnet configuration.
	RegressionNetParams = Params{
		Params: &chaincfg.RegressionNetParams,

		P2PKHPrefix: []byte{0x1D, 0x25},
		P2SHPrefix:  []byte{0x1C, 0xBA},
		Upgrades: []ParamsUpgrade{
			{0, []byte{0x00, 0x00, 0x00, 0x00}},
			{10, []byte{0x19, 0x1B, 0xA8, 0x5B}},
			{20, []byte{0xBB, 0x09, 0xB8, 0x76}},
			{30, []byte{0x60, 0x0E, 0xB4, 0x2B}},
			{40, []byte{0x0B, 0x23, 0xB9, 0xF5}},
			{50, []byte{0xA6, 0x75, 0xff, 0xe9}},
		},
	}
)

Functions

func DecodeAddress

func DecodeAddress(addr string, defaultNet *Params) (btcutil.Address, error)

func ExtractPkScriptAddrs

func ExtractPkScriptAddrs(pkScript []byte, chainParams *Params) (btcutil.Address, error)

ExtractPkScriptAddrs returns the type of script, addresses and required signatures associated with the passed PkScript. Note that it only works for 'standard' transaction script types. Any data such as public keys which are invalid are omitted from the results.

Types

type Address

type Address interface {
	btcutil.Address
	BitcoinAddress() btcutil.Address
}

An Address represents a Zcash address.

type AddressDecoder

type AddressDecoder struct {
	// contains filtered or unexported fields
}

AddressDecoder encapsulates the chain specific configurations and implements the address.Decoder interface

func NewAddressDecoder

func NewAddressDecoder(params *Params) AddressDecoder

NewAddressDecoder constructs a new AddressDecoder with the chain specific configurations

func (AddressDecoder) DecodeAddress

func (decoder AddressDecoder) DecodeAddress(addr address.Address) (address.RawAddress, error)

DecodeAddress implements the address.Decoder interface

type AddressEncodeDecoder

type AddressEncodeDecoder struct {
	AddressEncoder
	AddressDecoder
}

AddressEncodeDecoder implements the address.EncodeDecoder interface

func NewAddressEncodeDecoder

func NewAddressEncodeDecoder(params *Params) AddressEncodeDecoder

NewAddressEncodeDecoder constructs a new AddressEncodeDecoder with the chain specific configurations

type AddressEncoder

type AddressEncoder struct {
	// contains filtered or unexported fields
}

AddressEncoder encapsulates the chain specific configurations and implements the address.Encoder interface

func NewAddressEncoder

func NewAddressEncoder(params *Params) AddressEncoder

NewAddressEncoder constructs a new AddressEncoder with the chain specific configurations

func (AddressEncoder) EncodeAddress

func (encoder AddressEncoder) EncodeAddress(rawAddr address.RawAddress) (address.Address, error)

EncodeAddress implements the address.Encoder interface

type AddressPubKeyHash

type AddressPubKeyHash struct {
	*btcutil.AddressPubKeyHash
	// contains filtered or unexported fields
}

AddressPubKeyHash represents an address for P2PKH transactions for Zcash that is compatible with the Bitcoin Compat API.

func NewAddressPubKeyHash

func NewAddressPubKeyHash(pkh []byte, params *Params) (AddressPubKeyHash, error)

NewAddressPubKeyHash returns a new AddressPubKeyHash that is compatible with the Bitcoin Compat API.

func (AddressPubKeyHash) BitcoinAddress

func (addr AddressPubKeyHash) BitcoinAddress() btcutil.Address

BitcoinAddress returns the address as if it was a Bitcoin address.

func (AddressPubKeyHash) EncodeAddress

func (addr AddressPubKeyHash) EncodeAddress() string

EncodeAddress returns the string encoding of the payment address associated with the Address value. See the comment on String for how this method differs from String.

func (AddressPubKeyHash) IsForNet

func (addr AddressPubKeyHash) IsForNet(params *chaincfg.Params) bool

IsForNet returns whether or not the address is associated with the passed bitcoin network.

func (AddressPubKeyHash) ScriptAddress

func (addr AddressPubKeyHash) ScriptAddress() []byte

ScriptAddress returns the raw bytes of the address to be used when inserting the address into a txout's script.

func (AddressPubKeyHash) String

func (addr AddressPubKeyHash) String() string

String returns the string encoding of the transaction output destination.

Please note that String differs subtly from EncodeAddress: String will return the value as a string without any conversion, while EncodeAddress may convert destination types (for example, converting pubkeys to P2PKH addresses) before encoding as a payment address string.

type AddressScriptHash

type AddressScriptHash struct {
	*btcutil.AddressScriptHash
	// contains filtered or unexported fields
}

AddressScriptHash represents an address for P2SH transactions for Zcash that is compatible with the Bitcoin Compat API.

func NewAddressScriptHash

func NewAddressScriptHash(script []byte, params *Params) (AddressScriptHash, error)

NewAddressScriptHash returns a new AddressScriptHash that is compatible with the Bitcoin Compat API.

func NewAddressScriptHashFromHash

func NewAddressScriptHashFromHash(scriptHash []byte, params *Params) (AddressScriptHash, error)

NewAddressScriptHashFromHash returns a new AddressScriptHash that is compatible with the Bitcoin Compat API.

func (AddressScriptHash) BitcoinAddress

func (addr AddressScriptHash) BitcoinAddress() btcutil.Address

BitcoinAddress returns the address as if it was a Bitcoin address.

func (AddressScriptHash) EncodeAddress

func (addr AddressScriptHash) EncodeAddress() string

EncodeAddress returns the string encoding of the payment address associated with the Address value. See the comment on String for how this method differs from String.

func (AddressScriptHash) IsForNet

func (addr AddressScriptHash) IsForNet(params *chaincfg.Params) bool

IsForNet returns whether or not the address is associated with the passed bitcoin network.

func (AddressScriptHash) ScriptAddress

func (addr AddressScriptHash) ScriptAddress() []byte

ScriptAddress returns the raw bytes of the address to be used when inserting the address into a txout's script.

func (AddressScriptHash) String

func (addr AddressScriptHash) String() string

String returns the string encoding of the transaction output destination.

Please note that String differs subtly from EncodeAddress: String will return the value as a string without any conversion, while EncodeAddress may convert destination types (for example, converting pubkeys to P2PKH addresses) before encoding as a payment address string.

type Params

type Params struct {
	// TODO: We do not actually need to embed the entire chaincfg params object.
	*chaincfg.Params

	P2SHPrefix  []byte
	P2PKHPrefix []byte
	Upgrades    []ParamsUpgrade
}

Params signifies the chain specific parameters of the Zcash network.

type ParamsUpgrade

type ParamsUpgrade struct {
	ActivationHeight uint32
	BranchID         []byte
}

ParamsUpgrade ...

Jump to

Keyboard shortcuts

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