Address

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

View Source
const (
	BYRON          = 0b1000
	KEY_KEY        = 0b0000
	SCRIPT_KEY     = 0b0001
	KEY_SCRIPT     = 0b0010
	SCRIPT_SCRIPT  = 0b0011
	KEY_POINTER    = 0b0100
	SCRIPT_POINTER = 0b0101
	KEY_NONE       = 0b0110
	SCRIPT_NONE    = 0b0111
	NONE_KEY       = 0b1110
	NONE_SCRIPT    = 0b1111
)
View Source
const (
	MAINNET = 1
	TESTNET = 0
)

Variables

This section is empty.

Functions

func ComputeHrp

func ComputeHrp(address_type uint8, network uint8) string

*

ComputeHrp computes the human-readable part (Hrp) for an address
based on its address type and network.

Params:
 	address_type (uint8): The type of the address.
	network (uint8): The network identifier (1 for mainnet, 0 for testnet).

Returns:
	string: The computed Hrp for address encoding.

Types

type Address

type Address struct {
	PaymentPart []byte
	StakingPart []byte
	Network     byte
	AddressType byte
	HeaderByte  byte
	Hrp         string
}

func DecodeAddress

func DecodeAddress(value string) (Address, error)

*

This function decodes a string representation of an address into its corresponding Address structure.

Parameters:
	value (string): The string representation of the address to decode.

Returns:
	Address: The decoded Address structure.
	error: An error, if any, encountered during the decoding process.

func WalletAddressFromBytes added in v1.0.5

func WalletAddressFromBytes(payment []byte, staking []byte, network constants.Network) *Address

func (Address) Bytes

func (addr Address) Bytes() []byte

*

This function returns the binary representation of the address. It
constructs and returns the binary representation of teh address containing
the header byte, payment part, and staking part (if present).

Returns:
	[]byte: A byte slice representing the binary data of the address.

func (*Address) Debug

func (addr *Address) Debug() string

*

Debug method returns a formatted string representation of the address for debugging

Returns:
	string: A formatted debug string representing the address.

func (*Address) Equal

func (addr *Address) Equal(other *Address) bool

func (*Address) MarshalCBOR

func (addr *Address) MarshalCBOR() ([]byte, error)

*

	MarshalCBOR encodes an address to its CBOR (Concise Binary Object Representation) format.

	Returns:
	   	[]byte: A slice of bytes representing the address in CBOR format.
  		error: An error, if any, encountered during the encoding process.

func (Address) String

func (addr Address) String() string

*

This function returns the string representation of the address.

Returns:
	string: A string representing the address in Bech32 format.

func (*Address) ToCbor

func (addr *Address) ToCbor() (string, error)

*

It converts an address to its CBOR (Concise Binary Object Representation) format and returns
it as a hexadecimal string. This function marshals the address into its binary representation
using the CBOR encoding. In case of success, it returns the binary data encoded as a
hexadecimal string, otherwise a fatal error is logged.

Returns:
	string: A hexadecimal string representation of the address in CBOR format.
	error: An error if the convertion fails.

func (*Address) UnmarshalCBOR

func (addr *Address) UnmarshalCBOR(value []byte) error

*

UnmarshalCBOR decodes a CBOR (Concise Binary Object Representation) encoded address from a byte slice.

Params:
	value ([]byte): A byte slice containing the CBOR-encoded address.

Returns:
	error: An error, if any, encountered during the decoding process.

Jump to

Keyboard shortcuts

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