Documentation ¶
Index ¶
- Constants
- Variables
- func DerivePrivateKeyByPath(masterKey *hdkeychain.ExtendedKey, path string, fixIssue172 bool) (*btcec.PrivateKey, error)
- func DerivePublicKey(privateKey *ecdsa.PrivateKey) (*ecdsa.PublicKey, error)
- func EntropyFromMnemonic(mnemonic string) (entropy []byte, err error)
- func FormatBtc(amount int64) string
- func FormatEth(amount int64) string
- func FormatFloat(f float64, precision int) string
- func GetBtcChainParams(chainId int) (*chaincfg.Params, error)
- func GetEthChainParams(chainId int) (*params.ChainConfig, error)
- func MakeBip44Path(symbol string, chainId int, accountIndex, changeType, index int) (string, error)
- func MakeBip49Path(symbol string, chainId int, accountIndex, changeType, index int) (string, error)
- func MakeBip84Path(symbol string, chainId int, accountIndex, changeType, index int) (string, error)
- func MakeBipXPath(bipType int, symbol string, chainId int, accountIndex, changeType, index int) (string, error)
- func NewEntropy(bits int) (entropy []byte, err error)
- func NewMnemonic(bits int) (mnemonic string, err error)
- func NewMnemonicByEntropy(entropy []byte) (mnemonic string, err error)
- func NewSeedFromMnemonic(mnemonic, password string) ([]byte, error)
- type BtcWallet
- func (w *BtcWallet) ChainId() int
- func (w *BtcWallet) ChainParams() *chaincfg.Params
- func (w *BtcWallet) DeriveAddress() string
- func (w *BtcWallet) DeriveNativeAddress() btcutil.Address
- func (w *BtcWallet) DeriveNativePrivateKey() *btcec.PrivateKey
- func (w *BtcWallet) DerivePrivateKey() string
- func (w *BtcWallet) DerivePublicKey() string
- func (w *BtcWallet) GetKey(addr btcutil.Address) (*btcec.PrivateKey, bool, error)
- func (w *BtcWallet) GetScript(addr btcutil.Address) ([]byte, error)
- func (w *BtcWallet) Symbol() string
- type EthWallet
- func (w *EthWallet) ChainId() int
- func (w *EthWallet) ChainParams() *params.ChainConfig
- func (w *EthWallet) DeriveAddress() string
- func (w *EthWallet) DeriveNativeAddress() common.Address
- func (w *EthWallet) DeriveNativePrivateKey() *ecdsa.PrivateKey
- func (w *EthWallet) DerivePrivateKey() string
- func (w *EthWallet) DerivePublicKey() string
- func (w *EthWallet) Symbol() string
- type HDWallet
- func (this *HDWallet) NewNativeSegWitWallet(accountIndex, changeType, index int) (Wallet, error)
- func (this *HDWallet) NewSegWitWallet(accountIndex, changeType, index int) (Wallet, error)
- func (this *HDWallet) NewWallet(symbol string, accountIndex, changeType, index int) (Wallet, error)
- func (this *HDWallet) NewWalletByPath(symbol string, path string, segWitType SegWitType) (Wallet, error)
- type SegWitType
- type TrxWallet
- type Wallet
Constants ¶
View Source
const ( SymbolEth = "ETH" SymbolBtc = "BTC" SymbolTrx = "TRX" BtcChainMainNet = int(wire.MainNet) BtcChainTestNet3 = int(wire.TestNet3) BtcChainRegtest = int(wire.TestNet) BtcChainSimNet = int(wire.SimNet) ChainMainNet = 1 // for ETH ChainRopsten = 3 // for ETH ChainRinkeby = 4 // for ETH ChainGoerli = 5 // for ETH ChainSepolia = 11155111 ChainBsc = 56 // for Binance Smart Chain Mainnet ChainBscTestnet = 97 // for Binance Smart Chain Testnet ChainMatic = 137 // for Polygon Matic Mainnet ChainMaticTestnet = 80001 // for Polygon Matic Testnet ChainPrivate = 1337 // for ETH SegWitNone SegWitType = 0 SegWitScript SegWitType = 1 SegWitNative SegWitType = 2 ChangeTypeExternal = 0 ChangeTypeInternal = 1 // Usually used for change, not visible to the outside world SatoshiPerBitcoin = 1e8 SunPerTrx = 1e6 GweiPerEther = 1e9 WeiPerGwei = 1e9 WeiPerEther = 1e18 EtherTransferGas = 21000 TokenShowDecimals = 9 )
Variables ¶
View Source
var ( BscChainConfig = ¶ms.ChainConfig{} BscTestnetChainConfig = ¶ms.ChainConfig{} MaticChainConfig = ¶ms.ChainConfig{} MaticTestnetChainConfig = ¶ms.ChainConfig{} )
View Source
var ErrAddressNotMatch = errors.New("address not match")
View Source
var IsFixIssue172 = false
Functions ¶
func DerivePrivateKeyByPath ¶
func DerivePrivateKeyByPath(masterKey *hdkeychain.ExtendedKey, path string, fixIssue172 bool) (*btcec.PrivateKey, error)
func DerivePublicKey ¶
func DerivePublicKey(privateKey *ecdsa.PrivateKey) (*ecdsa.PublicKey, error)
func EntropyFromMnemonic ¶
func FormatFloat ¶
func GetEthChainParams ¶
func GetEthChainParams(chainId int) (*params.ChainConfig, error)
func MakeBip44Path ¶
func MakeBip49Path ¶
func MakeBip84Path ¶
func MakeBipXPath ¶
func NewEntropy ¶
func NewMnemonic ¶
func NewMnemonicByEntropy ¶
func NewSeedFromMnemonic ¶
Types ¶
type BtcWallet ¶
type BtcWallet struct {
// contains filtered or unexported fields
}
func NewBtcWallet ¶
func NewBtcWallet(privateKey string, chainId int, segWitType SegWitType) (*BtcWallet, error)
func NewBtcWalletByPath ¶
func (*BtcWallet) ChainParams ¶
func (*BtcWallet) DeriveAddress ¶
func (*BtcWallet) DeriveNativeAddress ¶
func (*BtcWallet) DeriveNativePrivateKey ¶
func (w *BtcWallet) DeriveNativePrivateKey() *btcec.PrivateKey
func (*BtcWallet) DerivePrivateKey ¶
func (*BtcWallet) DerivePublicKey ¶
type EthWallet ¶
type EthWallet struct {
// contains filtered or unexported fields
}
func NewEthWalletByPath ¶
func (*EthWallet) ChainParams ¶
func (w *EthWallet) ChainParams() *params.ChainConfig
func (*EthWallet) DeriveAddress ¶
func (*EthWallet) DeriveNativeAddress ¶
func (*EthWallet) DeriveNativePrivateKey ¶
func (w *EthWallet) DeriveNativePrivateKey() *ecdsa.PrivateKey
func (*EthWallet) DerivePrivateKey ¶
func (*EthWallet) DerivePublicKey ¶
type HDWallet ¶
type HDWallet struct {
// contains filtered or unexported fields
}
func NewHDWallet ¶
func (*HDWallet) NewNativeSegWitWallet ¶
func (*HDWallet) NewSegWitWallet ¶
func (*HDWallet) NewWalletByPath ¶
type SegWitType ¶
type SegWitType int
type TrxWallet ¶
type TrxWallet struct {
// contains filtered or unexported fields
}
func NewTrxWallet ¶
func (*TrxWallet) DeriveAddress ¶
func (*TrxWallet) DeriveNativePrivateKey ¶
func (w *TrxWallet) DeriveNativePrivateKey() *ecdsa.PrivateKey
func (*TrxWallet) DerivePrivateKey ¶
func (*TrxWallet) DerivePublicKey ¶
Click to show internal directories.
Click to hide internal directories.