fiox

package module
v0.0.0-...-475f5e4 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2020 License: MIT Imports: 22 Imported by: 0

README

fio-extras

fio-extras includes a keosd client, and helper for HD key derivation.

These were additions to the fio-go library that were removed because they cause OS incompatibilities, specifically with Windows. Because of either unix sockets or imports from go-ethereum that are exclusive to Unix-like systems, these won't run on Windows.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hd

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

Hd is an HD Wallet with BIP39 mnemonic phrase based on a BIP32 derivation path. Note: FIO uses m/44'/235'/0

func NewHdFromString

func NewHdFromString(mnemonic string) (*Hd, error)

NewHdFromString verifies a mnemonic string and creates a Hd containing a HD Wallet

func NewRandomHd

func NewRandomHd(words int) (*Hd, error)

NewRandomHd builds a new Hd with a specific word count (12, 15, 18, 21, or 24,) longer is better

func (Hd) KeyAt

func (hd Hd) KeyAt(index int) (*eos.KeyBag, error)

KeyAt creates a keybag holding a single key at m/44'/235'/0'/0/index

func (Hd) Keys

func (hd Hd) Keys(keys int) (*eos.KeyBag, error)

Keys provides a keybag with the requested number of keys, use KeyAt for a single key

func (Hd) Len

func (hd Hd) Len() int

func (Hd) PubKeyAt

func (hd Hd) PubKeyAt(index int) (*ecc.PublicKey, error)

PubKeyAt derives a public key at a specific location - m/44'/235'/0'/0/index

func (Hd) PubKeys

func (hd Hd) PubKeys(count int) ([]*ecc.PublicKey, error)

PubKeys derives a number of public keys for the Hd

func (Hd) Quiz

func (hd Hd) Quiz(count int) (questions []HdQuiz, err error)

Quiz generates a number of randomized quiz questions, if less than one is provided, it uses hd.Len()/3

func (Hd) String

func (hd Hd) String() string

func (Hd) Xpriv

func (hd Hd) Xpriv() (string, error)

Xpriv is the bip32 root key as a string, this may not import for bip44 compatible wallets, that is a planned addition.

func (Hd) Xpub

func (hd Hd) Xpub() (string, error)

Xpub is the bip32 root public key as a string, some wallets will expect a bip44 xpub or the bip32 derivation xpub key, these are planned additions.

type HdQuiz

type HdQuiz struct {
	Description string
	Check       func(s string) bool // function confirming correct answer
	// contains filtered or unexported fields
}

HdQuiz is used for prompting a user to confirm the mnemonic phrase by providing a description of which word to provide and a function to validate their answer

type KeosClient

type KeosClient struct {
	BaseUrl    string
	HttpClient *http.Client
	Socket     string
	Keys       map[string]KeosKeys `json:"-"`
	Wallet     string
	// contains filtered or unexported fields
}

func NewKeosClient

func NewKeosClient(keosUrl string, socket string) *KeosClient

NewKeosClient provides a connection to keosd. It allows either a Unix socket or a TCP connection.

func (*KeosClient) GetKeys

func (k *KeosClient) GetKeys(nodeosApi *fio.API) error

GetKeys populates the list of keys stored in the wallet

func (*KeosClient) PrintKeys

func (k *KeosClient) PrintKeys() string

PrintKeys provides a human readable list of keys in a wallet

func (KeosClient) Start

func (k KeosClient) Start(noKeosd bool) error

Start attempts to launch the keosd process by spawning clio

func (*KeosClient) Unlock

func (k *KeosClient) Unlock(password string, wallet string) error

Unlock opens a locked keos wallet, it does not return an error if already unlocked

type KeosKeys

type KeosKeys struct {
	PublicKey  string `json:"public_key"`
	PrivateKey string `json:"private_key"`
	FioAddress string `json:"fio_address"`
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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