Class: Bitcoin::Wallet::DB
- Inherits:
-
Object
- Object
- Bitcoin::Wallet::DB
- Defined in:
- lib/extensions/bitcoin/wallet/db.rb
Instance Method Summary collapse
Instance Method Details
#get_key_index(script_pubkey) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/extensions/bitcoin/wallet/db.rb', line 15 def get_key_index(script_pubkey) k = 'p' + script_pubkey id = level_db.get(k) return unless id id.htb.unpack('I*') end |
#save_key(account, purpose, index, key) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/extensions/bitcoin/wallet/db.rb', line 4 def save_key(account, purpose, index, key) pubkey = key.pub id = [account.purpose, account.index, purpose, index].pack('I*').bth k = KEY_PREFIX[:key] + id script_pubkey = Bitcoin::Script.to_p2wpkh(Bitcoin.hash160(pubkey)).to_payload.bth k2 = 'p' + script_pubkey level_db.put(k, pubkey) level_db.put(k2, id) key end |