Class: Wallet
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Wallet
- Defined in:
- app/models/wallet.rb
Instance Method Summary collapse
Instance Method Details
#create_keys(pv_random = nil, pr_random = nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/models/wallet.rb', line 17 def create_keys(pv_random = nil, pr_random = nil) if pv_random.nil? && pr_random.nil? pv_random = SecureRandom.hex(64) pr_random = SecureRandom.hex(64) end dig_pv = Digest::SHA256.hexdigest(pv_random) dig_pr = Digest::SHA256.hexdigest(pr_random) if Wallet.exists?(pr_key: dig_pr) || Wallet.exists?(pv_key: dig_pv) raise "Key already exists" else self.pr_key = dig_pr self.pv_key = dig_pv end end |