Version: v0.0.0-...-fa20899 Latest Latest

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

Go to latest
Published: Jan 15, 2020 License: AGPL-3.0 Imports: 12 Imported by: 0




View Source
const (
	//SeedChecksumSize is the number of bytes that are used to checksum
	//addresses to prevent accidental spending.
	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


This section is empty.


func NewBIP39RecoveryPhrase

func NewBIP39RecoveryPhrase() (string, error)

NewBIP39RecoveryPhrase creates a new unique 12 word wallet seed

func NewSiaRecoveryPhrase

func NewSiaRecoveryPhrase() (string, error)

NewSiaRecoveryPhrase creates a new unique 28 or 29 word wallet seed


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 RecoverBIP39Seed

func RecoverBIP39Seed(phrase string) (*SeedWallet, error)

RecoverBIP39Seed loads a 12 word BIP-39 seed phrase

func RecoverSiaSeed

func RecoverSiaSeed(phrase string) (*SeedWallet, error)

RecoverSiaSeed 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/go#L526

func (*SeedWallet) GetAddress

func (wallet *SeedWallet) GetAddress(index 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) SignTransaction

func (wallet *SeedWallet) SignTransaction(txn *types.Transaction, requiredSigIndices []uint64) 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
t or T : Toggle theme light dark auto
y or Y : Canonical URL