How to generate eos address from xpub
chenxing-luckysky opened this issue · 1 comments
chenxing-luckysky commented
Version of EOSJS
"^22.1.0"
I was building a HD Wallet, and derivate some xpub to create wallet for different coins. eos is one of the coins. and I can't find any recourses to generate address from this xpub?
function xpubToEosAddress(xpub){
...logic here;
return address;
}
for example:
for btc, I have
function xpubToBtcAddress(xpub) {
const node = HDKEY.fromExtendedKey(xpub);
const { address } = bitcoinjs.payments.p2pkh({ pubkey: node.publicKey });
return address;
}
So How can i generate eos address from xpub
bradlhart commented
eos uses account names, not addresses. I assume you would need to create an account with the key. I do not have any resources for converting an xpub key to eosio format however. This library does have some key conversion code you can look at for reference though in the PublicKey.ts
file, as well as a few other files. You can also check the elliptic
library that eosjs utilizes for much of the key conversions.