wallet

package
v1.10.0-beta.20201225 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2020 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//FlagBBCUseStandardBip44ID BBC使用标准bip44 id (默认不是标准bip44 id)
	FlagBBCUseStandardBip44ID = "bbc_use_std_bip44_id"
	//FlagMKFUseBBCBip44ID MKF使用BBC的bip44 id (即MKF和BBC共用地址)
	FlagMKFUseBBCBip44ID = "mkf_use_bbc_bip44_id"
	// FlagBTCUseSegWitFormat BTC使用隔离见证地址
	FlagBTCUseSegWitFormat = btc.FlagUseSegWitFormat
)

Variables

View Source
var (

	// Debug 模式下会打印关键过程
	Debug = false
)

Functions

func EntropyFromMnemonic

func EntropyFromMnemonic(mnemonic string) (entropy string, err error)

EntropyFromMnemonic 根据 助记词, 获取 Entropy returns the input entropy used to generate the given mnemonic

func GetAvailableCoinList

func GetAvailableCoinList() string

GetAvailableCoinList 获取支持币种列表 (case sensitive) return : "BTC LMC ETH WCG"

func GetBuildTime

func GetBuildTime() string

func GetGitHash

func GetGitHash() string

func GetVersion

func GetVersion() string

func MnemonicFromEntropy

func MnemonicFromEntropy(entropy string) (mnemonic string, err error)

MnemonicFromEntropy 根据 entropy, 获取对应助记词

func NewMnemonic

func NewMnemonic() (mnemonic string, err error)

NewMnemonic 生成助记词 默认使用128位密钥,生成12个单词的助记词

func ValidateMnemonic

func ValidateMnemonic(mnemonic string) (err error)

ValidateMnemonic 验证助记词的正确性

Types

type Wallet

type Wallet struct {

	// ShareAccountWithParentChain break the HD rule, use the metadata of the parent chain to generate keys and addresses.
	ShareAccountWithParentChain bool
	// contains filtered or unexported fields
}

Wallet all in one signer

func BuildWalletFromMnemonic

func BuildWalletFromMnemonic(mnemonic string, testNet bool, options *WalletOptions) (wallet *Wallet, err error)

BuildWalletFromMnemonic create a Wallet instance with fixed args (here is mnemonic and testNet) and other options

func BuildWalletFromPrivateKey

func BuildWalletFromPrivateKey(privateKey string, testNet bool, options WalletOptions) (wallet *Wallet, err error)

TODO not implemented BuildWallet create a Wallet instance with fixed args (here is privateKey and testNet) and other options

func NewHDWalletFromMnemonic

func NewHDWalletFromMnemonic(mnemonic, password string, testNet bool) (w *Wallet, err error)

NewHDWalletFromMnemonic 通过助记词得到一个 HD 对象

func (*Wallet) AddFlag

func (c *Wallet) AddFlag(f string)

AddFlag .

func (*Wallet) Bip39Seed

func (c *Wallet) Bip39Seed() ([]byte, error)

Bip39Seed get bip39 seed,调用该函数后不要求该mnemonic和password

func (Wallet) Clone

func (c Wallet) Clone(options *WalletOptions) (wallet *Wallet, err error)

Clone makes a copy of existing Wallet instance, with original attributes override by the given options

func (Wallet) DecodeTx

func (c Wallet) DecodeTx(symbol, msg string) (tx string, err error)

DecodeTx 解析交易数据 return: json 数据

func (Wallet) DeriveAddress

func (c Wallet) DeriveAddress(symbol string) (address string, err error)

DeriveAddress 获取对应币种代号的 地址

func (Wallet) DerivePrivateKey

func (c Wallet) DerivePrivateKey(symbol string) (privateKey string, err error)

DerivePrivateKey 获取对应币种代号的 私钥

func (Wallet) DerivePublicKey

func (c Wallet) DerivePublicKey(symbol string) (publicKey string, err error)

DerivePublicKey 获取对应币种代号的 公钥

func (*Wallet) HasFlag

func (c *Wallet) HasFlag(flag string) bool

HasFlag 是否存在flag

func (Wallet) Metadata

func (c Wallet) Metadata(symbol string) (core.MetadataProvider, error)

func (Wallet) RawKey

func (c Wallet) RawKey(symbol string) ([]byte, error)

RawKey 给出原始 私钥+公钥

func (Wallet) Sign

func (c Wallet) Sign(symbol, msg string) (sig string, err error)

Sign 签名交易

type WalletBuilder

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

func NewWalletBuilder

func NewWalletBuilder() *WalletBuilder

NewWalletBuilder normal builder pattern, not so good in golang

func (*WalletBuilder) SetMnemonic

func (wb *WalletBuilder) SetMnemonic(mnemonic string) *WalletBuilder

func (*WalletBuilder) SetPassword

func (wb *WalletBuilder) SetPassword(password string) *WalletBuilder

func (*WalletBuilder) SetShareAccountWithParentChain

func (wb *WalletBuilder) SetShareAccountWithParentChain(shareAccountWithParentChain bool) *WalletBuilder

func (*WalletBuilder) SetTestNet

func (wb *WalletBuilder) SetTestNet(testNet bool) *WalletBuilder

func (*WalletBuilder) SetUseShortestPath

func (wb *WalletBuilder) SetUseShortestPath(useShortestPath bool) *WalletBuilder

func (*WalletBuilder) Wallet

func (wb *WalletBuilder) Wallet() (wallet *Wallet, err error)

type WalletOption

type WalletOption interface {
	Visit(*Wallet) error
}

func WithFlag

func WithFlag(flag string) WalletOption

WithFlag 该选项添加特殊配置flag, flag参考 FlagXXX 常量

func WithPassword

func WithPassword(password string) WalletOption

func WithPathFormat

func WithPathFormat(pathFormat string) WalletOption

func WithShareAccountWithParentChain

func WithShareAccountWithParentChain(shareAccountWithParentChain bool) WalletOption

type WalletOptions

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

func (*WalletOptions) Add

func (opts *WalletOptions) Add(opt WalletOption)

Jump to

Keyboard shortcuts

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