Skip to content

Commit f4c43d4

Browse files
committed
Add: AlgorandHD & BIP32HD examples
1 parent 89ef265 commit f4c43d4

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

examples/hds/algorand.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env python3
2+
3+
from hdwallet.hds import AlgorandHD
4+
from hdwallet.cryptocurrencies import Algorand as Cryptocurrency
5+
from hdwallet.derivations import (
6+
BIP44Derivation, CHANGES
7+
)
8+
9+
algorand_hd: AlgorandHD = AlgorandHD()
10+
11+
seed = "3be138b36c013fc797d9a897dfeb57c82bfa43f32509753140d851bc88be0fbe5a0abe984e0ca0678749952a1b1f99853ce30b0c388a4da38e2a65c5d1f23e9b"
12+
xprivate_key = "xprv9s21ZrQH143K4L18AD5Ko2ELW8bqaGLW4vfASZzo9yEN8fkZPZLdECXWXAMovtonu7DdEFwJuYH31QT96FWJUfkiLUVT8t8e3WNDiwZkuLJ"
13+
xpublic_key = "xpub661MyMwAqRbcGp5bGEcLAAB54ASKyj4MS9amExQQiJmM1U5hw6esmzqzNQtquzBRNvLWtPC2kRu2kZR888FSAiZRpvKdjgbmoKRCgGM1YEy"
14+
private_key = "7f60ec0fa89064a37e208ade560c098586dd887e2133bee4564af1de52bc7f5c"
15+
wif = "L1VKQooPmgVLD35vHMeprus1zFYx58bHGMfTz8QYTEnRCzbjwMoo"
16+
public_key = "023e23967b818fb3959f2056b6e6449a65c4982c1267398d8897b921ab53b0be4b"
17+
18+
algorand_hd.from_seed(seed=seed)
19+
# algorand_hd.from_xprivate_key(xprivate_key=xprivate_key)
20+
# algorand_hd.from_xpublic_key(xpublic_key=xpublic_key)
21+
22+
print("Seed:", algorand_hd.seed())
23+
print("Strict:", algorand_hd.strict())
24+
print("Root XPrivate Key:", algorand_hd.root_xprivate_key())
25+
print("Root XPublic Key:", algorand_hd.root_xpublic_key())
26+
print("Root Private Key:", algorand_hd.root_private_key())
27+
print("Root Chain Code:", algorand_hd.root_chain_code())
28+
print("Root Public Key:", algorand_hd.root_public_key())
29+
30+
bip44_derivation: BIP44Derivation = BIP44Derivation(
31+
coin_type=Cryptocurrency.COIN_TYPE, account=0, change=CHANGES.EXTERNAL_CHAIN, address=0
32+
)
33+
algorand_hd.from_derivation(derivation=bip44_derivation)
34+
35+
# algorand_hd.from_private_key(private_key=private_key)
36+
# algorand_hd.from_wif(wif=wif)
37+
# algorand_hd.from_public_key(public_key=public_key)
38+
39+
print("XPrivate Key:", algorand_hd.xprivate_key())
40+
print("XPublic Key:", algorand_hd.xpublic_key())
41+
print("Private Key:", algorand_hd.private_key())
42+
print("Chain Code:", algorand_hd.chain_code())
43+
print("Public Key:", algorand_hd.public_key())
44+
print("Hash:", algorand_hd.hash())
45+
print("Fingerprint:", algorand_hd.fingerprint())
46+
print("Parent Fingerprint:", algorand_hd.parent_fingerprint())
47+
print("Depth:", algorand_hd.depth())
48+
print("Path:", algorand_hd.path())
49+
print("Index:", algorand_hd.index())
50+
print("Indexes:", algorand_hd.indexes())
51+
print("Address:", algorand_hd.address())

examples/hds/bip32.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
print("Path:", bip32_hd.path())
5656
print("Index:", bip32_hd.index())
5757
print("Indexes:", bip32_hd.indexes())
58-
print("getStrict:", bip32_hd.strict())
5958
print("Address:", bip32_hd.address(
6059
address=Cryptocurrency.ADDRESSES.P2TR
6160
))

0 commit comments

Comments
 (0)