wallet

package
v0.0.0-...-3ba53bb Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2019 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//SeedChecksumSize is the number of bytes that are used to checksum
	//addresses to prevent accidental spending.
	//https://gitlab.com/NebulousLabs/Sia/blob/fb65620/modules/wallet.go#L24
	SeedChecksumSize = 6
)

Some of these funcs and consts are copied directly from the Sia code base. Unfortunately we can't use some of the packages directly because of the wasm target

Variables

This section is empty.

Functions

This section is empty.

Types

type SeedWallet

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

SeedWallet creates keys and addresses for the generated seed. Wallet is stateless for ease of use

func NewSeed

func NewSeed() (wallet *SeedWallet)

NewSeed creates a new unique wallet seed

func RecoverSeed

func RecoverSeed(phrase string) (wallet *SeedWallet, err error)

RecoverSeed loads a standard 29 word wallet phrase. Wanted to import this directly from modules, but cannot because of bbolt https://gitlab.com/NebulousLabs/Sia/blob/fb65620/modules/wallet.go#L526

func (*SeedWallet) GetAddress

func (wallet *SeedWallet) GetAddress(idx uint64) SpendableKey

GetAddress returns the spendable address at the specified index

func (*SeedWallet) GetAddresses

func (wallet *SeedWallet) GetAddresses(idx uint64, keys []SpendableKey)

GetAddresses returns the n addresses starting at idx and incrementing by 1. Wanted to import this directly from modules, but cannot because of bbolt https://gitlab.com/NebulousLabs/Sia/blob/fb65620/modules/wallet/seed.go#L49

func (*SeedWallet) RecoveryPhrase

func (wallet *SeedWallet) RecoveryPhrase() (string, error)

RecoveryPhrase returns the 29 word seed recovery phrase. Wanted to import this directly from modules, but cannot because of bbolt https://gitlab.com/NebulousLabs/Sia/blob/fb65620/modules/wallet.go#L515

func (*SeedWallet) SignTransaction

func (wallet *SeedWallet) SignTransaction(txn types.Transaction, keys []SpendableKey) (types.Transaction, error)

SignTransaction signs a transaction for simplicity only supports standard 1 signature keys and siacoin inputs

type SpendableKey

type SpendableKey struct {
	UnlockConditions types.UnlockConditions `json:"unlock_conditions"`
	SecretKeys       []crypto.SecretKey     `json:"private_key"`
}

SpendableKey a set of secret keys plus the corresponding unlock conditions. Siacoin and Siafund outputs with unlock hashes matching the unlock conditions can be spent by the seed

type SpendableOutput

type SpendableOutput struct {
	ID         [32]byte       `json:"id"`
	UnlockHash string         `json:"unlock_hash"`
	SeedIndex  uint64         `json:"seed_index"`
	Value      types.Currency `json:"value"`
}

SpendableOutput an output known to be spendable by a seed with the index of the seed used to generate the unlock hash

type UnlockConditions

type UnlockConditions struct {
	PublicKeys         []string `json:"publickeys"`
	SignaturesRequired uint64   `json:"signaturesrequired"`
	Timelock           uint64   `json:"timelock"`
}

UnlockConditions maps sia unlock conditions to a more managable type

Jump to

Keyboard shortcuts

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