Class: Banano::Key
- Inherits:
-
Object
- Object
- Banano::Key
- Defined in:
- lib/banano/key.rb
Instance Method Summary collapse
-
#expand ⇒ Object
Derive public key and account from private key.
- #generate(seed: nil, index: nil) ⇒ Object
- #id ⇒ Object
- #info ⇒ Object
-
#initialize(node:, key: nil) ⇒ Key
constructor
A new instance of Key.
Constructor Details
#initialize(node:, key: nil) ⇒ Key
Returns a new instance of Key.
5 6 7 8 |
# File 'lib/banano/key.rb', line 5 def initialize(node:, key: nil) @node = node @key = key end |
Instance Method Details
#expand ⇒ Object
Derive public key and account from private key
21 22 23 24 25 |
# File 'lib/banano/key.rb', line 21 def return {} if @key.nil? rpc(action: :key_expand, params: {key: @key}) end |
#generate(seed: nil, index: nil) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/banano/key.rb', line 10 def generate(seed: nil, index: nil) if seed.nil? && index.nil? rpc(action: :key_create) elsif !seed.nil? && !index.nil? rpc(action: :deterministic_key, params: {seed: seed, index: index}) else raise ArgumentError, "Method must be called with either seed AND index params" end end |
#id ⇒ Object
27 28 29 |
# File 'lib/banano/key.rb', line 27 def id @key end |
#info ⇒ Object
31 32 33 34 |
# File 'lib/banano/key.rb', line 31 def info key_required! rpc(action: :key_expand) end |