Help us shape the future of Go! Take the 2026 Go Developer Survey

contacts

package
v1.3.104-alpha1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package contacts pkg/contacts/contacts.go c3-vis-core

The visor's address book: the people its operator knows, with the skywire keys, mail addresses and payment addresses that reach them. One store serves the CLI, the hypervisor and the visor's apps, so a name set once shows everywhere.

Each contact is a vCard 4.0 file (RFC 6350), so a book exports to and imports from any address book. vCard has no field for a skywire key or a coin address, so those are X- properties; a skywire key is also written as an IMPP skychat URI (RFC 4770), which most clients show as a chat handle.

Local by design: nothing here is published or sent to a peer.

Package contacts pkg/contacts/store.go c3-vis-core

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("contact not found")

ErrNotFound is returned for a UID the book does not hold.

Functions

func KeyByName

func KeyByName(list []Contact, name string) (cipher.PubKey, error)

KeyByName finds the one key of the contact named name, matched without case. No match, several matching contacts, or a contact with no key or several keys is an error, since a message must not go to a guessed key.

func Names

func Names(list []Contact) map[string]string

Names maps each key in list to its contact's name, as key hex. When a key is on more than one contact the first in list wins, so pass List's name order.

Types

type Contact

type Contact struct {
	UID      string          `json:"uid"`
	Name     string          `json:"name"`
	Keys     []cipher.PubKey `json:"keys,omitempty"`
	Mail     []string        `json:"mail,omitempty"`
	Payments []Payment       `json:"payments,omitempty"`
	Groups   []string        `json:"groups,omitempty"`
	Notes    string          `json:"notes,omitempty"`
}

Contact is one person or service in the book.

func (Contact) HasKey

func (c Contact) HasKey(pk cipher.PubKey) bool

HasKey reports whether pk is one of the contact's keys.

type Payment

type Payment struct {
	// Coin is the address's URI scheme, e.g. "skycoin" or "bitcoin" (BIP 321).
	Coin    string `json:"coin"`
	Address string `json:"address"`
}

Payment is an address a contact can be paid at.

func ParsePayment

func ParsePayment(s string) (Payment, error)

ParsePayment reads a payment URI such as "bitcoin:bc1q...".

func (Payment) URI

func (p Payment) URI() string

URI is the payment as a URI, e.g. "skycoin:2jBbGxZ...".

type Store

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

Store is an address book kept as one <uid>.vcf file per contact in a directory only the visor's user can read: it is the operator's social graph.

func OpenStore

func OpenStore(dir string) (*Store, error)

OpenStore opens the book in dir, creating it.

func (*Store) Delete

func (s *Store) Delete(uid string) error

Delete removes the contact with uid.

func (*Store) Dir

func (s *Store) Dir() string

Dir is where the book is kept.

func (*Store) Export

func (s *Store) Export(w io.Writer) error

Export writes the whole book as one .vcf stream.

func (*Store) Import

func (s *Store) Import(r io.Reader) (int, error)

Import adds every vCard in r, replacing contacts that share a UID. Nothing is written unless every card reads.

func (*Store) List

func (s *Store) List() ([]Contact, error)

List returns every contact, sorted by name.

func (*Store) Put

func (s *Store) Put(c Contact) (Contact, error)

Put adds c, or replaces the contact with its UID. A contact without a UID gets one. It returns c as stored.

Jump to

Keyboard shortcuts

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