summaryrefslogtreecommitdiff
path: root/design-documents/035-regional-currencies.rst
blob: 3d62dcc33a8f6f362ac301e54de5c9bca3c4bce7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
DD 35: Regional currencies
##########################

Summary
=======

This design document discusses how the GNU Taler wallet can support both
regional currency deployments and official fiat currencies.

Motivation
==========

Digital cash in a Taler wallet always requires some kind of trust anchor that
backs its value, be it either an exchange directly or an auditor that vouches
for one or more exchanges.

The currency code or symbol (EUR, USD, $, ...) is thus not enough to know what
a particular wallet balance really means.  It also matters what exchange or
auditor is behind it.  Thus the wallet needs some mechanism to allow users to
distinguish between an official deployment of a currency (say EUR in Europe) or
deployments of regional currencies.  Regional currencies might have coinciding
currency names for different incompatible deployments (say, MANA to buy Club
Mate drinks at different hacker events with completely separate and independent
Taler deployments).

Requirements
============

* Official deployments for fiat currencies should be supported without clutter
* Regional currencies should be easy to use as well
* It must be easy to integrate regional/official currencies with the existing
  Taler auditor/exchange structure
* Wallet users should be able to see disagregated balance between global currencies
  and regional currencies supported by different exchanges even if the currency
  name is equal.
* Merchants should be able to accept regional and global currencies based on the
  supported exchange list.

Proposed Solution
=================

Users usually do not want to see and verify the auditor/exchange URL for their
digital cash.  The wallet thus needs to support some form of "scope" for
currencies that indicates the trust anchor for particular amounts and balances.

The scope of a balance/amount gives the user additional information about the
meaning and trust anchor of a balance/amount. The scope is always local and
contextual to the wallet.  Depending on the configuration, the wallet can show
different scope information for the exact same coins.

A balance is in exactly one of three scopes:

1. Global. An amount in the global scope is by default displayed without
   any additional qualification on the currency.
2. Exchange-scoped.  An exchange-scoped amount is always displayed with the
   prettified base URL of the exchange.
3. Auditor-scoped. An auditor-scoped amount is always displayed with the
   prettified base URL of the auditor.  When multiple auditors are applicable,
   either the one with the lexically smallest base URL is chosen, or the
   one that the user/wallet has configured as the prefered one for the currency.

Whenever the wallet reports an amount, scope information should be
present in the same message with the following format:

.. code:: TypeScript

   type ScopeInfo =
     | { kind: "global" }
     | { kind: "exchange", baseUrl: string }
     | { kind: "auditor", baseUrl: string };

Prettified base URLs
^^^^^^^^^^^^^^^^^^^^

The base URLs should be rendered without the ``https://`` and without
trailing slashes:

* ``https://exchange.demo.taler.net/`` would be rendered as
  ``exchange.demo.taler.net``.

* ``http://ex1.demo.taler.net/`` would be rendered as
  ``http://ex1.demo.taler.net``.

* ``https://ex2.demo.taler.net/foo/bar/`` would be rendered as
  ``ex2.demo.taler.net/foo/bar``.


Currency Scope Info in the Wallet
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

For each configured currency code, the wallet should store following information:

* List of global-scope exchanges and currencies for the currency.  When this is an empty list,
  the currency will always be shown with exchange/auditor scope info.

Examples
^^^^^^^^

The following example shows how a wallet would render balances with
global-scope EUR (i.e. a user would expect these to be "official" EUR that can
be used with multiple vendors in Europe), two exchange-scoped MANA balances and
one auditor-scoped MANA balance.

.. code:: none

  Balances:

  1.5 EUR

  3 MANA ([exchange-icon] exchange.leipzig.ccc.de)
  3.3 MANA ([exchange-icon] exchange.berlin.ccc.de)
  5 MANA ([auditor-icon] auditor.ccc.it]

Scope information in requests for payments
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

In wallet-to-merchant payments, the merchant specifies which exchanges and
auditors the merchant accepts.  It is desirable that the wallet renders the
scope information for a requested amount in a similar way that a balance amount
would be rendered.

The amount should always be shown in the scope that is compatible with the
merchant and that the wallet holds the highest amount in.

Let's say a wallet has "auditor.ccc.it" as the global-scope auditor for MANA and holds
mana audited by this auditor. A merchant accepts MANA from this auditor as well
as from the exchange "mana.my-hackerspace.it".

A payment request could then be rendered like this:

.. code:: none

  Summary: Club Mate (5x)
  Amount: MANA:50


If a wallet (by a non-Italian hacker) would not have "auditor.ccc.it" as the
global-scope auditor for MANA, it would show as:

.. code:: none

  Summary: Cart #123 at Foomerchant
  Amount: MANA:123 ([auditor-icon] auditor.ccc.it)

  Other currencies supported by the merchant:
  [exchange-icon] mana.my-hackerspace.it

The last part should probably be hidden by default.  There might be nicer ways to render
this, such as some hoverable (?) icon after the amount that shows details about what currencies the merchant
accepts.

Wallet-core API for scope management
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

* ``listGlobalCurrencyExchanges`` lists all ``(currency, exchangeUrl, exchangePub)`` triples
  where funds are considered to be in global scope (i.e. non-regional).
* ``listGlobalCurrencyAuditors`` lists all ``(currency, auditorUrl, auditorPub)`` triples
  where funds are considered to be in global scope (i.e. non-regional).
* ``addGlobalCurrencyExchange`` and ``removeGlobalCurrencyExchange`` adds/removes a ``(currency, exchangeUrl, exchangePub)``
* ``addGlobalCurrencyAuditor`` and ``removeGlobalCurrencyAuditor`` adds/removes a ``(currency, auditorUrl, auditorPub)``


Implementation Breakdown
^^^^^^^^^^^^^^^^^^^^^^^^

* we need test currencies in each scope
* wallet-core needs to add scope information to balances response
  and various other requests
* the UI needs to render those
* wallet-core needs to expose new requests to manage currency information
* the UI needs to allow the user to manage currency information


Alternatives
============

* Completely distinguish regional currencies (non-three-letter currency code) and official currencies 
  (three letter ISO currency code).  This does not help with overlapping regional currency names,
  we can't expect them to be unique.

Drawbacks
=========

* API and UI changes are required, but they can be made in an incremental and
  backwards-compatible manner.
* Scope information could be attached to the currency code.
  That's a bad idea, because the scope information is totally local to the wallet.

Discussion / Q&A
================

* Should we allow users to customize how scopes are displayed (e.g. an alias
  instead of the full prettified base URL?)
* Do we still need the auditor/exchange URLs with this proposal?
* How does this affect the insufficient balance details?  Should we also take scopes
  into account here?