Skip to content

Commit

Permalink
Add support for Neutron
Browse files Browse the repository at this point in the history
  • Loading branch information
ebellocchia committed Jun 5, 2024
1 parent 0ed7dc7 commit dacc1ab
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ Supported BIP coins:
- Nano
- Near Protocol
- NEO (legacy and N3)
- Neutron
- Nimiq
- OKEx Chain (Ethereum and Cosmos addresses)
- Ontology
Expand Down
1 change: 1 addition & 0 deletions bip_utils/bip/conf/bip44/bip44_coins.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class Bip44Coins(BipCoins):
NEO = auto()
NEO_LEGACY = auto()
NEO_N3 = auto()
NEUTRON = auto()
NIMIQ = auto()
NINE_CHRONICLES_GOLD = auto()
OKEX_CHAIN_ATOM = auto()
Expand Down
15 changes: 15 additions & 0 deletions bip_utils/bip/conf/bip44/bip44_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,21 @@ class Bip44Conf:
},
)

# Configuration for Neutron
Neutron: BipCoinConf = BipCoinConf(
coin_names=CoinsConf.Neutron.CoinNames(),
coin_idx=Slip44.ATOM,
is_testnet=False,
def_path=DER_PATH_NON_HARDENED_FULL,
key_net_ver=_BIP44_BTC_KEY_NET_VER_MAIN,
wif_net_ver=None,
bip32_cls=Bip32Slip10Secp256k1,
addr_cls=AtomAddrEncoder,
addr_params={
"hrp": CoinsConf.Neutron.ParamByKey("addr_hrp"),
},
)

# Configuration for Nimiq
Nimiq: BipCoinConf = BipCoinConf(
coin_names=CoinsConf.Nimiq.CoinNames(),
Expand Down
1 change: 1 addition & 0 deletions bip_utils/bip/conf/bip44/bip44_conf_getter.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class Bip44ConfGetterConst:
Bip44Coins.NEO: Bip44Conf.NeoLegacy,
Bip44Coins.NEO_LEGACY: Bip44Conf.NeoLegacy,
Bip44Coins.NEO_N3: Bip44Conf.NeoN3,
Bip44Coins.NEUTRON: Bip44Conf.Neutron,
Bip44Coins.NIMIQ: Bip44Conf.Nimiq,
Bip44Coins.NINE_CHRONICLES_GOLD: Bip44Conf.NineChroniclesGold,
Bip44Coins.OKEX_CHAIN_ATOM: Bip44Conf.OkexChainAtom,
Expand Down
8 changes: 8 additions & 0 deletions bip_utils/coin_conf/coins_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,14 @@ class CoinsConf:
},
)

# Configuration for Neutron
Neutron: CoinConf = CoinConf(
coin_name=CoinNames("Neutron", "NTRN"),
params={
"addr_hrp": Slip173.NEUTRON,
},
)

