Skip to content

Commit

Permalink
Merge pull request #82 from git-infinianti/master
Browse files Browse the repository at this point in the history
Added Ravencoin Testnet and P2wpkh support,
  • Loading branch information
meherett authored May 1, 2023
2 parents b5b4fc0 + b0381d4 commit ecade4b
Show file tree
Hide file tree
Showing 4 changed files with 267 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ make.bat
Makefile

# Folders stuff
env/
experiment/
.idea/
.tox/
.vs/

# Setuptools stuff
build/
Expand Down
260 changes: 248 additions & 12 deletions hdwallet/cryptocurrencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,45 @@ class AuroracoinMainnet(Cryptocurrency):
WIF_SECRET_KEY = 0x97


class AviancoinMainnet(Cryptocurrency):
NAME = "Aviancoin"
SYMBOL = "AVN"
NETWORK = "mainnet"
SOURCE_CODE = "https://github.com/AvianNetwork/Avian"
COIN_TYPE = CoinType({
"INDEX": 921,
"HARDENED": True
})

SCRIPT_ADDRESS = 0x7a
PUBLIC_KEY_ADDRESS = 0x3c
SEGWIT_ADDRESS = SegwitAddress({
"HRP": "av",
"VERSION": 0x0d
})

EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({
"P2PKH": 0x488ade4,
"P2SH": 0x488ade4,
"P2WPKH": 0x04b2430c,
"P2WPKH_IN_P2SH": 0x049d7878,
"P2WSH": 0x02aa7a99,
"P2WSH_IN_P2SH": 0x0295b005
})
EXTENDED_PUBLIC_KEY = ExtendedPublicKey({
"P2PKH": 0x488b21e,
"P2SH": 0x488b21e,
"P2WPKH": 0x04b24746,
"P2WPKH_IN_P2SH": 0x049d7cb2,
"P2WSH": 0x02aa7ed3,
"P2WSH_IN_P2SH": 0x0295b43f
})

MESSAGE_PREFIX = "Aviancoin Signed Message:\n"
DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0"
WIF_SECRET_KEY = 0x80


class AxeMainnet(Cryptocurrency):

NAME = "Axe"
Expand Down Expand Up @@ -2154,6 +2193,86 @@ class EuropeCoinMainnet(Cryptocurrency):
WIF_SECRET_KEY = 0xa8


class EvrmoreMainnet(Cryptocurrency):

NAME = "Evrmore"
SYMBOL = "EVR"
NETWORK = "mainnet"
SOURCE_CODE = "https://github.com/EvrmoreOrg/Evrmore"
COIN_TYPE = CoinType({
"INDEX": 175,
"HARDENED": True
})

SCRIPT_ADDRESS = 0x5c
PUBLIC_KEY_ADDRESS = 0x21
SEGWIT_ADDRESS = SegwitAddress({
"HRP": "ev",
"VERSION": 0x0b
})

EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({
"P2PKH": 0x488ade4,
"P2SH": 0x488ade4,
"P2WPKH": 0x04b2430c,
"P2WPKH_IN_P2SH": 0x049d7878,
"P2WSH": 0x02aa7a99,
"P2WSH_IN_P2SH": 0x0295b005
})
EXTENDED_PUBLIC_KEY = ExtendedPublicKey({
"P2PKH": 0x488b21e,
"P2SH": 0x488b21e,
"P2WPKH": 0x04b24746,
"P2WPKH_IN_P2SH": 0x049d7cb2,
"P2WSH": 0x02aa7ed3,
"P2WSH_IN_P2SH": 0x0295b43f
})

MESSAGE_PREFIX = "Evrmore Signed Message:\n"
DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0"
WIF_SECRET_KEY = 0x80


class EvrmoreTestnet(Cryptocurrency):

NAME = "Evrmore"
SYMBOL = "EVRTEST"
NETWORK = "testnet"
SOURCE_CODE = "https://github.com/EvrmoreOrg/Evrmore"
COIN_TYPE = CoinType({
"INDEX": 1,
"HARDENED": True
})

SCRIPT_ADDRESS = 0xc4
PUBLIC_KEY_ADDRESS = 0x6f
SEGWIT_ADDRESS = SegwitAddress({
"HRP": "te",
"VERSION": 0x00
})

EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({
"P2PKH": 0x488ade4,
"P2SH": 0x488ade4,
"P2WPKH": 0x04b2430c,
"P2WPKH_IN_P2SH": 0x049d7878,
"P2WSH": 0x02aa7a99,
"P2WSH_IN_P2SH": 0x0295b005
})
EXTENDED_PUBLIC_KEY = ExtendedPublicKey({
"P2PKH": 0x488b21e,
"P2SH": 0x488b21e,
"P2WPKH": 0x04b24746,
"P2WPKH_IN_P2SH": 0x049d7cb2,
"P2WSH": 0x02aa7ed3,
"P2WSH_IN_P2SH": 0x0295b43f
})

MESSAGE_PREFIX = "Evrmore Signed Message:\n"
DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0"
WIF_SECRET_KEY = 0xef


class ExclusiveCoinMainnet(Cryptocurrency):

NAME = "Exclusive Coin"
Expand Down Expand Up @@ -2431,6 +2550,87 @@ class FluxMainnet(Cryptocurrency):
DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0"
WIF_SECRET_KEY = 0x80


class FoxdcoinMainnet(Cryptocurrency):

NAME = "Foxdcoin"
SYMBOL = "FOXD"
NETWORK = "mainnet"
SOURCE_CODE = "https://github.com/foxdproject/foxdcoin"
COIN_TYPE = CoinType({
"INDEX": 175,
"HARDENED": True
})

SCRIPT_ADDRESS = 0x1e
PUBLIC_KEY_ADDRESS = 0x23
SEGWIT_ADDRESS = SegwitAddress({
"HRP": "fx",
"VERSION": 0x0d
})

EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({
"P2PKH": 0x488ade4,
"P2SH": 0x488ade4,
"P2WPKH": 0x04b2430c,
"P2WPKH_IN_P2SH": 0x049d7878,
"P2WSH": 0x02aa7a99,
"P2WSH_IN_P2SH": 0x0295b005
})
EXTENDED_PUBLIC_KEY = ExtendedPublicKey({
"P2PKH": 0x488b21e,
"P2SH": 0x488b21e,
"P2WPKH": 0x04b24746,
"P2WPKH_IN_P2SH": 0x049d7cb2,
"P2WSH": 0x02aa7ed3,
"P2WSH_IN_P2SH": 0x0295b43f
})

MESSAGE_PREFIX = "Foxdcoin Signed Message:\n"
DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0"
WIF_SECRET_KEY = 0x80


class FoxdcoinTestnet(Cryptocurrency):

NAME = "Foxdcoin"
SYMBOL = "FOXDTEST"
NETWORK = "testnet"
SOURCE_CODE = "https://github.com/foxdproject/foxdcoin"
COIN_TYPE = CoinType({
"INDEX": 1,
"HARDENED": True
})

SCRIPT_ADDRESS = 0x5a
PUBLIC_KEY_ADDRESS = 0x5f
SEGWIT_ADDRESS = SegwitAddress({
"HRP": "tf",
"VERSION": 0x00
})

EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({
"P2PKH": 0x488ade4,
"P2SH": 0x488ade4,
"P2WPKH": 0x04b2430c,
"P2WPKH_IN_P2SH": 0x049d7878,
"P2WSH": 0x02aa7a99,
"P2WSH_IN_P2SH": 0x0295b005
})
EXTENDED_PUBLIC_KEY = ExtendedPublicKey({
"P2PKH": 0x488b21e,
"P2SH": 0x488b21e,
"P2WPKH": 0x04b24746,
"P2WPKH_IN_P2SH": 0x049d7cb2,
"P2WSH": 0x02aa7ed3,
"P2WSH_IN_P2SH": 0x0295b43f
})

MESSAGE_PREFIX = "Foxdcoin Signed Message:\n"
DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0"
WIF_SECRET_KEY = 0xef


class FujiCoinMainnet(Cryptocurrency):

