class EthereumBip44::Wallet

“44'”, # bip 44 “60'”, # coin, 0': bitcoin, 60': ethereum “0'”, # wallet “0” # 0 - public, 1 = private “0” # index

Public Class Methods

from_mnemonic(mnemonic, path) click to toggle source
# File lib/ethereum_bip44/wallet.rb, line 18
def self.from_mnemonic(mnemonic, path)
  seed = BipMnemonic.to_seed(mnemonic: mnemonic) # 2. 该助记词使用 PBKDF2 转化为种子(参见 BIP39)
  Wallet.from_seed(seed, path)
end
from_seed(seed, path) click to toggle source
# File lib/ethereum_bip44/wallet.rb, line 12
def self.from_seed(seed, path)
  master = MoneyTree::Master.new(seed_hex: seed) # 3. 种子用于使用 HMAC-SHA512 生成根私钥(参见 BIP32)
  wallet_node = master.node_for_path(path) # 4. 从该根私钥,导出子私钥(参见 BIP32),其中节点布局由BIP44设置
  Wallet.new(wallet_node)
end
from_xpub(xpub) click to toggle source
# File lib/ethereum_bip44/wallet.rb, line 23
def self.from_xpub(xpub)
  wallet_node = MoneyTree::Node.from_bip32(xpub)
  Wallet.new(wallet_node)
end
new(wallet_node) click to toggle source
# File lib/ethereum_bip44/wallet.rb, line 38
def initialize(wallet_node)
  @wallet_node = wallet_node
end

Public Instance Methods

xprv() click to toggle source
# File lib/ethereum_bip44/wallet.rb, line 32
def xprv
  @wallet_node.to_bip32(:private)
end
xpub() click to toggle source
# File lib/ethereum_bip44/wallet.rb, line 28
def xpub
  @wallet_node.to_bip32
end