Documentation ¶
Index ¶
- Constants
- Variables
- func Generate(compress bool) (wif, address, segwitBech32, segwitNested string, err error)
- func GenerateFromBytes(prvKey *btcec.PrivateKey, compress bool) (wif, address, segwitBech32, segwitNested string, err error)
- func Lang(str string)
- type CoinType
- type Key
- func (k *Key) Address() (string, error)
- func (k *Key) AddressPubKeyHash() (string, error)
- func (k *Key) AddressScriptHash() (string, error)
- func (k *Key) AddressTaproot() (string, error)
- func (k *Key) AddressWitnessPubKeyHash() (string, error)
- func (k *Key) AddressWitnessScriptHash() (string, error)
- func (k *Key) B58Serialize() string
- func (k *Key) GetPath() string
- func (k *Key) PrivateKey() (string, error)
- func (k *Key) PublicKey() string
- type KeyManager
- func (km *KeyManager) GetAccountKey(purpose, coinType, account uint32) (*Key, error)
- func (km *KeyManager) GetChangeKey(purpose, coinType, account, change uint32) (*Key, error)
- func (km *KeyManager) GetCoinTypeKey(purpose, coinType uint32) (*Key, error)
- func (km *KeyManager) GetKey(purpose, coinType, account, change, index uint32) (*Key, error)
- func (km *KeyManager) GetMasterKey() (*Key, error)
- func (km *KeyManager) GetMnemonic() string
- func (km *KeyManager) GetPassphrase() string
- func (km *KeyManager) GetPurposeKey(purpose uint32) (*Key, error)
- func (km *KeyManager) GetSeed() []byte
- type Purpose
Constants ¶
const (
Apostrophe uint32 = 0x80000000 // 0'
)
Variables ¶
var NotSuppportCoin = errors.New("not support coin")
Functions ¶
func GenerateFromBytes ¶
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) AddressPubKeyHash ¶ added in v0.0.4
func (*Key) AddressScriptHash ¶ added in v0.0.4
func (*Key) AddressTaproot ¶ added in v0.0.4
func (*Key) AddressWitnessPubKeyHash ¶ added in v0.0.4
func (*Key) AddressWitnessScriptHash ¶ added in v0.0.4
多签脚本太难了
func (*Key) B58Serialize ¶ added in v0.0.4
func (*Key) PrivateKey ¶ added in v0.0.4
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.