28.4 C
Bucharest
Friday, July 12, 2024

segregated witness – How one can create a litecoin testnet segwit pockets offline


Hello So I’m utilizing the bitcoinjs-lib pacakge to generate pockets deal with and personal keys regionally but it surely looks as if it is creating the litecoin deal with of legacy kind, my purpose is right here to create of segwit kind which has a prefix like tltc

right here is my code:

const bitcoin = require('bitcoinjs-lib');

operate generateLtcAddress() {
    const litecoinTestnet = {
        messagePrefix: 'x19Litecoin Signed Message:n',
        bip32: {
            public: 0x043587cf,
            personal: 0x04358394
        },
        pubKeyHash: 0x6f,
        scriptHash: 0xc4, //  for segwit (begin with 2)
        wif: 0xef
    };

    const keyPair = bitcoin.ECPair.makeRandom({ community: litecoinTestnet });
    const { deal with } = bitcoin.funds.p2pkh({
        pubkey: keyPair.publicKey,
        community: litecoinTestnet
    });

    const privateKeyWIF = keyPair.toWIF();

    console.log("Litecoin Testnet Handle:", deal with);
    console.log("Personal Key (WIF):", privateKeyWIF);
    return {
        deal with: deal with,
        privateKey: privateKeyWIF
    };
}

Output:

Litecoin Testnet Handle: mnUDkLibVp1MhKSm6pvYgT26PUxeTjHJiR
Personal Key (WIF): cQgM1FZSkJWJ3eFs4xfYozfCt37KYKr1rEGEYwuNdquwsfzjASnM

please let me know the way I can obtain this. or ought to I exploit every other npm package deal or one thing?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles