Sha256: dcb2fa5816705023117ed35d2bf4783ab0b964943142f501015c84111305b77c

Contents?: true

Size: 681 Bytes

Versions: 2

Compression:

Stored size: 681 Bytes

Contents

module MoneyTree
  class Address
    attr_reader :private_key
    attr_reader :public_key

    def initialize(opts = {})
      private_key = opts.delete(:private_key)
      @private_key = PrivateKey.new({ key: private_key }.merge(opts))
      @public_key = PublicKey.new(@private_key, opts)
    end

    def to_s(network: :bitcoin)
      @public_key.to_s(network: network)
    end

    def to_bech32(network: :bitcoin)
      hrp = NETWORKS[network][:human_readable_part]
      witprog = @public_key.to_ripemd160
      Support.to_serialized_bech32(hrp, witprog)
    end

    def to_p2wpkh_p2sh(network: :bitcoin)
      @public_key.to_p2wpkh_p2sh(network: network)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
money-tree-0.11.2 lib/money-tree/address.rb
money-tree-0.11.1 lib/money-tree/address.rb