# Configuration for Nimiq
Nimiq: CoinConf = CoinConf(
coin_name=CoinNames("Nimiq", "NIM"),
Expand Down
1 change: 1 addition & 0 deletions bip_utils/slip/slip173/slip173.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Slip173:
KAVA: str = "kava"
LITECOIN_MAINNET: str = "ltc"
LITECOIN_TESTNET: str = "tltc"
NEUTRON: str = "neutron"
OKEX_CHAIN: str = "ex"
OSMOSIS: str = "osmo"
SECRET_NETWORK: str = "secret"
Expand Down
9 changes: 5 additions & 4 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,16 @@ matic
metis
monero
multiversx
okex chain
ontology
optimism
osmosis
nano
near
near protocol
neo
neutron
nimiq
okex chain
ontology
optimism
osmosis
pi network
polygon
ripple
Expand Down
1 change: 1 addition & 0 deletions readme/bip44.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Supported coins enumerative for BIP-0044:
|Near Protocol|`Bip44Coins.NEAR_PROTOCOL`|-|
|NEO|`Bip44Coins.NEO_LEGACY` (or `Bip44Coins.NEO`)|-|
|NEO N3|`Bip44Coins.NEO_N3`|-|
|Neutron|`Bip44Coins.NEUTRON`|-|
|Nimiq|`Bip44Coins.NIMIQ`|-|
|OKEx Chain (Cosmos address)|`Bip44Coins.OKEX_CHAIN_ATOM`|-|
|OKEx Chain (Ethereum address)|`Bip44Coins.OKEX_CHAIN_ETH`|-|
Expand Down
30 changes: 30 additions & 0 deletions tests/bip/bip44/test_bip44.py
Original file line number Diff line number Diff line change
Expand Up @@ -1374,6 +1374,30 @@
"NbKAkUBrsZ29ffNkU7Lb8SHdtRdENhc26h",
],
},
# Neutron
{
"coin": Bip44Coins.NEUTRON,
"names": ("Neutron", "NTRN"),
"is_testnet": False,
"seed": b"5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4",
"ex_master": "xprv9s21ZrQH143K3GJpoapnV8SFfukcVBSfeCficPSGfubmSFDxo1kuHnLisriDvSnRRuL2Qrg5ggqHKNVpxR86QEC8w35uxmGoggxtQTPvfUu",
"wif_master": "",
"account": {
"ex_pub": "xpub6DGzViq8bmgMLYdVZ3xnLVEdKwzBnGdzzJZ4suG8kVb9TTLAbrwv8YdKBb8FWKdBNinaHKmBv7JpQvqBYx4rxch7WnHzNFzSVrMf8hQepTP",
"ex_priv": "xprv9zHe6DJEmQ8484Z2T2RmyMHtmv9hNov9d5dU5WrXCA4Aaf124KdfakJqLGnVYwvBvMP4ttqm7QL5vuPTepiJiEJREiJnhswKmj6zLttwCMu",
},
"chain_ext": {
"ex_pub": "xpub6EbeQ8h8S7mEGxYTn34gKedwvsmytMW61v51RAc8e6VzgMMLFkkNMN6sYtqvtZQ8TjBKswbxUTzxzj3nZfwr4pzFB7rySMaBUUCJnCuxu33",
"ex_priv": "xprvA1cHzdAEbkCw4UTzg1XfxWhDNqwVUtnEeh9QcnCX5ky1oZ2BiDS7oZnPhdgFNqWwGtB3BNebior1tS26wAtbQzCTe5Pty1BhkcwT8QfWQSP",
},
"addresses": [
"neutron19rl4cm2hmr8afy4kldpxz3fka4jguq0aclyl9j",
"neutron1jrkmdcwgq94uaamx6zax2luewlhf7u4kc80nv9",
"neutron1kng7tv83qesgvv2ze7hxlw4urfrjk8vqyvgzhv",
"neutron1zuvk68xw4y9swp06796rx8zarjvvkrt6t96y3c",
"neutron12ecyuddg4wlnhztusgju5zxxjgznkz7f5kauv8",
],
},
# Nimiq
{
"coin": Bip44Coins.NIMIQ,
Expand Down Expand Up @@ -2614,6 +2638,12 @@
"seed": b"5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4",
"default_address": "NYqCjmV8g8PFCYpyD3K4kSCkQxZff1UNMV",
},
# Neutron
{
"coin": Bip44Coins.NEUTRON,
"seed": b"5eb00bbddcf069084889a8ab9155568165f5c453ccb85e70811aaed6f6da5fc19a5ac40b389cd370d086206dec8aa6c43daea6690f20ad3d8d48b2d2ce9e38e4",
"default_address": "neutron19rl4cm2hmr8afy4kldpxz3fka4jguq0aclyl9j",
},
# Nimiq
{
"coin": Bip44Coins.NIMIQ,
Expand Down

0 comments on commit dacc1ab

Please sign in to comment.