0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Blockchain(ブロックチェーン)Advent Calendar 2021

Day 12

Litecoinの鍵をbitcoinjs-libで生成する

Last updated at Posted at 2021-12-13

はじめに

以前、bitcoinjs-libを用いてBitcoin Testnet/Signetの鍵、アドレスを生成してそこに送金し、TX作るというハンズオンをやったのですが、
Litecoin Mainnetの鍵を作ってみましょう。

ニーモニックを生成

使うコードはこちら

node getMnemonic
mnemonic:
bomb strategy round brown bomb solve biology soft second artefact once delay coach slight arch vintage always life toss artwork peasant finish device bamboo

ここに載っているニーモニックは使わないでくださいね。

Litecoinの鍵を生成

getKeys.js
let bitcoinNetwork = TESTNET; // MAINNET, TESTNET, LITECOIN or DOGECOIN

↑この行を以下のように書き換えます。

getKeys.js
let bitcoinNetwork = LITECOIN; 

以下のLITECOINのprefix情報が使われるようになるわけですね。

getKeys.js
const LITECOIN = {
    messagePrefix: '\x19Litecoin Signed Message:\n',
    bech32: 'ltc',
    bip32: {
      public: 0x019da462,
      private: 0x019d9cfe,
    },
    pubKeyHash: 0x30,
    scriptHash: 0x32,
    wif: 0xb0,
};

実行して拡張秘密鍵と拡張公開鍵を生成してみましょう。

node getKeys.js
path:
m/44'/2'/0'
xpub:
Ltub2Yp2889mKTKeuzHyJqgDszUfp8GWyRcYACGp5JhSwhJ92tLpuKuimd44JZ5Brfq4HzeLzdHFHLZJMQTgGxpvzEmBcyCoKuxzkRnfneDrdK6
xpriv:
Ltpv77dgXLjE5JnhJ7b94EBqoQeTNZaKuB3t5gAnQKwA1WWYSX9kaQsHm1wo4CNLNPHyv9vyaAR4CRrWuqUqx3fV9xbuDo9HmLXMLzAF8mGM2eG

Litecoinの拡張公開鍵、拡張秘密鍵の接頭辞は"L"になります。

次回はアドレス生成してみましょう!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?