taler-docs

Documentation for GNU Taler components, APIs and protocols
Log | Files | Refs | README | LICENSE

get-balances.rst (5754B)


      1 .. ts:op:: getBalances
      2   :read-only:
      3 
      4   Get current wallet balance.
      5 
      6   Balances are reported per *scope* (`ScopeInfo`): funds held globally
      7   for a currency, at a particular exchange, under a particular auditor
      8   or under a superseded exchange master key are reported as separate
      9   balances.
     10 
     11   **Request:**
     12 
     13   This operation takes no arguments (an empty object).
     14 
     15   **Response:**
     16 
     17   On success, the result is a `BalancesResponse` object.
     18 
     19   **Details:**
     20 
     21   Each balance distinguishes three amounts.  ``available`` is the
     22   balance available for spending from transactions in their final state,
     23   plus amounts expected to become available from pending refreshes.
     24   ``pendingIncoming`` is the expected positive delta to the available
     25   balance once pending operations (such as withdrawals or incoming peer
     26   payments) reach the "done" state.  ``pendingOutgoing`` is the amount
     27   currently allocated to spend operations that could still be aborted,
     28   in which case part of the amount may be recovered.
     29 
     30 .. ts:def:: BalancesResponse
     31 
     32   interface BalancesResponse {
     33     // Electronic cash balances, per currency scope.
     34     balances: WalletBalance[];
     35 
     36     // Does the user have money from an exchange other than demo or test?
     37     haveProdBalance: boolean;
     38 
     39     // Summary of donations, per donau/year/currency.
     40     donauSummary?: DonauSummaryItem[];
     41   }
     42 
     43 .. ts:def:: WalletBalance
     44 
     45   interface WalletBalance {
     46     // DD71 expiry information and conditional
     47     // cost of keeping this balance.
     48     refreshInfo?: WalletRefreshInfo;
     49 
     50     // Scope of the funds covered by this balance.
     51     scopeInfo: ScopeInfo;
     52 
     53     // Balance available for spending, including amounts
     54     // expected from pending refreshes.
     55     available: AmountString;
     56 
     57     // Expected positive delta to the available balance
     58     // from pending operations.
     59     pendingIncoming: AmountString;
     60 
     61     // Amount allocated to spend operations that could still be aborted.
     62     pendingOutgoing: AmountString;
     63 
     64     // Pending KYC or confirmation steps affecting this balance.
     65     flags: BalanceFlag[];
     66 
     67     // Available URLs for pages that list
     68     // where money in this scope can be spent.
     69     shoppingUrls?: string[];
     70 
     71     // Are p2p payments disabled for this scope?
     72     disablePeerPayments?: boolean;
     73 
     74     // Are wallet deposits disabled for this scope?
     75     disableDirectDeposits?: boolean;
     76   }
     77 
     78 .. ts:def:: WalletRefreshInfo
     79 
     80   interface WalletRefreshInfo {
     81     risks: CashExpirationRisk[];
     82     recoveries: CashRenewalNotice[];
     83     annualCostBound: AnnualRefreshCostBound;
     84   }
     85 
     86 .. ts:def:: CashExpirationRisk
     87 
     88   interface CashExpirationRisk {
     89     exchangeBaseUrl: string;
     90     exchangeMasterPub: string;
     91     amount: AmountString;
     92     earliestDepositExpiration: TalerProtocolTimestamp;
     93     reason:
     94       | "pending"
     95       | "connectivity"
     96       | "exchange-error"
     97       | "no-replacement"
     98       | "checking"
     99       | "invalid-lifetime";
    100   }
    101 
    102 .. ts:def:: CashRenewalNotice
    103 
    104   interface CashRenewalNotice {
    105     warningId: string;
    106     exchangeBaseUrl: string;
    107     exchangeMasterPub: string;
    108     amount: AmountString;
    109     oldDepositExpiration: TalerProtocolTimestamp;
    110     newDepositExpiration: TalerProtocolTimestamp;
    111     // Earliest emergency threshold of the renewed coins.
    112     nextRelevantDate: TalerProtocolTimestamp;
    113   }
    114 
    115 .. ts:def:: AnnualRefreshCostBound
    116 
    117   // Conditional on stable, continuously available compatible
    118   // offerings and timely reveal.
    119   type AnnualRefreshCostBound = {
    120     horizonDays: 365;
    121     projection: "stable-current-offerings";
    122   } & (
    123     | {
    124         status: "available";
    125         amount: AmountString;
    126       }
    127     | {
    128         status: "unavailable";
    129         reasons: string[];
    130       }
    131   );
    132 
    133 .. ts:def:: ScopeInfo
    134 
    135   // Scope of a balance; identifies the trust domain
    136   // the funds belong to.
    137   type ScopeInfo =
    138     | ScopeInfoGlobal
    139     | ScopeInfoExchange
    140     | ScopeInfoAuditor
    141     | ScopeInfoExchangeLegacyKeys;
    142 
    143 .. ts:def:: ScopeInfoGlobal
    144 
    145   // Funds held with an exchange that is globally
    146   // trusted for the currency.
    147   type ScopeInfoGlobal = {
    148     type: "global";
    149     currency: string;
    150   };
    151 
    152 .. ts:def:: ScopeInfoExchange
    153 
    154   // Funds held at one particular exchange.
    155   type ScopeInfoExchange = {
    156     type: "exchange";
    157     currency: string;
    158     url: string;
    159   };
    160 
    161 .. ts:def:: ScopeInfoAuditor
    162 
    163   // Funds whose denominations are audited by a globally
    164   // trusted auditor.
    165   type ScopeInfoAuditor = {
    166     type: "auditor";
    167     currency: string;
    168     url: string;
    169   };
    170 
    171 .. ts:def:: ScopeInfoExchangeLegacyKeys
    172 
    173   // Funds issued under a master public key that the exchange has
    174   // since replaced; never pooled with funds under the current key.
    175   type ScopeInfoExchangeLegacyKeys = {
    176     type: "exchange-legacy-keys";
    177     currency: string;
    178     url: string;
    179     // The superseded key the funds were issued under.
    180     masterPub: string;
    181   };
    182 
    183 .. ts:def:: BalanceFlag
    184 
    185   // Flag marking a pending KYC, AML or confirmation step for
    186   // the incoming or outgoing funds of a balance.
    187   type BalanceFlag =
    188     | "incoming-kyc"
    189     | "incoming-aml"
    190     | "incoming-confirmation"
    191     | "outgoing-kyc";
    192 
    193 .. ts:def:: DonauSummaryItem
    194 
    195   interface DonauSummaryItem {
    196     // Base URL of the donau service.
    197     donauBaseUrl: string;
    198 
    199     // Legal domain of the donau service (if available).
    200     legalDomain?: string;
    201 
    202     // Year of the donation(s).
    203     year: number;
    204 
    205     // Sum of donation receipts received from merchants
    206     // in the applicable year.
    207     amountReceiptsAvailable: AmountString;
    208 
    209     // Sum of donation receipts already submitted to the
    210     // donau in the applicable year.
    211     amountReceiptsSubmitted: AmountString;
    212 
    213     // Amount of the latest available statement.  Missing
    214     // if no statement was requested yet.
    215     amountStatement?: AmountString;
    216   }