Fix BIP44 coin type (#480)

* fix docsearch

* update BIP44 coin type

* changelog

* set HD path
This commit is contained in:
Federico Kunze
2020-08-28 11:35:10 -04:00
committed by GitHub
parent 6307ba9d28
commit 8a3692e174
7 changed files with 60 additions and 3 deletions
+12
View File
@@ -20,6 +20,12 @@ const (
Bech32PrefixConsAddr = EthBech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus
// Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key
Bech32PrefixConsPub = EthBech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus + sdk.PrefixPublic
// Bip44CoinType satisfies EIP84. See https://github.com/ethereum/EIPs/issues/84 for more info.
Bip44CoinType = 60
// BIP44HDPath is the BIP44 HD path used on Ethereum.
BIP44HDPath = "44'/60'/0'/0/0"
)
// SetBech32Prefixes sets the global prefixes to be used when serializing addresses and public keys to Bech32 strings.
@@ -28,3 +34,9 @@ func SetBech32Prefixes(config *sdk.Config) {
config.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub)
}
// SetBip44CoinType sets the global coin type to be used in hierarchical deterministic wallets.
func SetBip44CoinType(config *sdk.Config) {
config.SetCoinType(Bip44CoinType)
config.SetFullFundraiserPath(BIP44HDPath)
}
+9
View File
@@ -32,3 +32,12 @@ func TestSetBech32Prefixes(t *testing.T) {
require.Equal(t, sdk.GetConfig().GetBech32ConsensusAddrPrefix(), config.GetBech32ConsensusAddrPrefix())
require.Equal(t, sdk.GetConfig().GetBech32ConsensusPubPrefix(), config.GetBech32ConsensusPubPrefix())
}
func TestSetCoinType(t *testing.T) {
config := sdk.GetConfig()
require.Equal(t, sdk.CoinType, int(config.GetCoinType()))
SetBip44CoinType(config)
require.Equal(t, Bip44CoinType, int(config.GetCoinType()))
require.Equal(t, sdk.GetConfig().GetCoinType(), config.GetCoinType())
}