Class: Bitcoin::Descriptor::Addr

Inherits:
Expression show all
Includes:
Util
Defined in:
lib/bitcoin/descriptor/addr.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

#byte_to_bit, #calc_checksum, #decode_base58_address, #double_sha256, #encode_base58_address, #hash160, #hkdf_sha256, #hmac_sha256, #pack_boolean, #pack_var_int, #pack_var_string, #padding_zero, #sha256, #tagged_hash, #unpack_boolean, #unpack_var_int, #unpack_var_int_from_io, #unpack_var_string, #valid_address?

Methods inherited from Expression

#==, #compressed_key?, #derive_path, #extract_pubkey, #to_hex, #to_s

Constructor Details

#initialize(addr) ⇒ Addr

Returns a new instance of Addr.

Raises:

  • (ArgumentError)


8
9
10
11
12
# File 'lib/bitcoin/descriptor/addr.rb', line 8

def initialize(addr)
  raise ArgumentError, "Address must be string." unless addr.is_a?(String)
  raise ArgumentError, "Address is not valid." unless valid_address?(addr)
  @addr = addr
end

Instance Attribute Details

#addrObject (readonly)

Returns the value of attribute addr.



6
7
8
# File 'lib/bitcoin/descriptor/addr.rb', line 6

def addr
  @addr
end

Instance Method Details

#argsObject



26
27
28
# File 'lib/bitcoin/descriptor/addr.rb', line 26

def args
  addr
end

#to_scriptObject



18
19
20
# File 'lib/bitcoin/descriptor/addr.rb', line 18

def to_script
  Bitcoin::Script.parse_from_addr(addr)
end

#top_level?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/bitcoin/descriptor/addr.rb', line 22

def top_level?
  true
end

#typeObject



14
15
16
# File 'lib/bitcoin/descriptor/addr.rb', line 14

def type
  :addr
end