How can I derive BTC m44 addresses from xpub?

I checked Swan’s Address Derivation Library https://github.com/swan-bitcoin/xpub-tool.

I try to get m44 address, but I got m84. Why? Do you know is it any parameter to force return m44? I tried to pass path: "m/44'/0'/0'/0", but it did not help.

Do you have any idea?

addressFromXPub("xpub6C5oXscLYZwgq2DB42TFC32QcoPa1MeCWUNPZSjydunniCM77TRcBfFnjScJeToVXS5RBDr53Ls5RXvDHujmFSL4Fqc9kkpsMjU1vg68xv7"
  );

export const addressFromXPub = (key) => {
  console.log(
    addressesFromExtPubKey({
      extPubKey: key,
      network: "mainnet",
      addressCount: 3,
    })
  );
};
[
    {path: "m/84'/0'/0'/0/0", address: "bc1qfgnqm6g46ys0h9gh606m76wemka2rrttrac90x"
    },
    {path: "m/84'/0'/0'/0/1", address: "bc1qnvzdj2m4wsrcrtl30j5c304qa77v4h2s8ajp0r"
    },
    {path: "m/84'/0'/0'/0/2", address: "bc1qjf5u77e6clwkxgf7a0shw7zq2nhqr4vjys7an0"
    }
]

Answer

From official docs

Address derivation will default to bech32 (native SegWit) unless a different purpose is specified. For example: to derive wrapped SegWit addresses (starting with 3…) specify the appropriate purpose with purpose: Purpose.P2SH.

So, to get m44 you need to set purpose:Purpose.P2PKH

Sample

const lib = require('@swan-bitcoin/xpub-lib/lib/derivation')
const Purpose = require('@swan-bitcoin/xpub-lib/lib/purpose')

console.log(
    lib.addressesFromExtPubKey({
        extPubKey: 'xpub6C5oXscLYZwgq2DB42TFC32QcoPa1MeCWUNPZSjydunniCM77TRcBfFnjScJeToVXS5RBDr53Ls5RXvDHujmFSL4Fqc9kkpsMjU1vg68xv7',
        network: "mainnet",
        addressCount: 3,
        purpose: Purpose.Purpose.P2PKH
    })
);

Result:

[
  {
    path: "m/44'/0'/0'/0/0",
    address: '17m4bFvDU8wNn5XAyXRqQUKUPLf5GByybS'
  },
  {
    path: "m/44'/0'/0'/0/1",
    address: '1F8fYbrGGfSYyKfWGzz4YdFbNrMbdRzJer'
  },
  {
    path: "m/44'/0'/0'/0/2",
    address: '1EMAQrBE3ZmhQcQLDWKfakMognoXotM8pU'
  }
]