LoginSignup
18
11

More than 5 years have passed since last update.

EthereumでBIP44 HDWALLETを作成する

Last updated at Posted at 2016-06-07

EthereumでBIP44 HDWALLETを作成する

ethereumでもBIP32,39,44を用いたウォレットが使えるみたいなので作ってみた

用意

npm で以下のモジュールをインストール

  • bip39
  • ethereumjs-wallet

bip39は乱数の初期化ベクトル作るだけの仕組みでビットコイン全く関係ないからビットコインのモジュールそのまま使える

BIP仕様

コイン種別

サンプルコード

var bip39 = require('bip39');
var hdkey = require('ethereumjs-wallet/hdkey')

var mnemonic = 'armed bundle pudding lazy strategy impulse where identify submit weekend physical antenna flight social acoustic absurd whip snack decide blur unfold fiction pumpkin athlete';
var password = '';
var masterseed = bip39.mnemonicToSeed(mnemonic, password);
var hdnode = hdkey.fromSeedBuffer(masterseed);

var getKeyPair = function(hdnode){
    return {
        "address" : hdnode.getWallet().getAddressString(),
        "private" : hdnode.getWallet().getPrivateKeyString(),
        "public" : hdnode.getWallet().getPublicKeyString(),
    }
}

// cointype=60=eth
// m / purpose' / coin_type' / account' / change / address_index
console.log(getKeyPair(hdnode.derivePath("m/44'/60'/0'/0/0")))
console.log(getKeyPair(hdnode.derivePath("m/44'/60'/0'/0/1")))

その他

残高確認やトランザクションの送信

  • GETHにつないでWEB3経由でおこなう

PS

ethereumjs-walletを作った作者(Alex Beregszasziさん)はtrezorへのeth対応パッチをpull-requestした人なので信用できるはず

18
11
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
18
11