I am using solana.web3.js. The connection.getAccountInfo() works fine when I'm not using HD wallets (eg if I use Keypair.fromSeed()) per the Solana Cookbook ).
However I am now using BIP44 HD Wallets to make multiple wallets from a single seed:
const mnemonic =
(12 word phrase);
const seed = bip39.mnemonicToSeedSync(mnemonic, "");
for (let i = 0; i < 10; i++) {
const path = `m/44'/501'/${i}'/0'`;
const keypair = Keypair.fromSeed(derivePath(path, seed.toString("hex")).key);
console.log(`${path} => ${keypair.publicKey.toBase58()}`);
}
When I try to get the account info from the first account (the one with the keyPath m/44'/501'/0'/0':
const account = await connection.getAccountInfo(wallets[0].publicKey);
getAccountInfo() fails with:
Error: Could not find account '(publicKey here)'
How can I get account information for an HD wallet?