address

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2019 License: BSD-2-Clause, BSD-3-Clause, ISC, + 2 more Imports: 8 Imported by: 1

Documentation

Overview

Address is able to maintain a list of AddressNamePairs, which consists of an address (Factoid or EC), a name, and a boolean flag to indicate if it is a seeded address. The list is able to be marshaled into binary for saving

Index

Constants

View Source
const MaxNameLength int = 20

MaxNameLength is the longest a name is allowed to be.

Variables

View Source
var IllegalCharacters = `!@#$%^&*()+=';:.,?/*<>"'[]{}~|\ ` + "`"

Functions

This section is empty.

Types

type AddressList

type AddressList struct {
	Length uint64
	List   []AddressNamePair
}

func NewAddressList

func NewAddressList() *AddressList

func (*AddressList) Add

func (addList *AddressList) Add(name string, address string) (*AddressNamePair, error)

Add is called when an address is not seeded.

func (*AddressList) AddANP

func (addList *AddressList) AddANP(anp *AddressNamePair) error

AddANP ensures the address is valid before it adds it. It will also not add a duplicate address

func (*AddressList) AddSeeded

func (addList *AddressList) AddSeeded(name string, address string) (*AddressNamePair, error)

AddSeeded should be called when an address is seeded, as this will set the seeded flag

func (*AddressList) Get

func (addList *AddressList) Get(address string) (*AddressNamePair, int)

Get searches for Address by Address, not by name

func (*AddressList) IsSameAs

func (addList *AddressList) IsSameAs(b *AddressList) bool

IsSameAs will call the IsSameAs for individual elemtents, meaning it will compare length, addresses, names, AND order

func (*AddressList) MarshalBinary

func (addList *AddressList) MarshalBinary() (data []byte, err error)

func (*AddressList) Remove

func (addList *AddressList) Remove(removeAdd string) error

func (*AddressList) ResetSeeded

func (addList *AddressList) ResetSeeded()

ResetSeeded is used when importing a new seed. This will set all addresses to be unseeded.

func (*AddressList) UnmarshalBinary

func (addList *AddressList) UnmarshalBinary(data []byte) (err error)

func (*AddressList) UnmarshalBinaryData

func (addList *AddressList) UnmarshalBinaryData(data []byte) (newData []byte, err error)

type AddressNamePair

type AddressNamePair struct {
	Name    string // Length maxNameLength Characters
	Address string
	Seeded  bool // Derived from seeed

	// Not Marshaled
	Balance int64 // Unused except for JSON return
}

AddressNamePair represents a public address to a user readable name. Also contains whether is was generated by the seed.

func NewAddress

func NewAddress(name string, address string) (*AddressNamePair, error)

NewAddress used if addresses DOES NOT derives from the seed

func NewSeededAddress

func NewSeededAddress(name string, address string) (*AddressNamePair, error)

NewSeededAddress used if addresses derives from the seed

func (*AddressNamePair) ChangeName

func (anp *AddressNamePair) ChangeName(name string) error

ChangeName should be used instead of manually changing the name, as ChangeName ensure the new name is of an appropriate length

func (*AddressNamePair) IsSameAs

func (anp *AddressNamePair) IsSameAs(b *AddressNamePair) bool

IsSameAs will compare addresses and names

func (*AddressNamePair) IsSimilarTo

func (anp *AddressNamePair) IsSimilarTo(b *AddressNamePair) bool

IsSimilarTo will ONLY compare addresses, not names or seeded.

func (*AddressNamePair) MarshalBinary

func (anp *AddressNamePair) MarshalBinary() (data []byte, err error)

MarshalBinary will convert an AddressNamePair to a []byte, which can be unmarshaled

func (*AddressNamePair) UnmarshalBinary

func (anp *AddressNamePair) UnmarshalBinary(data []byte) (err error)

func (*AddressNamePair) UnmarshalBinaryData

func (anp *AddressNamePair) UnmarshalBinaryData(data []byte) (newData []byte, err error)

Jump to

Keyboard shortcuts

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