keygen

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: MIT Imports: 25 Imported by: 0

README

keygen

介绍

{以下是 Gitee 平台说明,您可以替换此简介 Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 https://gitee.com/enterprises}

软件架构

软件架构说明

安装教程
  1. xxxx
  2. xxxx
  3. xxxx
使用说明
  1. xxxx
  2. xxxx
  3. xxxx
参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/

Documentation

Index

Constants

View Source
const (
	Apostrophe uint32 = 0x80000000 // 0'
)

Variables

View Source
var NotSuppportCoin = errors.New("not support coin")

Functions

func Generate

func Generate(compress bool) (wif, address, segwitBech32, segwitNested string, err error)

func GenerateFromBytes

func GenerateFromBytes(prvKey *btcec.PrivateKey, compress bool) (wif, address, segwitBech32, segwitNested string, err error)

func Lang added in v0.0.5

func Lang(str string)

Types

type CoinType

type CoinType = uint32

CoinType SLIP-0044 : Registered coin types for BIP-0044 https://github.com/satoshilabs/slips/blob/master/slip-0044.md

const (
	CoinTypeBTC     CoinType = 0x80000000
	CoinTypeTestnet CoinType = 0x80000001
	CoinTypeLTC     CoinType = 0x80000002
	CoinTypeDOGE    CoinType = 0x80000003
	CoinTypeDASH    CoinType = 0x80000005
	CoinTypeETH     CoinType = 0x8000003c
	CoinTypeZEC     CoinType = 0x80000085
	CoinTypeBCH     CoinType = 0x80000091
	CoinTypeEOS     CoinType = 0x800000c2
	CoinTypeTRX     CoinType = 0x800000c3
	CoinTypeNEAR    CoinType = 0x8000018d
	CoinTypeSOL     CoinType = 0x800001f5
	CoinTypeFLOW    CoinType = 0x8000021b
	CoinTypeMATIC   CoinType = 0x800003c6
	CoinTypeOKT     CoinType = 0x800003e4
	CoinTypeADA     CoinType = 0x80000717
	CoinTypeAVAXC   CoinType = 0x8000232d
	CoinTypeBSC     CoinType = 0x8000232e
)

type Key

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

func (*Key) Address added in v0.0.4

func (k *Key) Address() (string, error)

func (*Key) AddressPubKeyHash added in v0.0.4

func (k *Key) AddressPubKeyHash() (string, error)

func (*Key) AddressScriptHash added in v0.0.4

func (k *Key) AddressScriptHash() (string, error)

func (*Key) AddressTaproot added in v0.0.4

func (k *Key) AddressTaproot() (string, error)

func (*Key) AddressWitnessPubKeyHash added in v0.0.4

func (k *Key) AddressWitnessPubKeyHash() (string, error)

func (*Key) AddressWitnessScriptHash added in v0.0.4

func (k *Key) AddressWitnessScriptHash() (string, error)

多签脚本太难了

func (*Key) B58Serialize added in v0.0.4

func (k *Key) B58Serialize() string

func (*Key) GetPath

func (k *Key) GetPath() string

func (*Key) PrivateKey added in v0.0.4

func (k *Key) PrivateKey() (string, error)

func (*Key) PublicKey added in v0.0.4

func (k *Key) PublicKey() string

type KeyManager

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

func NewKeyManager

func NewKeyManager(bitSize int, passphrase, mnemonic string) (*KeyManager, error)

NewKeyManager return new key manager bitSize has to be a multiple 32 and be within the inclusive range of {128, 256} 128: 12 phrases 256: 24 phrases

func (*KeyManager) GetAccountKey

func (km *KeyManager) GetAccountKey(purpose, coinType, account uint32) (*Key, error)

func (*KeyManager) GetChangeKey

func (km *KeyManager) GetChangeKey(purpose, coinType, account, change uint32) (*Key, error)

GetChangeKey ... https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#change change constant 0 is used for external chain change constant 1 is used for internal chain (also known as change addresses)

func (*KeyManager) GetCoinTypeKey

func (km *KeyManager) GetCoinTypeKey(purpose, coinType uint32) (*Key, error)

func (*KeyManager) GetKey

func (km *KeyManager) GetKey(purpose, coinType, account, change, index uint32) (*Key, error)

func (*KeyManager) GetMasterKey

func (km *KeyManager) GetMasterKey() (*Key, error)

func (*KeyManager) GetMnemonic

func (km *KeyManager) GetMnemonic() string

func (*KeyManager) GetPassphrase

func (km *KeyManager) GetPassphrase() string

func (*KeyManager) GetPurposeKey

func (km *KeyManager) GetPurposeKey(purpose uint32) (*Key, error)

func (*KeyManager) GetSeed

func (km *KeyManager) GetSeed() []byte

type Purpose

type Purpose = uint32

Purpose BIP43 - Purpose Field for Deterministic Wallets https://github.com/bitcoin/bips/blob/master/bip-0043.mediawiki

Purpose is a constant set to 44' (or 0x8000002C) following the BIP43 recommendation. It indicates that the subtree of this node is used according to this specification.

What does 44' mean in BIP44? https://bitcoin.stackexchange.com/questions/74368/what-does-44-mean-in-bip44

44' means that hardened keys should be used. The distinguisher for whether a key a given index is hardened is that the index is greater than 2^31, which is 2147483648. In hex, that is 0x80000000. That is what the apostrophe (') means. The 44 comes from adding it to 2^31 to get the final hardened key index. In hex, 44 is 2C, so 0x80000000 + 0x2C = 0x8000002C.

const (
	PurposeBIP44   Purpose = 0x8000002C // 44' BIP44
	PurposeBIP49   Purpose = 0x80000031 // 49' BIP49
	PurposeBIP84   Purpose = 0x80000054 // 84' BIP84
	PurposeBIP86   Purpose = 0x80000056 // 86' BIP86
	PurposeCIP1852 Purpose = 0x8000073c // 1852' CIP1852
)

Directories

Path Synopsis
Package address defines the Address API.
Package address defines the Address API.

Jump to

Keyboard shortcuts

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