Skip to content

Commit

Permalink
Add Secret Network Support (3rdIteration#336)
Browse files Browse the repository at this point in the history
* Add Secret Network Support
* Update requirements-full.txt (Secret Network needs py_crypto_hd_wallet at least 1.1.0)
  • Loading branch information
3rdIteration authored Mar 28, 2022
1 parent 153407e commit e588005
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ If you need help, [your best bet is to look at my BTCRecover playlist on YouTube
* Monacoin
* Polkadot (sr25519, like those produced by polkadot.js)
* Ripple
* Secret Network
* Solana
* Stellar
* Tezos
Expand Down
48 changes: 48 additions & 0 deletions btcrecover/btcrseed.py
Original file line number Diff line number Diff line change
Expand Up @@ -2334,6 +2334,54 @@ def _verify_seed(self, mnemonic, passphrase = None):

return False

############### Secret Network ###############

@register_selectable_wallet_class('Secret Network BIP44 (Old/Ledger Derivation Path)')
class WalletSecretNetworkOld(WalletPyCryptoHDWallet):
def _verify_seed(self, mnemonic, passphrase = None):
if passphrase:
testSaltList = [passphrase]
else:
testSaltList = self._derivation_salts

for salt in testSaltList:

wallet = py_crypto_hd_wallet.HdWalletBipFactory(py_crypto_hd_wallet.HdWalletBip44Coins.SECRET_NETWORK_OLD)

wallet2 = wallet.CreateFromMnemonic("Cosmos", mnemonic = " ".join(mnemonic), passphrase = salt.decode())

for account_index in range(self._address_start_index, self._address_start_index + self._addrs_to_generate):
wallet2.Generate(addr_num=1, addr_off=0, acc_idx=account_index,
change_idx=py_crypto_hd_wallet.HdWalletBipChanges.CHAIN_EXT)

if wallet2.ToDict()['address']['address_0']['address'] in self._known_hash160s:
return True

return False

@register_selectable_wallet_class('Secret Network BIP44 (New Derivation Path)')
class WalletSecretNetworkNew(WalletPyCryptoHDWallet):
def _verify_seed(self, mnemonic, passphrase = None):
if passphrase:
testSaltList = [passphrase]
else:
testSaltList = self._derivation_salts

for salt in testSaltList:

wallet = py_crypto_hd_wallet.HdWalletBipFactory(py_crypto_hd_wallet.HdWalletBip44Coins.SECRET_NETWORK_NEW)

wallet2 = wallet.CreateFromMnemonic("Cosmos", mnemonic = " ".join(mnemonic), passphrase = salt.decode())

for account_index in range(self._address_start_index, self._address_start_index + self._addrs_to_generate):
wallet2.Generate(addr_num=1, addr_off=0, acc_idx=account_index,
change_idx=py_crypto_hd_wallet.HdWalletBipChanges.CHAIN_EXT)

if wallet2.ToDict()['address']['address_0']['address'] in self._known_hash160s:
return True

return False

############### Helium ###############

@register_selectable_wallet_class('Helium BIP39/44 & Mobile')
Expand Down
10 changes: 10 additions & 0 deletions btcrecover/test/test_seeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -900,11 +900,21 @@ def test_WalletPyCryptoHDWallet_Cosmos(self):
"doctor giant eternal huge improve suit service poem logic dynamic crane summer exhibit describe later suit dignity ahead unknown fall syrup mirror nurse season")

@skipUnless(can_load_PyCryptoHDWallet, "requires Py_Crypto_HD_Wallet module")
def test_WalletPyCryptoHDWallet_SecretNetworkNew(self):
self.address_tester(btcrseed.WalletSecretNetworkNew, "secret1788gts0a69v5fckayds5cz9n3y4zfmtqct5qxc", 1,
"doctor giant eternal huge improve suit service poem logic dynamic crane summer exhibit describe later suit dignity ahead unknown fall syrup mirror nurse season")

@skipUnless(can_load_PyCryptoHDWallet, "requires Py_Crypto_HD_Wallet module")
def test_WalletPyCryptoHDWallet_SecretNetworkOld(self):
self.address_tester(btcrseed.WalletSecretNetworkOld, "secret1t47f66q50ft66ypwn9x7laeectyvh23azueqxu", 1,
"doctor giant eternal huge improve suit service poem logic dynamic crane summer exhibit describe later suit dignity ahead unknown fall syrup mirror nurse season")
@skipUnless(can_load_PyCryptoHDWallet, "requires Py_Crypto_HD_Wallet module")
def test_WalletPyCryptoHDWallet_Tezos(self):
self.address_tester(btcrseed.WalletTezos, "tz1UXZKEq7SsveAi1jpKBeigcdoFHmVopHKq", 1,
"cake return enhance slender swap butter code cram fashion warm uphold adapt swarm slight misery enhance almost ability artefact lava sugar regret example lake")



@skipUnless(can_load_PyCryptoHDWallet, "requires Py_Crypto_HD_Wallet module")
def test_WalletPyCryptoHDWallet_Avalanche(self):
self.address_tester(btcrseed.WalletAvalanche, "X-avax1mpf7j47w7t3xt32g3vzm0zvzy35d7t5twv2ax3", 2,
Expand Down
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ If you have found a bug, please open an issue on Github here: [https://github.co
* Monacoin
* Polkadot (sr25519, like those produced by polkadot.js)
* Ripple
* Secret Network
* Solana
* Stellar
* Tezos
Expand Down
2 changes: 1 addition & 1 deletion requirements-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pycryptodome~=3.12.0
ecdsa==0.17.0
groestlcoin_hash~=1.0.3
eth-keyfile~=0.5.1
py_crypto_hd_wallet~=1.0.1
py_crypto_hd_wallet~=1.1.0
pynacl~=1.4.0
bitstring~=3.1.9
shamir-mnemonic~=0.2.2
Expand Down

0 comments on commit e588005

Please sign in to comment.