NAME = "Fuji Coin"
Expand Down Expand Up @@ -4836,7 +5036,7 @@ class RavencoinMainnet(Cryptocurrency):
NAME = "Ravencoin"
SYMBOL = "RVN"
NETWORK = "mainnet"
SOURCE_CODE = None
SOURCE_CODE = "https://github.com/RavenProject/Ravencoin"
COIN_TYPE = CoinType({
"INDEX": 175,
"HARDENED": True
Expand All @@ -4845,32 +5045,68 @@ class RavencoinMainnet(Cryptocurrency):
SCRIPT_ADDRESS = 0x7a
PUBLIC_KEY_ADDRESS = 0x3c
SEGWIT_ADDRESS = SegwitAddress({
"HRP": None,
"VERSION": 0x00
"HRP": "ra",
"VERSION": 0x0c
})

EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({
"P2PKH": 0x488ade4,
"P2SH": 0x488ade4,
"P2WPKH": None,
"P2WPKH_IN_P2SH": None,
"P2WSH": None,
"P2WSH_IN_P2SH": None
"P2WPKH": 0x04b2430c,
"P2WPKH_IN_P2SH": 0x049d7878,
"P2WSH": 0x02aa7a99,
"P2WSH_IN_P2SH": 0x0295b005
})
EXTENDED_PUBLIC_KEY = ExtendedPublicKey({
"P2PKH": 0x488b21e,
"P2SH": 0x488b21e,
"P2WPKH": None,
"P2WPKH_IN_P2SH": None,
"P2WSH": None,
"P2WSH_IN_P2SH": None
"P2WPKH": 0x04b24746,
"P2WPKH_IN_P2SH": 0x049d7cb2,
"P2WSH": 0x02aa7ed3,
"P2WSH_IN_P2SH": 0x0295b43f
})

MESSAGE_PREFIX = "Raven Signed Message:\n"
MESSAGE_PREFIX = "Raven Signed Message:\n"
DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0"
WIF_SECRET_KEY = 0x80


class RavencoinTestnet(Cryptocurrency):

NAME = "Ravencoin"
SYMBOL = "RVNTEST"
NETWORK = "testnet"
SOURCE_CODE = "https://github.com/RavenProject/Ravencoin"
COIN_TYPE = CoinType({
"INDEX": 1,
"HARDENED": True
})

SCRIPT_ADDRESS = 0xc4
PUBLIC_KEY_ADDRESS = 0x6f
SEGWIT_ADDRESS = SegwitAddress({
"HRP": "tr",
"VERSION": 0x00
})

EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({
"P2PKH": 0x488ade4,
"P2SH": 0x488ade4,
"P2WPKH": 0x04b2430c,
"P2WPKH_IN_P2SH": 0x049d7878,
"P2WSH": 0x02aa7a99,
"P2WSH_IN_P2SH": 0x0295b005
})
EXTENDED_PUBLIC_KEY = ExtendedPublicKey({
"P2PKH": 0x488b21e,
"P2SH": 0x488b21e,
"P2WPKH": 0x04b24746,
"P2WPKH_IN_P2SH": 0x049d7cb2,
"P2WSH": 0x02aa7ed3,
"P2WSH_IN_P2SH": 0x0295b43f
})


class ReddcoinMainnet(Cryptocurrency):

NAME = "Reddcoin"
Expand Down
10 changes: 6 additions & 4 deletions hdwallet/hdwallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1196,9 +1196,10 @@ def p2wpkh_address(self) -> Optional[str]:

compressed_public_key = unhexlify(self.compressed())
public_key_hash = ripemd160(sha256(compressed_public_key).digest())
if self._cryptocurrency.SEGWIT_ADDRESS.HRP is None:
segwit = self._cryptocurrency.SEGWIT_ADDRESS
if segwit.HRP is None:
return None
return ensure_string(encode(self._cryptocurrency.SEGWIT_ADDRESS.HRP, 0, public_key_hash))
return ensure_string(encode(segwit.HRP, segwit.VERSION, public_key_hash))

def p2wpkh_in_p2sh_address(self) -> Optional[str]:
"""
Expand Down Expand Up @@ -1240,9 +1241,10 @@ def p2wsh_address(self) -> Optional[str]:

compressed_public_key = unhexlify("5121" + self.compressed() + "51ae")
script_hash = sha256(compressed_public_key).digest()
if self._cryptocurrency.SEGWIT_ADDRESS.HRP is None:
segwit = self._cryptocurrency.SEGWIT_ADDRESS
if segwit.HRP is None:
return None
return ensure_string(encode(self._cryptocurrency.SEGWIT_ADDRESS.HRP, 0, script_hash))
return ensure_string(encode(segwit.HRP, segwit.VERSION, script_hash))

def p2wsh_in_p2sh_address(self) -> Optional[str]:
"""
Expand Down
Loading

0 comments on commit ecade4b

Please sign in to comment.