Documentation ¶
Index ¶
- Variables
- func VariableNatDecode(raw []byte) (uint64, int, error)
- func VariableNatEncode(num uint64) []byte
- type Address
- type BaseAddress
- func (b *BaseAddress) Bytes() []byte
- func (b *BaseAddress) MarshalCBOR() ([]byte, error)
- func (b *BaseAddress) NetworkInfo() *network.NetworkInfo
- func (b *BaseAddress) Prefix() string
- func (b *BaseAddress) String() string
- func (b *BaseAddress) ToEnterprise() (addr *EnterpriseAddress)
- func (b *BaseAddress) ToReward() (addr *RewardAddress)
- type ByronAddress
- func (b *ByronAddress) Bytes() (bytes []byte)
- func (b *ByronAddress) MarshalCBOR() (bytes []byte, err error)
- func (b *ByronAddress) NetworkInfo() (ni *network.NetworkInfo)
- func (b *ByronAddress) Prefix() string
- func (b *ByronAddress) String() (str string)
- func (b *ByronAddress) UnmarshalCBOR(data []byte) error
- type ByronAddressAttributes
- type EnterpriseAddress
- type PointerAddress
- type RewardAddress
- type StakeCredential
- type StakeCredentialType
- type StakePointer
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidByronAddress = errors.New("invalid byron address") ErrInvalidByronChecksum = errors.New("invalid byron checksum") )
var (
ErrUnsupportedAddress = errors.New("invalid/unsupported address type")
)
Functions ¶
func VariableNatEncode ¶
Types ¶
type Address ¶
type Address interface { cbor.Marshaler // Bytes returns raw bytes for use in tx_outputs Bytes() []byte // String returns bech32 encoded human readable string String() string // NetworkInfo returns NetworkInfo with networks network id and protocol magic NetworkInfo() *network.NetworkInfo }
func NewAddress ¶
func NewAddressFromBytes ¶
func NewAddressFromHex ¶
type BaseAddress ¶
type BaseAddress struct { Network network.NetworkInfo Payment StakeCredential Stake StakeCredential }
BaseAddress contains information of the base address. A base address directly specifies the staking key that should control the stake for that address but can be used for transactions without registering the staking key in advance.
func NewBaseAddress ¶
func NewBaseAddress(network *network.NetworkInfo, payment *StakeCredential, stake *StakeCredential) *BaseAddress
NewBaseAddress returns a pointer to a new BaseAddress given the network, payment and stake credentials.
func (*BaseAddress) Bytes ¶
func (b *BaseAddress) Bytes() []byte
Bytes returns a length 57 byte slice represantation of the Address.
func (*BaseAddress) MarshalCBOR ¶
func (b *BaseAddress) MarshalCBOR() ([]byte, error)
MarshalCBOR returns a cbor encoded byte slice of the base address.
func (*BaseAddress) NetworkInfo ¶
func (b *BaseAddress) NetworkInfo() *network.NetworkInfo
NetworkInfo returns NetworkInfo{ProtocolMagigic and NetworkId}.
func (*BaseAddress) Prefix ¶
func (b *BaseAddress) Prefix() string
Prefix returns the string prefix for the base address. Prefix `addr` for mainnet addresses and `addr_test` for testnet.
func (*BaseAddress) String ¶
func (b *BaseAddress) String() string
String returns a bech32 encoded string of the Enterprise Address.
func (*BaseAddress) ToEnterprise ¶
func (b *BaseAddress) ToEnterprise() (addr *EnterpriseAddress)
ToEnterprise returns the Enterprise Address from the base address. This is equivalent to removing the stake part of the base address.
func (*BaseAddress) ToReward ¶
func (b *BaseAddress) ToReward() (addr *RewardAddress)
ToReward returns the RewardAddress from the base address. This is equivalent to removing the payment part of the base address.
type ByronAddress ¶
type ByronAddress struct { Hash []byte Attributes ByronAddressAttributes Tag uint }
func (*ByronAddress) Bytes ¶
func (b *ByronAddress) Bytes() (bytes []byte)
Bytes returns byte slice represantation of the Address.
func (*ByronAddress) MarshalCBOR ¶
func (b *ByronAddress) MarshalCBOR() (bytes []byte, err error)
MarshalCBOR returns a cbor encoded byte slice of the base address.
func (*ByronAddress) NetworkInfo ¶
func (b *ByronAddress) NetworkInfo() (ni *network.NetworkInfo)
NetworkInfo returns NetworkInfo{ProtocolMagigic and NetworkId}.
func (*ByronAddress) Prefix ¶
func (b *ByronAddress) Prefix() string
Pref returns the string prefix for the base address. "" for byron address since it has no prefix.
func (*ByronAddress) String ¶
func (b *ByronAddress) String() (str string)
String returns base58 encoded byron address.
func (*ByronAddress) UnmarshalCBOR ¶
func (b *ByronAddress) UnmarshalCBOR(data []byte) error
UnmarshalCBOR deserializes raw byron address, encoded in cbor, into a Byron Address.
type ByronAddressAttributes ¶
type EnterpriseAddress ¶
type EnterpriseAddress struct { Network network.NetworkInfo Payment StakeCredential }
EnterpriseAddress contains content for enterprise addresses. Enterprise addresses carry no stake rights, so using these addresses means that you are opting out of participation in the proof-of-stake protocol.
func NewEnterpriseAddress ¶
func NewEnterpriseAddress(network *network.NetworkInfo, payment *StakeCredential) *EnterpriseAddress
NewEnterpriseAddress returns a pointer to a new Enterprise Address given the network and payment.
func (*EnterpriseAddress) Bytes ¶
func (e *EnterpriseAddress) Bytes() []byte
Bytes returns a length 29 byte slice represantation of the Address.
func (*EnterpriseAddress) MarshalCBOR ¶
func (e *EnterpriseAddress) MarshalCBOR() (bytes []byte, err error)
MarshalCBOR returns a cbor encoded byte slice of the enterprise address.
func (*EnterpriseAddress) NetworkInfo ¶
func (e *EnterpriseAddress) NetworkInfo() *network.NetworkInfo
NetworkInfo returns NetworkInfo{ProtocolMagigic and NetworkId}.
func (*EnterpriseAddress) Prefix ¶
func (e *EnterpriseAddress) Prefix() string
Prefix returns the string prefix for the Enterprise Address. Prefix `addr` for mainnet addresses and `addr_test` for testnet.
func (*EnterpriseAddress) String ¶
func (e *EnterpriseAddress) String() string
String returns a bech32 encoded string of the Enterprise Address.
type PointerAddress ¶
type PointerAddress struct { Network network.NetworkInfo Payment StakeCredential Stake StakePointer }
A pointer address indirectly specifies the staking key that should control the stake for the address.
func NewPointerAddress ¶
func NewPointerAddress(net network.NetworkInfo, payment StakeCredential, stake StakePointer) *PointerAddress
NewPointerAddress returns a pointer to a new Pointer address given the network, payment and stake credentials.
func (*PointerAddress) Bytes ¶
func (p *PointerAddress) Bytes() (bytes []byte)
Bytes retuns a byte slice representation of the pointer address.
func (*PointerAddress) MarshalCBOR ¶
func (p *PointerAddress) MarshalCBOR() (bytes []byte, err error)
MarshalCBOR returns a cbor encoded byte slice of the enterprise address.
func (*PointerAddress) NetworkInfo ¶
func (p *PointerAddress) NetworkInfo() *network.NetworkInfo
NetworkInfo returns NetworkInfo{ProtocolMagigic and NetworkId}.
func (*PointerAddress) Prefix ¶
func (p *PointerAddress) Prefix() string
Prefix returns the string prefix for the base address. Prefix `addr` for mainnet addresses and `addr_test` for testnet.
func (*PointerAddress) String ¶
func (p *PointerAddress) String() string
String returns a bech32 encoded string of the Enterprise Address.
type RewardAddress ¶
type RewardAddress struct { Network network.NetworkInfo Stake StakeCredential }
RewardAddress contains content of the reward/staking address. Reward account addresses are used to distribute rewards for participating in the proof-of-stake protocol (either directly or via delegation).
func NewRewardAddress ¶
func NewRewardAddress(net *network.NetworkInfo, stake *StakeCredential) *RewardAddress
NewRewardAddress returns a pointer to a new RewardAddress given the network and stake credentials.
func (*RewardAddress) Bytes ¶
func (r *RewardAddress) Bytes() []byte
Bytes returns a length 29 byte slice represantation of the Address.
func (*RewardAddress) MarshalCBOR ¶
func (r *RewardAddress) MarshalCBOR() ([]byte, error)
MarshalCBOR returns a cbor encoded byte slice of the base address.
func (*RewardAddress) NetworkInfo ¶
func (r *RewardAddress) NetworkInfo() *network.NetworkInfo
NetworkInfo returns pointer to NetworkInfo{ProtocolMagigic and NetworkId}.
func (*RewardAddress) Prefix ¶
func (r *RewardAddress) Prefix() string
Prefix returns the string prefix for the base address. Prefix `stake` for mainnet addresses and `stake_test` for testnet.
func (*RewardAddress) String ¶
func (r *RewardAddress) String() string
String returns a bech32 encoded string of the reward address.
type StakeCredential ¶
type StakeCredential struct { Kind StakeCredentialType `cbor:"0,keyasint,omitempty"` Payload []byte `cbor:"1,keyasint,omitempty"` }
func NewKeyStakeCredential ¶
func NewKeyStakeCredential(hash []byte) *StakeCredential
func NewScriptStakeCredential ¶
func NewScriptStakeCredential(hash []byte) *StakeCredential
type StakeCredentialType ¶
type StakeCredentialType byte
const ( KeyStakeCredentialType StakeCredentialType = iota ScriptStakeCredentialType )
type StakePointer ¶
func NewPointer ¶
func NewPointer(slot, txIndex, certIndex uint64) *StakePointer
NewPointer returns a pointer to a new StakePointer given slot, transaction index and certificate index.