Class: RubyCoin::Bitcoin::Address

Inherits:
Address
  • Object
show all
Defined in:
lib/ruby_coin/bitcoin/address.rb

Instance Attribute Summary

Attributes inherited from Address

#compressed, #curve, #public_key

Instance Method Summary collapse

Methods inherited from Address

#compressed?, #to_s

Methods included from Utilities

#extract_options!

Constructor Details

#initialize(*args) ⇒ Address

Returns a new instance of Address.



4
5
6
# File 'lib/ruby_coin/bitcoin/address.rb', line 4

def initialize(*args)
  super(CURVE_TYPE, *args)
end

Instance Method Details

#addressObject



8
9
10
# File 'lib/ruby_coin/bitcoin/address.rb', line 8

def address
  '1' + encode_address
end

#private_keyObject



16
17
18
19
20
21
22
# File 'lib/ruby_coin/bitcoin/address.rb', line 16

def private_key
  key = compressed? ? @private_key + '01' : @private_key
  hex = PRIKEY_VER + key
  sum = checksum(hex)

  number_to_base((hex + sum).to_i(16), ADDR_CHARS)
end

#version_hash(hex) ⇒ Object



12
13
14
# File 'lib/ruby_coin/bitcoin/address.rb', line 12

def version_hash(hex)
  PUBKEY_VER + hash160(hex)
end