Hi, so I'm using the bitcoinjs-lib package to locally generate a wallet address and private keys, but it seems that it creates the legacy type litecoin address, my goal here is to create a segwit type which has a prefix as tltc
here is my code:
const bitcoin = require('bitcoinjs-lib');
function generateLtcAddress() {
const litecoinTestnet = {
messagePrefix: '\x19Litecoin Signed Message:\n',
bip32: {
public: 0x043587cf,
private: 0x04358394
},
pubKeyHash: 0x6f,
scriptHash: 0xc4, // for segwit (start with 2)
wif: 0xef
};
const keyPair = bitcoin.ECPair.makeRandom({ network: litecoinTestnet });
const { address } = bitcoin.payments.p2pkh({
pubkey: keyPair.publicKey,
network: litecoinTestnet
});
const privateKeyWIF = keyPair.toWIF();
console.log("Litecoin Testnet Address:", address);
console.log("Private Key (WIF):", privateKeyWIF);
return {
address: address,
privateKey: privateKeyWIF
};
}
To go out:
Litecoin Testnet Address: mnUDkLibVp1MhKSm6pvYgT26PUxeTjHJiR
Private Key (WIF): cQgM1FZSkJWJ3eFs4xfYozfCt37KYKr1rEGEYwuNdquwsfzjASnM
please let me know how I can achieve this. or should I use another npm package or something like that?