wallet

package
v0.0.0-...-07263e3 Latest Latest
Warning

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

Go to latest
Published: May 14, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base58Decode

func Base58Decode(input []byte) []byte

func Base58Encode

func Base58Encode(input []byte) []byte

Base58 was invented with Bitcoin. It's a derivative of the base 64 algorithm except the main difference is that it uses 6 less characters inside its alphabet: O 0 1 I + /

func Checksum

func Checksum(payload []byte) []byte

func NewKeyPair

func NewKeyPair() (ecdsa.PrivateKey, []byte)

Generates a new private / public key pair. In theory we can create up to 10^77 different keys.

func PublicKeyHash

func PublicKeyHash(pubKey []byte) []byte

Types

type Wallet

type Wallet struct {
	PrivateKey ecdsa.PrivateKey
	PublicKey  []byte
}

We use the Elliptic Curve Digital Signature Algorithm to create a private key. It chooses randomly a number D between 0 and 2^256. Then with the private key, we pick on spot on the elliptical curve and use D value to move around the curve that many times until we reach another spot that will become the public key. The X and Y fields (of the public key) are the final coordinate that we landed on based on the D value.

func MakeWallet

func MakeWallet() *Wallet

Creates a Wallet struct.

func (Wallet) Address

func (w Wallet) Address() []byte

Generates an address.

type Wallets

type Wallets struct {
	Wallets map[string]*Wallet
}

Stores the wallets inside a map of type: address -> Wallet.

func CreateWallets

func CreateWallets() (*Wallets, error)

Populates the Wallets struct.

func (*Wallets) AddWallet

func (ws *Wallets) AddWallet() string

Adds a wallet to the Wallets struct.

func (*Wallets) GetAllAddresses

func (ws *Wallets) GetAllAddresses() []string

Gets all the wallet adresses inside the Wallets struct.

func (Wallets) GetWallet

func (ws Wallets) GetWallet(address string) Wallet

Gets a wallet with its corresponding string address.

func (*Wallets) LoadFile

func (ws *Wallets) LoadFile() error

Loads all the wallets indide the local file.

func (*Wallets) SaveFile

func (ws *Wallets) SaveFile()

Saves the wallets in a local file.

Jump to

Keyboard shortcuts

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