 
   @network Application.get_env(:rpc, :network)
 
-  # TODO: P2SH in/out, P2PK in/out
+  # TODO: P2SH in/out
 
   def parse_address(%TransactionOutput{pk_script: script}) do
     case script do


      # P2PK output (compressed): 33 <pubkey> OP_CHECKSIG
      <<33, pk :: bytes-size(33), 172>> ->
        address = pk
        |> Base.encode16(case: :lower)
        |> BitcoinTool.process!(:pubkey_hex)
        {:ok, address }

      # P2PK output (uncompressed): 65 <pubkey> OP_CHECKSIG
      <<65, pk :: bytes-size(65), 172>> ->
        address = pk
        |> Base.encode16(case: :lower)
        |> BitcoinTool.process!(:pubkey_hex)
        {:ok, address }

      # Unmatched
      _ ->

    end
  end

  defp pubkey_to_address(pubkey) do
    address = pubkey
    |> Base.encode16(case: :lower)
    |> BitcoinTool.process!(:pubkey_hex)
    {:ok, address }
  end

end
