Class: PolarLoop::Wallet
- Inherits:
-
Object
- Object
- PolarLoop::Wallet
- Defined in:
- lib/polarloop/wallet.rb
Constant Summary collapse
- BIP44_BASE_PATH =
"m/44'/60'/0'/0"
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #address ⇒ Object
-
#initialize(mnemonic, index: 0) ⇒ Wallet
constructor
A new instance of Wallet.
Constructor Details
#initialize(mnemonic, index: 0) ⇒ Wallet
Returns a new instance of Wallet.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/polarloop/wallet.rb', line 12 def initialize(mnemonic, index: 0) validate_mnemonic!(mnemonic) seed_hex = BipMnemonic.to_seed(mnemonic: mnemonic) master = MoneyTree::Master.new(seed_hex: seed_hex) node = master.node_for_path("#{BIP44_BASE_PATH}/#{index}") @key = Eth::Key.new(priv: node.private_key.to_hex) rescue WalletError raise rescue => e raise WalletError, "Failed to derive wallet: #{e.}" end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
10 11 12 |
# File 'lib/polarloop/wallet.rb', line 10 def key @key end |
Instance Method Details
#address ⇒ Object
24 25 26 |
# File 'lib/polarloop/wallet.rb', line 24 def address @key.address.to_s end |