Documentation ¶
Overview ¶
Package bip32 provides ...
Package bip32 provides ...
Index ¶
- Constants
- Variables
- func EntropyFromMnemonic(mnemonic string) ([]byte, error)
- func GetAddressFromMnemonic(words string, net Network) string
- func GetAddressFromPrivateKey(priv string, net Network) string
- func GetPrivateKeyFromMnemonic(words string, net Network) string
- func GetWordList() []string
- func IsMnemonicValid(mnemonic string) bool
- func IsRegIdStr(regId string) bool
- func MnemonicToByteArray(mnemonic string, raw ...bool) ([]byte, error)
- func NetworkToChainConfig(net Network) (*chaincfg.Params, error)
- func NewEntropy(bitSize int) ([]byte, error)
- func NewMnemonic(entropy []byte) (string, error)
- func NewSeed(mnemonic string, password string) []byte
- func NewSeedWithErrorChecking(mnemonic string, password string) ([]byte, error)
- func SetWordList(list []string)
- func WriteContractScript(writer *WriterHelper, script []byte, description string)
- type AddressId
- type AssetModel
- type AssetUpdateType
- type ChangeType
- type CoinType
- type Dest
- type ExtendedKey
- func (key *ExtendedKey) Address() (*ec.AddressPubKeyHash, error)
- func (key *ExtendedKey) B58Serialize() string
- func (key *ExtendedKey) Child(i uint32) (*ExtendedKey, error)
- func (key *ExtendedKey) DerivePath(pathStr string) (*ExtendedKey, error)
- func (key *ExtendedKey) ECPrivKey() (*ec.PrivateKey, error)
- func (key *ExtendedKey) HardenedChild(i uint32) (*ExtendedKey, error)
- func (key *ExtendedKey) Neuter() *ExtendedKey
- func (key *ExtendedKey) Serialize() ([]byte, error)
- type MnemonicLanguage
- type Network
- type OperVoteFund
- type PubKeyId
- type RegId
- type UserIdType
- type UserIdWraper
- type WICCNet
- type WalletAddress
- type WalletStatus
- type WaykiAssetIssueTx
- type WaykiAssetUpdateTx
- type WaykiBaseSignTx
- type WaykiCallContractTx
- type WaykiCdpLiquidateTx
- type WaykiCdpRedeemTx
- type WaykiCdpStakeTx
- type WaykiCommonTx
- type WaykiDelegateTx
- type WaykiDexCancelTx
- type WaykiDexMarketTx
- type WaykiDexSellLimitTx
- type WaykiRegisterAccountTx
- type WaykiRegisterContractTx
- type WaykiRewardTx
- type WaykiTxType
- type WaykiUCoinCallContractTx
- type WaykiUCoinRegisterContractTx
- type WaykiUCoinTransferTx
- type WaykiVoteType
- type WriterHelper
- func (writer WriterHelper) GetBuf() *bytes.Buffer
- func (writer WriterHelper) Write(p []byte)
- func (writer WriterHelper) WriteAddressId(value AddressId)
- func (writer WriterHelper) WriteByte(value byte)
- func (writer WriterHelper) WriteBytes(value []byte)
- func (write WriterHelper) WriteCdpAsset(assets []AssetModel)
- func (writer WriterHelper) WriteCompactSize(value uint64)
- func (writer WriterHelper) WriteContractScript(script []byte, description string)
- func (writer WriterHelper) WriteIntData(data interface{})
- func (writer WriterHelper) WritePubKeyId(value PubKeyId)
- func (writer WriterHelper) WriteRegId(value RegId)
- func (writer WriterHelper) WriteReverse(value []byte)
- func (writer WriterHelper) WriteString(value string)
- func (writer WriterHelper) WriteUserId(value *UserIdWraper)
- func (writer WriterHelper) WriteVarInt(value int64)
Constants ¶
const ( REWARD_TX WaykiTxType = 1 + iota //!< reward tx REG_ACCT_TX //!< tx that used to register account COMMON_TX //!< transfer coin from one account to another CONTRACT_TX //!< contract tx REG_CONT_TX //!< register contract DELEGATE_TX //!< delegate tx FCOIN_STAKE_TX = 8 ASSET_ISSUE_TX = 9 //!< a user issues onchain asset ASSET_UPDATE_TX = 10 //!< a user update onchain asset UCOIN_TRANSFER_TX = 11 UCONTRACT_DEPLOY_TX = 14 //!< universal VM contract deployment UCOIN_CONTRACT_INVOKE_TX = 15 PRICE_FEED_TX = 16 CDP_STAKE_TX = 21 CDP_REDEEMP_TX = 22 CDP_LIQUIDATE_TX = 23 DEX_SETTLE_TX = 89 //!< dex settle Tx DEX_CANCEL_ORDER_TX = 88 //!< dex cancel order Tx DEX_BUY_LIMIT_ORDER_TX = 84 //!< dex buy limit price order Tx DEX_SELL_LIMIT_ORDER_TX = 85 //!< dex sell limit price order Tx DEX_BUY_MARKET_ORDER_TX = 86 //!< dex buy market price order Tx DEX_SELL_MARKET_ORDER_TX = 87 //!< dex sell market price order Tx )
const ( UINT16_MAX = ^uint16(0) UINT32_MAX = ^uint32(0) UINT_MAX = ^uint(0) UINT64_MAX = ^uint64(0) )
const ( // MainNet represents the main wicc network. MainNet wire.BitcoinNet = 0xff421d1a // TestNet represents the test wicc network. TestNet wire.BitcoinNet = 0xfd7d5cd7 // Default entropy size for mnemonic DefaultEntropySize = 128 // Default seed pass. it used to generate seed from mnemonic( BIP39 ). Don't change if determined DefaultSeedPass = "" HardenedKeyZeroIndex = 0x8001869f BIP44Purpose uint32 = 0x8000002C WICCCoinType uint32 = 99999 MAINNET Network = 1 TESTNET Network = 2 BIP44PATH = "m/44'/99999'/0'/0/0" )
const ( ENGLISH MnemonicLanguage = "EN" JAPANESE = "JP" FRENCH = "FR" ITALIAN = "IT" KOREAN = "KR" SPANISH = "ES" )
List Mnemonic language support
const ( WICC CoinType = "WICC" WGRT = "WGRT" WUSD = "WUSD" WCNY = "WCNY" WBTC = "WBTC" WETH = "WETH" WEOS = "WEOS" USD = "USD" CNY = "CNY" EUR = "EUR" BTC = "BTC" USDT = "USDT" GOLD = "GOLD" KWH = "KWH" )
const ( ASSET_OWNER_UID AssetUpdateType = 1 ASSET_NAME = 2 ASSET_MINT_AMOUNT = 3 )
const ( //HardenedKeyStart hardended key starts. HardenedKeyStart uint32 = 0x80000000 // 2^31 )
Variables ¶
var ( // ErrInvalidSeedLen seed Len error ErrInvalidSeedLen = errors.New("seed lenght must be between 128 and 512 bits") // ErrUnusableSeed describes an error in which the provided seed is not // usable due to the derived key falling outside of the valid range for // secp256k1 private keys. This error indicates the caller must choose // another seed. ErrUnusableSeed = errors.New("unusable seed") // ErrKeyByteSize error extended key bytes ErrKeyByteSize = errors.New("error extended key bytes") //ErrDeriveBeyondMaxDepth max 255 indices ErrDeriveBeyondMaxDepth = errors.New("cannot derive a key with more than 255 indices in its path") // ErrDeriveHardFromPublic cannot derive a hardened key from a public key ErrDeriveHardFromPublic = errors.New("cannot derive a hardened key from a public key") //ErrInvalidChild child index invalid ErrInvalidChild = errors.New("the extended key at this index is invalid") // ErrNotPrivExtKey not Private Key ErrNotPrivExtKey = errors.New("cant't create private keys from public extended key") )
var ( // ErrInvalidMnemonic is returned when trying to use a malformed mnemonic. ErrInvalidMnemonic = errors.New("Invalid mnenomic") // ErrEntropyLengthInvalid is returned when trying to use an entropy set with // an invalid size. ErrEntropyLengthInvalid = errors.New("Entropy length must be [128, 256] and a multiple of 32") // ErrValidatedSeedLengthMismatch is returned when a validated seed is not the // same size as the given seed. This should never happen is present only as a // sanity assertion. ErrValidatedSeedLengthMismatch = errors.New("Seed length does not match validated seed length") // ErrChecksumIncorrect is returned when entropy has the incorrect checksum. ErrChecksumIncorrect = errors.New("Checksum incorrect") )
var ErrKeyPathFormat = errors.New("Wallet Path Error")
var ErrParentKey = errors.New("Key must master")
var WaykiMainNetParams = chaincfg.Params{ PubKeyHashAddrID: 0x49, PrivateKeyID: 0x99, HDPrivateKeyID: [4]byte{0x04, 0x88, 0xad, 0xe4}, HDPublicKeyID: [4]byte{0x04, 0x88, 0xb2, 0x1e}, HDCoinType: 99999, }
var WaykiTestNetParams = chaincfg.Params{ PubKeyHashAddrID: 0x87, PrivateKeyID: 0xd2, HDPrivateKeyID: [4]byte{0x04, 0x88, 0xad, 0xe4}, HDPublicKeyID: [4]byte{0x04, 0x88, 0xb2, 0x1e}, HDCoinType: 99999, }
Functions ¶
func EntropyFromMnemonic ¶
EntropyFromMnemonic takes a mnemonic generated by this library, and returns the input entropy used to generate the given mnemonic. An error is returned if the given mnemonic is invalid.
func GetAddressFromMnemonic ¶
func GetWordList ¶
func GetWordList() []string
GetWordList gets the list of words to use for mnemonics.
func IsMnemonicValid ¶
IsMnemonicValid attempts to verify that the provided mnemonic is valid. Validity is determined by both the number of words being appropriate, and that all the words in the mnemonic are present in the word list.
func IsRegIdStr ¶
func MnemonicToByteArray ¶
MnemonicToByteArray takes a mnemonic string and turns it into a byte array suitable for creating another mnemonic. An error is returned if the mnemonic is invalid.
func NewEntropy ¶
NewEntropy will create random entropy bytes so long as the requested size bitSize is an appropriate size.
bitSize has to be a multiple 32 and be within the inclusive range of {128, 256}
func NewMnemonic ¶
NewMnemonic will return a string consisting of the mnemonic words for the given entropy. If the provide entropy is invalid, an error will be returned.
func NewSeed ¶
NewSeed creates a hashed seed output given a provided string and password. No checking is performed to validate that the string provided is a valid mnemonic.
func NewSeedWithErrorChecking ¶
NewSeedWithErrorChecking creates a hashed seed output given the mnemonic string and a password. An error is returned if the mnemonic is not convertible to a byte array.
func SetWordList ¶
func SetWordList(list []string)
SetWordList sets the list of words to use for mnemonics. Currently the list that is set is used package-wide.
func WriteContractScript ¶
func WriteContractScript(writer *WriterHelper, script []byte, description string)
Types ¶
type AssetModel ¶
type AssetUpdateType ¶
type AssetUpdateType int
type ChangeType ¶
type ChangeType uint32
type Dest ¶
type Dest struct { CoinSymbol string //From Coin Type CoinAmount uint64 DestAddr *UserIdWraper }
type ExtendedKey ¶
type ExtendedKey struct { DerivationPath string // contains filtered or unexported fields }
ExtendedKey private/public key data
func NewMasterKey ¶
func NewMasterKey(seed []byte, params *chaincfg.Params) (*ExtendedKey, error)
NewMasterKey create a new master key data from seed
func (*ExtendedKey) Address ¶
func (key *ExtendedKey) Address() (*ec.AddressPubKeyHash, error)
Address return pay-to-pubkey-has (P2PKH) address
func (*ExtendedKey) B58Serialize ¶
func (key *ExtendedKey) B58Serialize() string
func (*ExtendedKey) Child ¶
func (key *ExtendedKey) Child(i uint32) (*ExtendedKey, error)
Child create extended child key https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#child-key-derivation-ckd-functions
func (*ExtendedKey) DerivePath ¶
func (key *ExtendedKey) DerivePath(pathStr string) (*ExtendedKey, error)
DerivePath return key by path : m/0'/1/2' etc...
func (*ExtendedKey) ECPrivKey ¶
func (key *ExtendedKey) ECPrivKey() (*ec.PrivateKey, error)
func (*ExtendedKey) HardenedChild ¶
func (key *ExtendedKey) HardenedChild(i uint32) (*ExtendedKey, error)
HardenedChild derivation hardened child
func (*ExtendedKey) Neuter ¶
func (key *ExtendedKey) Neuter() *ExtendedKey
Neuter https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#private-parent-key--public-child-key
func (*ExtendedKey) Serialize ¶
func (key *ExtendedKey) Serialize() ([]byte, error)
type MnemonicLanguage ¶
type MnemonicLanguage string
type OperVoteFund ¶
type OperVoteFund struct { VoteType WaykiVoteType PubKey *PubKeyId VoteValue int64 }
type PubKeyId ¶
type PubKeyId []byte
func NewPubKeyIdByKey ¶
func NewPubKeyIdByKey(privKey *btcec.PrivateKey) *PubKeyId
func NewPubKeyIdByStr ¶
type RegId ¶
func ParseRegId ¶
type UserIdType ¶
type UserIdType int
const ( UID_REG UserIdType = iota //< reg id UID_PUB_KEY //< public key UID_ADDRESS //< wicc address )
type UserIdWraper ¶
type UserIdWraper struct {
// contains filtered or unexported fields
}
func NewAdressUid ¶
func NewAdressUid(address AddressId) *UserIdWraper
func NewAdressUidByStr ¶
func NewAdressUidByStr(address string) *UserIdWraper
func NewPubKeyUid ¶
func NewPubKeyUid(pubKey PubKeyId) *UserIdWraper
func NewPubKeyUidByStr ¶
func NewPubKeyUidByStr(pubKey string) *UserIdWraper
func NewRegUid ¶
func NewRegUid(regId RegId) *UserIdWraper
func NewRegUidByStr ¶
func NewRegUidByStr(regId string) *UserIdWraper
func (UserIdWraper) GetId ¶
func (uid UserIdWraper) GetId() interface{}
func (UserIdWraper) GetType ¶
func (uid UserIdWraper) GetType() UserIdType
type WalletAddress ¶
type WalletAddress struct {
// contains filtered or unexported fields
}
type WalletStatus ¶
type WalletStatus int64
type WaykiAssetIssueTx ¶
type WaykiAssetIssueTx struct { WaykiBaseSignTx Fees uint64 FeeSymbol string //Fee Type (WICC/WUSD) AssetSymbol string //From Coin Type AssetName string AssetTotal uint64 AssetOwner *UserIdWraper MinTable bool }
type WaykiAssetUpdateTx ¶
type WaykiAssetUpdateTx struct { WaykiBaseSignTx Fees uint64 UpdateType int FeeSymbol string //Fee Type (WICC/WUSD) AssetSymbol string //From Coin Type AssetName string AssetTotal uint64 AssetOwner *UserIdWraper }
type WaykiBaseSignTx ¶
type WaykiBaseSignTx struct { TxType WaykiTxType Version int64 ValidHeight int64 PubKey []byte UserId *UserIdWraper // current operating user id, the one want to do something }
type WaykiCallContractTx ¶
type WaykiCallContractTx struct { WaykiBaseSignTx AppId *UserIdWraper //user regid or user key id or app regid Fees uint64 Values uint64 //transfer amount Contract []byte }
type WaykiCdpLiquidateTx ¶
type WaykiCdpRedeemTx ¶
type WaykiCdpRedeemTx struct { WaykiBaseSignTx Fees uint64 ScoinValues uint64 //Stake Coin Assets []AssetModel FeeSymbol string //Fee Type (WICC/WUSD) CdpTxHash []byte }
type WaykiCdpStakeTx ¶
type WaykiCdpStakeTx struct { WaykiBaseSignTx Fees uint64 ScoinValues uint64 //get Coin amount FeeSymbol string //Fee Type (WICC/WUSD) ScoinSymbol string //get Coin Type Assets []AssetModel CdpTxHash []byte }
type WaykiCommonTx ¶
type WaykiCommonTx struct { WaykiBaseSignTx Fees uint64 Values uint64 Memo string DestId *UserIdWraper //< the dest id(reg id or address or public key) received the wicc values }
type WaykiDelegateTx ¶
type WaykiDelegateTx struct { WaykiBaseSignTx OperVoteFunds []OperVoteFund Fees uint64 }
type WaykiDexCancelTx ¶
type WaykiDexCancelTx struct { WaykiBaseSignTx Fees uint64 FeeSymbol string //Fee Type (WICC/WUSD) DexHash []byte //From Coin Type }
type WaykiDexMarketTx ¶
type WaykiDexMarketTx struct { WaykiBaseSignTx Fees uint64 FeeSymbol string //Fee Type (WICC/WUSD) CoinSymbol string //From Coin Type AssetSymbol string AssetAmount uint64 DestId *UserIdWraper //< the dest id(reg id or address or public key) received the wicc values }
type WaykiDexSellLimitTx ¶
type WaykiDexSellLimitTx struct { WaykiBaseSignTx Fees uint64 FeeSymbol string //Fee Type (WICC/WUSD) CoinSymbol string //From Coin Type AssetSymbol string AssetAmount uint64 AskPrice uint64 DestId *UserIdWraper //< the dest id(reg id or address or public key) received the wicc values }
type WaykiRegisterAccountTx ¶
type WaykiRegisterAccountTx struct { WaykiBaseSignTx MinerId *UserIdWraper Fees uint64 }
type WaykiRegisterContractTx ¶
type WaykiRegisterContractTx struct { WaykiBaseSignTx Script []byte Description string Fees uint64 }
type WaykiRewardTx ¶
type WaykiRewardTx struct { WaykiBaseSignTx Values uint64 // reward values }
type WaykiTxType ¶
type WaykiTxType uint32
type WaykiUCoinCallContractTx ¶
type WaykiUCoinCallContractTx struct { WaykiBaseSignTx AppId *UserIdWraper //user regid or user key id or app regid Fees int64 CoinAmount int64 //transfer amount FeeSymbol string //Fee Type (WICC/WUSD) CoinSymbol string //From Coin Type Contract []byte }
type WaykiUCoinRegisterContractTx ¶
type WaykiUCoinRegisterContractTx struct { WaykiBaseSignTx Script []byte Description string Fees uint64 FeeSymbol string }
type WaykiUCoinTransferTx ¶
type WaykiUCoinTransferTx struct { WaykiBaseSignTx Fees uint64 FeeSymbol string //Fee Type (WICC/WUSD) Dests []Dest Memo string }
type WaykiVoteType ¶
type WaykiVoteType uint32
const ( NULL_OPER WaykiVoteType = iota ADD_FUND //投票 MINUS_FUND //撤销投票 )
func GetVoteTypeByValue ¶
func GetVoteTypeByValue(value int64) WaykiVoteType
type WriterHelper ¶
type WriterHelper struct {
// contains filtered or unexported fields
}
func NewWriterHelper ¶
func NewWriterHelper(buf *bytes.Buffer) *WriterHelper
func (WriterHelper) GetBuf ¶
func (writer WriterHelper) GetBuf() *bytes.Buffer
func (WriterHelper) Write ¶
func (writer WriterHelper) Write(p []byte)
func (WriterHelper) WriteAddressId ¶
func (writer WriterHelper) WriteAddressId(value AddressId)
func (WriterHelper) WriteByte ¶
func (writer WriterHelper) WriteByte(value byte)
func (WriterHelper) WriteBytes ¶
func (writer WriterHelper) WriteBytes(value []byte)
func (WriterHelper) WriteCdpAsset ¶
func (write WriterHelper) WriteCdpAsset(assets []AssetModel)
func (WriterHelper) WriteCompactSize ¶
func (writer WriterHelper) WriteCompactSize(value uint64)
func (WriterHelper) WriteContractScript ¶
func (writer WriterHelper) WriteContractScript(script []byte, description string)
func (WriterHelper) WriteIntData ¶
func (writer WriterHelper) WriteIntData(data interface{})
func (WriterHelper) WritePubKeyId ¶
func (writer WriterHelper) WritePubKeyId(value PubKeyId)
func (WriterHelper) WriteRegId ¶
func (writer WriterHelper) WriteRegId(value RegId)
func (WriterHelper) WriteReverse ¶
func (writer WriterHelper) WriteReverse(value []byte)
func (WriterHelper) WriteString ¶
func (writer WriterHelper) WriteString(value string)
func (WriterHelper) WriteUserId ¶
func (writer WriterHelper) WriteUserId(value *UserIdWraper)
func (WriterHelper) WriteVarInt ¶
func (writer WriterHelper) WriteVarInt(value int64)
Source Files ¶
- WaykiAssetIssueTx.go
- WaykiAssetUpdateTx.go
- WaykiCallContractTx.go
- WaykiCdpLiquidateTx.go
- WaykiCdpRedeemTx.go
- WaykiCdpStakeTx.go
- WaykiCommonTx.go
- WaykiDelegateTx.go
- WaykiDexCancelTx.go
- WaykiDexLimitTx.go
- WaykiDexMarketTx.go
- WaykiNetParams.go
- WaykiRegisterAccountTx.go
- WaykiRegisterContractTx.go
- WaykiRewardTx.go
- WaykiTx.go
- WaykiUCoinCallContractTx.go
- WaykiUCoinRegisterContractTx.go
- WaykiUCoinTransferTx.go
- WaykiWalletUtils.go
- WriterHelper.go
- bip32.go
- bip32path.go
- bip39.go
- constants.go
- genesis.go
Directories ¶
Path | Synopsis |
---|---|
Package base58 provides ...
|
Package base58 provides ... |
Package bytes provides ...
|
Package bytes provides ... |
Package address provides ...
|
Package address provides ... |
Package utils provides ...
|
Package utils provides ... |
Package wif provides ...
|
Package wif provides ... |