go-mnemonic

module
v0.1.1-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2021 License: MIT

README

go-mnemonic

PkgGoDev GitHub release MIT License Contributors

Build check Go Report Card Coverage Status

An implementation of the BIP32 spec for Hierarchical Deterministic Bitcoin addresses as a simple Go library. The semantics of derived keys are up to the user. BIP43 and BIP44 are good schemes to implement with this library. An additional library for either or both of those on top of this library should be developed.

Install(安装)

go get github.com/huangkaiqiao/go-mnemonic@v0.1.1-alpha

Example

It's very unlikely, but possible, that a given index does not produce a valid private key. Error checking is skipped in this example for brevity but should be handled in real code. In such a case, a ErrInvalidPrivateKey is returned.

ErrInvalidPrivateKey should be handled by trying the next index for a child key.

Any valid private key will have a valid public key so that Key.PublicKey() method never returns an error.

package main

import (
  "github.com/huangkaiqiao/go-mnemonic"
  "fmt"
)

func main() {
	// 获取助记词
  mnemonic := mnemonic.NewMnemonic()
  fmt.Println(mnemonic)

  // 生成 filecoin 地址
  address := mnemonic.FromMnemonic(mnemonic)
  fmt.Println(address)
}

Thanks

The developers at Factom have contributed a lot to this library and have made many great improvements to it. Please check out their project(s) and give them a thanks if you use this library.

Thanks to bartekn from Stellar for some important bug catches.

Directories

Path Synopsis
package bip32
package bip32

Jump to

Keyboard shortcuts

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