hdwallet

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: MIT Imports: 6 Imported by: 0

README

go-solana-hdwallet

Solana HD Wallet derivations from [mnemonic] seed in Go (golang).

License Go Report Card PRs Welcome

Install

go get -u github.com/cnsumi/go-solana-hdwallet

Getting started

package main

import (
	"fmt"
	hdwallet "github.com/cnsumi/go-solana-hdwallet"
)

func main() {
	// derivation from default path
	mnemonic := "beach liar addict wrap pause runway evolve front grab print jungle mimic"
	node := hdwallet.NewNode(mnemonic)

	fmt.Println(node.SecretKey())
	fmt.Println(node.Address())
	
	// derivation according solana account index
	node = hdwallet.NewNode(mnemonic, hdwallet.WithIndex(1))
	fmt.Println(node.SecretKey())
	fmt.Println(node.Address())
	
	// ...
}

CLI

Test

make test

Contributing

Pull requests are welcome!

For contributions please create a new branch and submit a pull request for review.

License

Released under the MIT license.

© CNSumi

Documentation

Index

Constants

View Source
const FirstHardenedChildIndex = 0x80000000

Variables

This section is empty.

Functions

This section is empty.

Types

type NewNodeOption

type NewNodeOption func(cfg *newNodeCfg)

func WithIndex

func WithIndex(index uint32) NewNodeOption

WithIndex only work if no path preset

func WithPassword

func WithPassword(password string) NewNodeOption

func WithPath

func WithPath(path []uint32) NewNodeOption

type Node

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

func NewNode

func NewNode(mnemonic string, opts ...NewNodeOption) *Node

func (*Node) Address

func (node *Node) Address() string

func (*Node) Derive

func (node *Node) Derive(path ...uint32) *Node

func (*Node) DeriveChild

func (node *Node) DeriveChild(index uint32) *Node

func (*Node) PublicKey

func (node *Node) PublicKey() ed25519.PublicKey

func (*Node) SecretKey

func (node *Node) SecretKey() string

Jump to

Keyboard shortcuts

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