bitcoin core – How do I get a hex encoded pubkey for `importpubkey` in javascript

I’m trying to import watch-only wallets to bitcoin-core via the importpubkey command and I can’t seem to construct a correct pubkey in javascript. Does anyone know where I go wrong with this:

  1. Generate a https://iancoleman.io/bip39/
  2. In the BIP44 tab, copy the BIP32 Extended Public Key field
  3. Run:
    const hex = new Buffer('(BIP32 Extended Public Key)').toString('hex');
    const result = await this.client.importpubkey({ pubkey: hex, rescan: false });

I get the response: "Pubkey is not a valid public key" for everything I try.

  1. Which public key should I be using? Since there are many on https://iancoleman.io/bip39/ when you generate a wallet.
  2. Also, is new Buffer('(BIP32 Extended Public Key)').toString('hex'); the proper hex format bitcoin-core is expecting?

I’m trying to do this in testnet mode if that makes a difference, the wallet I generate is also a testnet wallet.