Wallet-Core API Documentation

Contents

1.5. Wallet-Core API Documentation#

This file is auto-generated from wallet-core.

1.5.1. Overview#

1.5.1.1. Initialization#

1.5.1.2. Basic Wallet Information#

1.5.1.3. Managing Transactions#

1.5.1.4. Withdrawals#

1.5.1.5. Merchant Payments#

1.5.1.6. Global Currency management#

1.5.1.7. Exchange Management#

1.5.1.8. Deposits#

1.5.1.9. Backups#

1.5.1.10. Peer Payments#

1.5.1.11. Data Validation#

1.5.1.12. Database Management#

1.5.1.13. Testing and Debugging#

1.5.2. Operation Reference#

1.5.2.1. InitWalletOp#

/**
 * Initialize wallet-core.
 *
 * Must be the first request made to wallet-core.
 */
export type InitWalletOp = {
  op: WalletApiOperation.InitWallet;
  request: InitRequest;
  response: InitResponse;
};
// InitWallet = "initWallet"

1.5.2.2. ShutdownOp#

export type ShutdownOp = {
  op: WalletApiOperation.Shutdown;
  request: EmptyObject;
  response: EmptyObject;
};
// Shutdown = "shutdown"

1.5.2.3. HintApplicationResumedOp#

/**
 * Give wallet-core a kick and restart all pending tasks.
 * Useful when the host application gets suspended and resumed,
 * and active network requests might have stalled.
 */
export type HintApplicationResumedOp = {
  op: WalletApiOperation.HintApplicationResumed;
  request: EmptyObject;
  response: EmptyObject;
};
// HintApplicationResumed = "hintApplicationResumed"

1.5.2.4. SetWalletRunConfigOp#

/**
 * Change the configuration of wallet-core.
 *
 * Currently an alias for the initWallet request.
 */
export type SetWalletRunConfigOp = {
  op: WalletApiOperation.SetWalletRunConfig;
  request: InitRequest;
  response: InitResponse;
};
// SetWalletRunConfig = "setWalletRunConfig"

1.5.2.5. GetVersionOp#

export type GetVersionOp = {
  op: WalletApiOperation.GetVersion;
  request: EmptyObject;
  response: WalletCoreVersion;
};
// GetVersion = "getVersion"

1.5.2.6. HintNetworkAvailabilityOp#

export type HintNetworkAvailabilityOp = {
  op: WalletApiOperation.HintNetworkAvailability;
  request: HintNetworkAvailabilityRequest;
  response: EmptyObject;
};
// HintNetworkAvailability = "hintNetworkAvailability"

export interface HintNetworkAvailabilityRequest {
  isNetworkAvailable: boolean;
}

1.5.2.7. GetBalancesOp#

/**
 * Get current wallet balance.
 */
export type GetBalancesOp = {
  op: WalletApiOperation.GetBalances;
  request: EmptyObject;
  response: BalancesResponse;
};
// GetBalances = "getBalances"

export interface BalancesResponse {
  balances: WalletBalance[];
}

export interface WalletBalance {
  scopeInfo: ScopeInfo;
  available: AmountString;
  pendingIncoming: AmountString;
  pendingOutgoing: AmountString;
  /**
   * Does the balance for this currency have a pending
   * transaction?
   *
   * @deprecated use flags and pendingIncoming/pendingOutgoing instead
   */
  hasPendingTransactions: boolean;
  /**
   * Is there a transaction that requires user input?
   *
   * @deprecated use flags instead
   */
  requiresUserInput: boolean;
  flags: BalanceFlag[];
}

export declare enum BalanceFlag {
  IncomingKyc = "incoming-kyc",
  IncomingAml = "incoming-aml",
  IncomingConfirmation = "incoming-confirmation",
  OutgoingKyc = "outgoing-kyc",
}

1.5.2.8. GetBalancesDetailOp#

export type GetBalancesDetailOp = {
  op: WalletApiOperation.GetBalanceDetail;
  request: GetBalanceDetailRequest;
  response: PaymentBalanceDetails;
};
// GetBalanceDetail = "getBalanceDetail"

export interface GetBalanceDetailRequest {
  currency: string;
}

export interface PaymentBalanceDetails {
  /**
   * Balance of type "available" (see balance.ts for definition).
   */
  balanceAvailable: AmountJson;
  /**
   * Balance of type "material" (see balance.ts for definition).
   */
  balanceMaterial: AmountJson;
  /**
   * Balance of type "age-acceptable" (see balance.ts for definition).
   */
  balanceAgeAcceptable: AmountJson;
  /**
   * Balance of type "receiver-acceptable" (see balance.ts for definition).
   */
  balanceReceiverAcceptable: AmountJson;
  /**
   * Balance of type "receiver-depositable" (see balance.ts for definition).
   */
  balanceReceiverDepositable: AmountJson;
  /**
   * Balance that's depositable with the exchange.
   * This balance is reduced by the exchange's debit restrictions
   * and wire fee configuration.
   */
  balanceExchangeDepositable: AmountJson;
  /**
   * Estimated maximum amount that the wallet could pay for, under the assumption
   * that the merchant pays absolutely no fees.
   */
  maxMerchantEffectiveDepositAmount: AmountJson;
}

/**
 * Non-negative financial amount.  Fractional values are expressed as multiples
 * of 1e-8.
 */
export interface AmountJson {
  /**
   * Value, must be an integer.
   */
  readonly value: number;
  /**
   * Fraction, must be an integer.  Represent 1/1e8 of a unit.
   */
  readonly fraction: number;
  /**
   * Currency of the amount.
   */
  readonly currency: string;
}

1.5.2.9. ConvertDepositAmountOp#

export type ConvertDepositAmountOp = {
  op: WalletApiOperation.ConvertDepositAmount;
  request: ConvertAmountRequest;
  response: AmountResponse;
};
// ConvertDepositAmount = "convertDepositAmount"

export interface ConvertAmountRequest {
  amount: AmountString;
  type: TransactionAmountMode;
  depositPaytoUri: PaytoString;
}

/**
 * How the amount should be interpreted in a transaction
 * Effective = how the balance is change
 * Raw = effective amount without fee
 *
 * Depending on the transaction, raw can be higher than effective
 */
export declare enum TransactionAmountMode {
  Effective = "effective",
  Raw = "raw",
}

export interface AmountResponse {
  effectiveAmount: AmountString;
  rawAmount: AmountString;
}

1.5.2.10. GetMaxDepositAmountOp#

export type GetMaxDepositAmountOp = {
  op: WalletApiOperation.GetMaxDepositAmount;
  request: GetMaxDepositAmountRequest;
  response: GetMaxDepositAmountResponse;
};
// GetMaxDepositAmount = "getMaxDepositAmount"

export interface GetMaxDepositAmountRequest {
  /**
   * Currency to deposit.
   */
  currency: string;
  /**
   * Target bank account to deposit into.
   */
  depositPaytoUri?: string;
  /**
   * Restrict the deposit to a certain scope.
   */
  restrictScope?: ScopeInfo;
}

export interface GetMaxDepositAmountResponse {
  effectiveAmount: AmountString;
  rawAmount: AmountString;
  /**
   * Account restrictions that affect the max deposit amount.
   */
  depositRestrictions?: {
    [exchangeBaseUrl: string]: {
      [paytoUri: string]: AccountRestriction[];
    };
  };
}

1.5.2.11. GetMaxPeerPushDebitAmountOp#

export type GetMaxPeerPushDebitAmountOp = {
  op: WalletApiOperation.GetMaxPeerPushDebitAmount;
  request: GetMaxPeerPushDebitAmountRequest;
  response: GetMaxPeerPushDebitAmountResponse;
};
// GetMaxPeerPushDebitAmount = "getMaxPeerPushDebitAmount"

export interface GetMaxPeerPushDebitAmountRequest {
  currency: string;
  /**
   * Preferred exchange to use for the p2p payment.
   */
  exchangeBaseUrl?: string;
  restrictScope?: ScopeInfo;
}

export interface GetMaxPeerPushDebitAmountResponse {
  effectiveAmount: AmountString;
  rawAmount: AmountString;
  exchangeBaseUrl?: string;
}

1.5.2.12. GetTransactionsOp#

/**
 * Get transactions.
 */
export type GetTransactionsOp = {
  op: WalletApiOperation.GetTransactions;
  request: TransactionsRequest;
  response: TransactionsResponse;
};
// GetTransactions = "getTransactions"

export interface TransactionsRequest {
  /**
   * return only transactions in the given currency
   *
   * it will be removed in next release
   *
   * @deprecated use scopeInfo
   */
  currency?: string;
  /**
   * return only transactions in the given scopeInfo
   */
  scopeInfo?: ScopeInfo;
  /**
   * if present, results will be limited to transactions related to the given search string
   */
  search?: string;
  /**
   * Sort order of the transaction items.
   * By default, items are sorted ascending by their
   * main timestamp.
   *
   * ascending: ascending by timestamp, but pending transactions first
   * descending: ascending by timestamp, but pending transactions first
   * stable-ascending: ascending by timestamp, with pending transactions amidst other transactions
   *    (stable in the sense of: pending transactions don't jump around)
   */
  sort?: "ascending" | "descending" | "stable-ascending";
  /**
   * If true, include all refreshes in the transactions list.
   */
  includeRefreshes?: boolean;
  filterByState?: TransactionStateFilter;
}

1.5.2.13. GetTransactionsV2Op#

export type GetTransactionsV2Op = {
  op: WalletApiOperation.GetTransactionsV2;
  request: GetTransactionsV2Request;
  response: TransactionsResponse;
};
// GetTransactionsV2 = "getTransactionsV2"

export interface GetTransactionsV2Request {
  /**
   * Return only transactions in the given currency.
   */
  currency?: string;
  /**
   * Return only transactions in the given scopeInfo
   */
  scopeInfo?: ScopeInfo;
  /**
   * If true, include all refreshes in the transactions list.
   */
  includeRefreshes?: boolean;
  /**
   * Only return transactions before/after this offset.
   */
  offsetTransactionId?: TransactionIdStr;
  /**
   * Only return transactions before/after the transaction with this
   * timestamp.
   *
   * Used as a fallback if the offsetTransactionId was deleted.
   */
  offsetTimestamp?: TalerPreciseTimestamp;
  /**
   * Number of transactions to return.
   *
   * When the limit is positive, results are returned
   * in ascending order of their timestamp.  If no offset is specified,
   * the result list begins with the first transaction.
   * If an offset is specified, transactions after the offset are returned.
   *
   * When the limit is negative, results are returned
   * in descending order of their timestamp.  If no offset is specified,
   * the result list begins with with the last transaction.
   * If an offset is specified, transactions before the offset are returned.
   */
  limit?: number;
  /**
   * Filter transactions by their state / state category.
   *
   * If not specified, all transactions are returned.
   */
  filterByState?: "final" | "nonfinal" | "done";
}

1.5.2.14. ListAssociatedRefreshesOp#

/**
 * List refresh transactions associated with another transaction.
 */
export type ListAssociatedRefreshesOp = {
  op: WalletApiOperation.ListAssociatedRefreshes;
  request: ListAssociatedRefreshesRequest;
  response: ListAssociatedRefreshesResponse;
};
// ListAssociatedRefreshes = "listAssociatedRefreshes"

export interface ListAssociatedRefreshesRequest {
  transactionId: string;
}

export interface ListAssociatedRefreshesResponse {
  transactionIds: string[];
}

1.5.2.15. TestingGetSampleTransactionsOp#

/**
 * Get sample transactions.
 */
export type TestingGetSampleTransactionsOp = {
  op: WalletApiOperation.TestingGetSampleTransactions;
  request: EmptyObject;
  response: TransactionsResponse;
};
// TestingGetSampleTransactions = "testingGetSampleTransactions"

1.5.2.16. GetTransactionByIdOp#

export type GetTransactionByIdOp = {
  op: WalletApiOperation.GetTransactionById;
  request: TransactionByIdRequest;
  response: Transaction;
};
// GetTransactionById = "getTransactionById"

export interface TransactionByIdRequest {
  transactionId: string;
  /**
   * If set to true, report the full contract terms in the response
   * if the transaction has them.
   */
  includeContractTerms?: boolean;
}

1.5.2.17. RetryPendingNowOp#

export type RetryPendingNowOp = {
  op: WalletApiOperation.RetryPendingNow;
  request: EmptyObject;
  response: EmptyObject;
};
// RetryPendingNow = "retryPendingNow"

1.5.2.18. DeleteTransactionOp#

/**
 * Delete a transaction locally in the wallet.
 */
export type DeleteTransactionOp = {
  op: WalletApiOperation.DeleteTransaction;
  request: DeleteTransactionRequest;
  response: EmptyObject;
};
// DeleteTransaction = "deleteTransaction"

export interface DeleteTransactionRequest {
  transactionId: TransactionIdStr;
}

1.5.2.19. RetryTransactionOp#

/**
 * Immediately retry a transaction.
 */
export type RetryTransactionOp = {
  op: WalletApiOperation.RetryTransaction;
  request: RetryTransactionRequest;
  response: EmptyObject;
};
// RetryTransaction = "retryTransaction"

export interface RetryTransactionRequest {
  transactionId: TransactionIdStr;
}

1.5.2.20. AbortTransactionOp#

/**
 * Abort a transaction
 *
 * For payment transactions, it puts the payment into an "aborting" state.
 */
export type AbortTransactionOp = {
  op: WalletApiOperation.AbortTransaction;
  request: AbortTransactionRequest;
  response: EmptyObject;
};
// AbortTransaction = "abortTransaction"

1.5.2.21. FailTransactionOp#

/**
 * Cancel aborting a transaction
 *
 * For payment transactions, it puts the payment into an "aborting" state.
 */
export type FailTransactionOp = {
  op: WalletApiOperation.FailTransaction;
  request: FailTransactionRequest;
  response: EmptyObject;
};
// FailTransaction = "failTransaction"

export interface FailTransactionRequest {
  transactionId: TransactionIdStr;
}

1.5.2.22. SuspendTransactionOp#

/**
 * Suspend a transaction
 */
export type SuspendTransactionOp = {
  op: WalletApiOperation.SuspendTransaction;
  request: AbortTransactionRequest;
  response: EmptyObject;
};
// SuspendTransaction = "suspendTransaction"

1.5.2.23. ResumeTransactionOp#

/**
 * Resume a transaction
 */
export type ResumeTransactionOp = {
  op: WalletApiOperation.ResumeTransaction;
  request: AbortTransactionRequest;
  response: EmptyObject;
};
// ResumeTransaction = "resumeTransaction"

1.5.2.24. GetWithdrawalDetailsForAmountOp#

/**
 * Get details for withdrawing a particular amount (manual withdrawal).
 */
export type GetWithdrawalDetailsForAmountOp = {
  op: WalletApiOperation.GetWithdrawalDetailsForAmount;
  request: GetWithdrawalDetailsForAmountRequest;
  response: WithdrawalDetailsForAmount;
};
// GetWithdrawalDetailsForAmount = "getWithdrawalDetailsForAmount"

export interface GetWithdrawalDetailsForAmountRequest {
  exchangeBaseUrl?: string;
  /**
   * Specify currency scope for the withdrawal.
   *
   * May only be used when exchangeBaseUrl is not specified.
   */
  restrictScope?: ScopeInfo;
  amount: AmountString;
  restrictAge?: number;
  /**
   * ID provided by the client to cancel the request.
   *
   * If the same request is made again with the same clientCancellationId,
   * all previous requests are cancelled.
   *
   * The cancelled request will receive an error response with
   * an error code that indicates the cancellation.
   *
   * The cancellation is best-effort, responses might still arrive.
   */
  clientCancellationId?: string;
}

export interface WithdrawalDetailsForAmount {
  /**
   * Exchange base URL for the withdrawal.
   */
  exchangeBaseUrl: string;
  /**
   * Amount that the user will transfer to the exchange.
   */
  amountRaw: AmountString;
  /**
   * Amount that will be added to the user's wallet balance.
   */
  amountEffective: AmountString;
  /**
   * Number of coins that would be used for withdrawal.
   *
   * The UIs should warn if this number is too high (roughly at >100).
   */
  numCoins: number;
  /**
   * Ways to pay the exchange, including accounts that require currency conversion.
   */
  withdrawalAccountsList: WithdrawalExchangeAccountDetails[];
  /**
   * If the exchange supports age-restricted coins it will return
   * the array of ages.
   */
  ageRestrictionOptions?: number[];
  /**
   * Scope info of the currency withdrawn.
   */
  scopeInfo: ScopeInfo;
  /**
   * KYC soft limit.
   *
   * Withdrawals over that amount will require KYC.
   */
  kycSoftLimit?: AmountString;
  /**
   * KYC soft limits.
   *
   * Withdrawals over that amount will be denied.
   */
  kycHardLimit?: AmountString;
  /**
   * Ways to pay the exchange.
   *
   * @deprecated in favor of withdrawalAccountsList
   */
  paytoUris: string[];
  /**
   * Did the user accept the current version of the exchange's
   * terms of service?
   *
   * @deprecated the client should query the exchange entry instead
   */
  tosAccepted: boolean;
}

1.5.2.25. GetWithdrawalDetailsForUriOp#

/**
 * Get details for withdrawing via a particular taler:// URI.
 */
export type GetWithdrawalDetailsForUriOp = {
  op: WalletApiOperation.GetWithdrawalDetailsForUri;
  request: GetWithdrawalDetailsForUriRequest;
  response: WithdrawUriInfoResponse;
};
// GetWithdrawalDetailsForUri = "getWithdrawalDetailsForUri"

export interface GetWithdrawalDetailsForUriRequest {
  talerWithdrawUri: string;
  /**
   * @deprecated not used
   */
  restrictAge?: number;
}

1.5.2.26. PrepareBankIntegratedWithdrawalOp#

/**
 * Prepare a bank-integrated withdrawal operation.
 */
export type PrepareBankIntegratedWithdrawalOp = {
  op: WalletApiOperation.PrepareBankIntegratedWithdrawal;
  request: PrepareBankIntegratedWithdrawalRequest;
  response: PrepareBankIntegratedWithdrawalResponse;
};
// PrepareBankIntegratedWithdrawal = "prepareBankIntegratedWithdrawal"

export interface PrepareBankIntegratedWithdrawalRequest {
  talerWithdrawUri: string;
}

export interface PrepareBankIntegratedWithdrawalResponse {
  transactionId: TransactionIdStr;
  info: WithdrawUriInfoResponse;
}

1.5.2.27. ConfirmWithdrawalOp#

/**
 * Confirm a withdrawal transaction.
 */
export type ConfirmWithdrawalOp = {
  op: WalletApiOperation.ConfirmWithdrawal;
  request: ConfirmWithdrawalRequest;
  response: AcceptWithdrawalResponse;
};
// ConfirmWithdrawal = "confirmWithdrawal"

export interface ConfirmWithdrawalRequest {
  transactionId: string;
  exchangeBaseUrl: string;
  amount: AmountString | undefined;
  forcedDenomSel?: ForcedDenomSel;
  restrictAge?: number;
}

1.5.2.28. AcceptBankIntegratedWithdrawalOp#

/**
 * Accept a bank-integrated withdrawal.
 *
 * @deprecated in favor of prepare/confirm withdrawal.
 */
export type AcceptBankIntegratedWithdrawalOp = {
  op: WalletApiOperation.AcceptBankIntegratedWithdrawal;
  request: AcceptBankIntegratedWithdrawalRequest;
  response: AcceptWithdrawalResponse;
};
// AcceptBankIntegratedWithdrawal = "acceptBankIntegratedWithdrawal"

export interface AcceptBankIntegratedWithdrawalRequest {
  talerWithdrawUri: string;
  exchangeBaseUrl: string;
  forcedDenomSel?: ForcedDenomSel;
  /**
   * Amount to withdraw.
   * If the bank's withdrawal operation uses a fixed amount,
   * this field must either be left undefined or its value must match
   * the amount from the withdrawal operation.
   */
  amount?: AmountString;
  restrictAge?: number;
}

1.5.2.29. AcceptManualWithdrawalOp#

/**
 * Create a manual withdrawal.
 */
export type AcceptManualWithdrawalOp = {
  op: WalletApiOperation.AcceptManualWithdrawal;
  request: AcceptManualWithdrawalRequest;
  response: AcceptManualWithdrawalResult;
};
// AcceptManualWithdrawal = "acceptManualWithdrawal"

export interface AcceptManualWithdrawalRequest {
  exchangeBaseUrl: string;
  amount: AmountString;
  restrictAge?: number;
  /**
   * Instead of generating a fresh, random reserve key pair,
   * use the provided reserve private key.
   *
   * Use with caution.  Usage of this field may be restricted
   * to developer mode.
   */
  forceReservePriv?: EddsaPrivateKeyString;
}

export interface AcceptManualWithdrawalResult {
  /**
   * Payto URIs that can be used to fund the withdrawal.
   *
   * @deprecated in favor of withdrawalAccountsList
   */
  exchangePaytoUris: string[];
  /**
   * Public key of the newly created reserve.
   */
  reservePub: string;
  withdrawalAccountsList: WithdrawalExchangeAccountDetails[];
  transactionId: TransactionIdStr;
}

1.5.2.30. PreparePayForUriOp#

/**
 * Prepare to make a payment based on a taler://pay/ URI.
 */
export type PreparePayForUriOp = {
  op: WalletApiOperation.PreparePayForUri;
  request: PreparePayRequest;
  response: PreparePayResult;
};
// PreparePayForUri = "preparePayForUri"

export interface PreparePayRequest {
  talerPayUri: string;
}

1.5.2.31. SharePaymentOp#

export type SharePaymentOp = {
  op: WalletApiOperation.SharePayment;
  request: SharePaymentRequest;
  response: SharePaymentResult;
};
// SharePayment = "sharePayment"

export interface SharePaymentRequest {
  merchantBaseUrl: string;
  orderId: string;
}

export interface SharePaymentResult {
  privatePayUri: string;
}

1.5.2.32. CheckPayForTemplateOp#

export type CheckPayForTemplateOp = {
  op: WalletApiOperation.CheckPayForTemplate;
  request: CheckPayTemplateRequest;
  response: CheckPayTemplateReponse;
};
// CheckPayForTemplate = "checkPayForTemplate"

export interface CheckPayTemplateRequest {
  talerPayTemplateUri: string;
}

export type CheckPayTemplateReponse = {
  templateDetails: TalerMerchantApi.WalletTemplateDetails;
  supportedCurrencies: string[];
};

export interface WalletTemplateDetails {
  template_contract: TemplateContractDetails;
  editable_defaults?: TemplateContractDetailsDefaults;
}

export interface TemplateContractDetails {
  summary?: string;
  currency?: string;
  amount?: AmountString;
  minimum_age: Integer;
  pay_duration: RelativeTime;
}

export interface TemplateContractDetailsDefaults {
  summary?: string;
  currency?: string;
  /**
   * Amount *or* a plain currency string.
   */
  amount?: string;
}

1.5.2.33. PreparePayForTemplateOp#

/**
 * Prepare to make a payment based on a taler://pay-template/ URI.
 */
export type PreparePayForTemplateOp = {
  op: WalletApiOperation.PreparePayForTemplate;
  request: PreparePayTemplateRequest;
  response: PreparePayResult;
};
// PreparePayForTemplate = "preparePayForTemplate"

export interface PreparePayTemplateRequest {
  talerPayTemplateUri: string;
  templateParams?: TemplateParams;
}

export type TemplateParams = {
  amount?: string;
  summary?: string;
};

1.5.2.34. GetContractTermsDetailsOp#

export type GetContractTermsDetailsOp = {
  op: WalletApiOperation.GetContractTermsDetails;
  request: GetContractTermsDetailsRequest;
  response: WalletContractData;
};
// GetContractTermsDetails = "getContractTermsDetails"

export interface GetContractTermsDetailsRequest {
  transactionId: string;
}

/**
 * Data extracted from the contract terms that is relevant for payment
 * processing in the wallet.
 */
export interface WalletContractData {
  /**
   * Fulfillment URL, or the empty string if the order has no fulfillment URL.
   *
   * Stored as a non-nullable string as we use this field for IndexedDB indexing.
   */
  fulfillmentUrl: string;
  contractTermsHash: string;
  fulfillmentMessage?: string;
  fulfillmentMessageI18n?: InternationalizedString;
  merchantSig: string;
  merchantPub: string;
  merchant: MerchantInfo;
  amount: AmountString;
  orderId: string;
  merchantBaseUrl: string;
  summary: string;
  summaryI18n:
    | {
        [lang_tag: string]: string;
      }
    | undefined;
  autoRefund: TalerProtocolDuration | undefined;
  payDeadline: TalerProtocolTimestamp;
  refundDeadline: TalerProtocolTimestamp;
  allowedExchanges: AllowedExchangeInfo[];
  timestamp: TalerProtocolTimestamp;
  wireMethod: string;
  wireInfoHash: string;
  maxDepositFee: AmountString;
  minimumAge?: number;
}

export interface AllowedExchangeInfo {
  exchangeBaseUrl: string;
  exchangePub: string;
}

1.5.2.35. ConfirmPayOp#

/**
 * Confirm a payment that was previously prepared with
 * {@link PreparePayForUriOp}
 */
export type ConfirmPayOp = {
  op: WalletApiOperation.ConfirmPay;
  request: ConfirmPayRequest;
  response: ConfirmPayResult;
};
// ConfirmPay = "confirmPay"

export interface ConfirmPayRequest {
  transactionId: TransactionIdStr;
  sessionId?: string;
  forcedCoinSel?: ForcedCoinSel;
}

export type ConfirmPayResult = ConfirmPayResultDone | ConfirmPayResultPending;

/**
 * Result for confirmPay
 */
export interface ConfirmPayResultDone {
  type: ConfirmPayResultType.Done;
  contractTerms: MerchantContractTermsV0;
  transactionId: TransactionIdStr;
}

export interface ConfirmPayResultPending {
  type: ConfirmPayResultType.Pending;
  transactionId: TransactionIdStr;
  lastError: TalerErrorDetail | undefined;
}

1.5.2.36. StartRefundQueryForUriOp#

/**
 * Check for a refund based on a taler://refund URI.
 */
export type StartRefundQueryForUriOp = {
  op: WalletApiOperation.StartRefundQueryForUri;
  request: PrepareRefundRequest;
  response: StartRefundQueryForUriResponse;
};
// StartRefundQueryForUri = "startRefundQueryForUri"

export interface PrepareRefundRequest {
  talerRefundUri: string;
}

export interface StartRefundQueryForUriResponse {
  /**
   * Transaction id of the *payment* where the refund query was started.
   */
  transactionId: TransactionIdStr;
}

1.5.2.37. StartRefundQueryOp#

export type StartRefundQueryOp = {
  op: WalletApiOperation.StartRefundQuery;
  request: StartRefundQueryRequest;
  response: EmptyObject;
};
// StartRefundQuery = "startRefundQuery"

export interface StartRefundQueryRequest {
  transactionId: TransactionIdStr;
}

1.5.2.38. ListGlobalCurrencyAuditorsOp#

export type ListGlobalCurrencyAuditorsOp = {
  op: WalletApiOperation.ListGlobalCurrencyAuditors;
  request: EmptyObject;
  response: ListGlobalCurrencyAuditorsResponse;
};
// ListGlobalCurrencyAuditors = "listGlobalCurrencyAuditors"

export interface ListGlobalCurrencyAuditorsResponse {
  auditors: {
    currency: string;
    auditorBaseUrl: string;
    auditorPub: string;
  }[];
}

1.5.2.39. ListGlobalCurrencyExchangesOp#

export type ListGlobalCurrencyExchangesOp = {
  op: WalletApiOperation.ListGlobalCurrencyExchanges;
  request: EmptyObject;
  response: ListGlobalCurrencyExchangesResponse;
};
// ListGlobalCurrencyExchanges = "listGlobalCurrencyExchanges"

export interface ListGlobalCurrencyExchangesResponse {
  exchanges: {
    currency: string;
    exchangeBaseUrl: string;
    exchangeMasterPub: string;
  }[];
}

1.5.2.40. AddGlobalCurrencyExchangeOp#

export type AddGlobalCurrencyExchangeOp = {
  op: WalletApiOperation.AddGlobalCurrencyExchange;
  request: AddGlobalCurrencyExchangeRequest;
  response: EmptyObject;
};
// AddGlobalCurrencyExchange = "addGlobalCurrencyExchange"

export interface AddGlobalCurrencyExchangeRequest {
  currency: string;
  exchangeBaseUrl: string;
  exchangeMasterPub: string;
}

1.5.2.41. AddGlobalCurrencyAuditorOp#

export type AddGlobalCurrencyAuditorOp = {
  op: WalletApiOperation.AddGlobalCurrencyAuditor;
  request: AddGlobalCurrencyAuditorRequest;
  response: EmptyObject;
};
// AddGlobalCurrencyAuditor = "addGlobalCurrencyAuditor"

export interface AddGlobalCurrencyAuditorRequest {
  currency: string;
  auditorBaseUrl: string;
  auditorPub: string;
}

1.5.2.42. RemoveGlobalCurrencyExchangeOp#

export type RemoveGlobalCurrencyExchangeOp = {
  op: WalletApiOperation.RemoveGlobalCurrencyExchange;
  request: RemoveGlobalCurrencyExchangeRequest;
  response: EmptyObject;
};
// RemoveGlobalCurrencyExchange = "removeGlobalCurrencyExchange"

export interface RemoveGlobalCurrencyExchangeRequest {
  currency: string;
  exchangeBaseUrl: string;
  exchangeMasterPub: string;
}

1.5.2.43. RemoveGlobalCurrencyAuditorOp#

export type RemoveGlobalCurrencyAuditorOp = {
  op: WalletApiOperation.RemoveGlobalCurrencyAuditor;
  request: RemoveGlobalCurrencyAuditorRequest;
  response: EmptyObject;
};
// RemoveGlobalCurrencyAuditor = "removeGlobalCurrencyAuditor"

export interface RemoveGlobalCurrencyAuditorRequest {
  currency: string;
  auditorBaseUrl: string;
  auditorPub: string;
}

1.5.2.44. ListExchangesOp#

/**
 * List exchanges known to the wallet.
 */
export type ListExchangesOp = {
  op: WalletApiOperation.ListExchanges;
  request: ListExchangesRequest;
  response: ExchangesListResponse;
};
// ListExchanges = "listExchanges"

export interface ListExchangesRequest {
  /**
   * Filter results to only include exchanges in the given scope.
   */
  filterByScope?: ScopeInfo;
  filterByExchangeEntryStatus?: ExchangeEntryStatus;
}

export interface ExchangesListResponse {
  exchanges: ExchangeListItem[];
}

1.5.2.45. StartExchangeWalletKycOp#

export type StartExchangeWalletKycOp = {
  op: WalletApiOperation.StartExchangeWalletKyc;
  request: StartExchangeWalletKycRequest;
  response: EmptyObject;
};
// StartExchangeWalletKyc = "startExchangeWalletKyc"

export interface StartExchangeWalletKycRequest {
  exchangeBaseUrl: string;
  amount: AmountString;
}

1.5.2.46. TestingWaitExchangeWalletKycOp#

export type TestingWaitExchangeWalletKycOp = {
  op: WalletApiOperation.TestingWaitExchangeWalletKyc;
  request: TestingWaitWalletKycRequest;
  response: EmptyObject;
};
// TestingWaitExchangeWalletKyc = "testingWaitWalletKyc"

export interface TestingWaitWalletKycRequest {
  exchangeBaseUrl: string;
  amount: AmountString;
  /**
   * Do we wait for the KYC to be passed (true),
   * or do we already return if legitimization is
   * required (false).
   */
  passed: boolean;
}

1.5.2.47. PrepareWithdrawExchangeOp#

/**
 * Prepare for withdrawing via a taler://withdraw-exchange URI.
 */
export type PrepareWithdrawExchangeOp = {
  op: WalletApiOperation.PrepareWithdrawExchange;
  request: PrepareWithdrawExchangeRequest;
  response: PrepareWithdrawExchangeResponse;
};
// PrepareWithdrawExchange = "prepareWithdrawExchange"

export interface PrepareWithdrawExchangeRequest {
  /**
   * A taler://withdraw-exchange URI.
   */
  talerUri: string;
}

export interface PrepareWithdrawExchangeResponse {
  /**
   * Base URL of the exchange that already existed
   * or was ephemerally added as an exchange entry to
   * the wallet.
   */
  exchangeBaseUrl: string;
  /**
   * Amount from the taler://withdraw-exchange URI.
   * Only present if specified in the URI.
   */
  amount?: AmountString;
}

1.5.2.48. AddExchangeOp#

/**
 * Add / force-update an exchange.
 */
export type AddExchangeOp = {
  op: WalletApiOperation.AddExchange;
  request: AddExchangeRequest;
  response: EmptyObject;
};
// AddExchange = "addExchange"

1.5.2.49. UpdateExchangeEntryOp#

/**
 * Update an exchange entry.
 */
export type UpdateExchangeEntryOp = {
  op: WalletApiOperation.UpdateExchangeEntry;
  request: UpdateExchangeEntryRequest;
  response: EmptyObject;
};
// UpdateExchangeEntry = "updateExchangeEntry"

export interface UpdateExchangeEntryRequest {
  exchangeBaseUrl: string;
  force?: boolean;
}

1.5.2.50. ListBankAccountsOp#

export type ListBankAccountsOp = {
  op: WalletApiOperation.ListBankAccounts;
  request: ListBankAccountsRequest;
  response: ListBankAccountsResponse;
};
// ListBankAccounts = "listBankAccounts"

export interface ListBankAccountsRequest {
  currency?: string;
}

export interface ListBankAccountsResponse {
  accounts: WalletBankAccountInfo[];
}

1.5.2.51. GetBankAccountByIdOp#

export type GetBankAccountByIdOp = {
  op: WalletApiOperation.GetBankAccountById;
  request: GetBankAccountByIdRequest;
  response: GetBankAccountByIdResponse;
};
// GetBankAccountById = "getBankAccountById"

export interface GetBankAccountByIdRequest {
  bankAccountId: string;
}

1.5.2.52. AddBankAccountsOp#

export type AddBankAccountsOp = {
  op: WalletApiOperation.AddBankAccount;
  request: AddBankAccountRequest;
  response: AddBankAccountResponse;
};
// AddBankAccount = "addBankAccount"

export interface AddBankAccountRequest {
  /**
   * Payto URI of the bank account that should be added.
   */
  paytoUri: string;
  /**
   * Human-readable label for the account.
   */
  label: string;
  /**
   * Currencies supported by the bank (if known).
   */
  currencies?: string[] | undefined;
  /**
   * Bank account that this new account should replace.
   */
  replaceBankAccountId?: string;
}

export interface AddBankAccountResponse {
  /**
   * Identifier of the added bank account.
   */
  bankAccountId: string;
}

1.5.2.53. ForgetBankAccountsOp#

export type ForgetBankAccountsOp = {
  op: WalletApiOperation.ForgetBankAccount;
  request: ForgetBankAccountRequest;
  response: EmptyObject;
};
// ForgetBankAccount = "forgetBankAccount"

export interface ForgetBankAccountRequest {
  bankAccountId: string;
}

1.5.2.54. SetExchangeTosAcceptedOp#

/**
 * Accept a particular version of the exchange terms of service.
 */
export type SetExchangeTosAcceptedOp = {
  op: WalletApiOperation.SetExchangeTosAccepted;
  request: AcceptExchangeTosRequest;
  response: EmptyObject;
};
// SetExchangeTosAccepted = "setExchangeTosAccepted"

1.5.2.55. SetExchangeTosForgottenOp#

/**
 * Accept a particular version of the exchange terms of service.
 */
export type SetExchangeTosForgottenOp = {
  op: WalletApiOperation.SetExchangeTosForgotten;
  request: AcceptExchangeTosRequest;
  response: EmptyObject;
};
// SetExchangeTosForgotten = "setExchangeTosForgotten"

1.5.2.56. GetExchangeTosOp#

/**
 * Get the current terms of a service of an exchange.
 */
export type GetExchangeTosOp = {
  op: WalletApiOperation.GetExchangeTos;
  request: GetExchangeTosRequest;
  response: GetExchangeTosResult;
};
// GetExchangeTos = "getExchangeTos"

export interface GetExchangeTosRequest {
  exchangeBaseUrl: string;
  acceptedFormat?: string[];
  acceptLanguage?: string;
}

export interface GetExchangeTosResult {
  /**
   * Markdown version of the current ToS.
   */
  content: string;
  /**
   * Version tag of the current ToS.
   */
  currentEtag: string;
  /**
   * Version tag of the last ToS that the user has accepted,
   * if any.
   */
  acceptedEtag: string | undefined;
  /**
   * Accepted content type
   */
  contentType: string;
  /**
   * Language of the returned content.
   *
   * If missing, language is unknown.
   */
  contentLanguage: string | undefined;
  /**
   * Available languages as advertised by the exchange.
   */
  tosAvailableLanguages: string[];
  tosStatus: ExchangeTosStatus;
}

1.5.2.57. GetDepositWireTypesOp#

export type GetDepositWireTypesOp = {
  op: WalletApiOperation.GetDepositWireTypes;
  request: GetDepositWireTypesRequest;
  response: GetDepositWireTypesResponse;
};
// GetDepositWireTypes = "getDepositWireTypes"

export interface GetDepositWireTypesRequest {
  currency?: string;
  /**
   * Optional scope info to further restrict the result.
   * Currency must match the currency field.
   */
  scopeInfo?: ScopeInfo;
}

export interface GetDepositWireTypesResponse {
  /**
   * Details for each wire type.
   */
  wireTypeDetails: WireTypeDetails[];
}

1.5.2.58. GetDepositWireTypesForCurrencyOp#

/**
 * Get wire types that can be used for a deposit operation
 * with the provided currency.
 *
 * @deprecated Use getDepositWireTypes instead
 */
export type GetDepositWireTypesForCurrencyOp = {
  op: WalletApiOperation.GetDepositWireTypesForCurrency;
  request: GetDepositWireTypesForCurrencyRequest;
  response: GetDepositWireTypesForCurrencyResponse;
};
// GetDepositWireTypesForCurrency = "getDepositWireTypesForCurrency"

export interface GetDepositWireTypesForCurrencyRequest {
  currency: string;
  /**
   * Optional scope info to further restrict the result.
   * Currency must match the currency field.
   */
  scopeInfo?: ScopeInfo;
}

/**
 * Response with wire types that are supported for a deposit.
 *
 * In the future, we might surface more information here, such as debit restrictions
 * by the exchange, which then can be shown by UIs to the user before they
 * enter their payment information.
 */
export interface GetDepositWireTypesForCurrencyResponse {
  /**
   * @deprecated, use wireTypeDetails instead.
   */
  wireTypes: string[];
  /**
   * Details for each wire type.
   */
  wireTypeDetails: WireTypeDetails[];
}

1.5.2.59. GetExchangeDetailedInfoOp#

/**
 * Get the current terms of a service of an exchange.
 */
export type GetExchangeDetailedInfoOp = {
  op: WalletApiOperation.GetExchangeDetailedInfo;
  request: AddExchangeRequest;
  response: ExchangeDetailedResponse;
};
// GetExchangeDetailedInfo = "getExchangeDetailedInfo"

export interface ExchangeDetailedResponse {
  exchange: ExchangeFullDetails;
}

export interface ExchangeFullDetails {
  exchangeBaseUrl: string;
  currency: string;
  paytoUris: string[];
  auditors: ExchangeAuditor[];
  wireInfo: WireInfo;
  denomFees: DenomOperationMap<FeeDescription[]>;
  transferFees: Record<string, FeeDescription[]>;
  globalFees: FeeDescription[];
}

/**
 * Auditor information as given by the exchange in /keys.
 */
export interface ExchangeAuditor {
  /**
   * Auditor's public key.
   */
  auditor_pub: string;
  /**
   * Base URL of the auditor.
   */
  auditor_url: string;
  /**
   * List of signatures for denominations by the auditor.
   */
  denomination_keys: AuditorDenomSig[];
}

/**
 * Signature by the auditor that a particular denomination key is audited.
 */
export interface AuditorDenomSig {
  /**
   * Denomination public key's hash.
   */
  denom_pub_h: string;
  /**
   * The signature.
   */
  auditor_sig: string;
}

export interface WireInfo {
  feesForType: WireFeeMap;
  accounts: ExchangeWireAccount[];
}

export type WireFeeMap = {
  [wireMethod: string]: WireFee[];
};

/**
 * Wire fee for one wire method
 */
export interface WireFee {
  /**
   * Fee for wire transfers.
   */
  wireFee: AmountString;
  /**
   * Fees to close and refund a reserve.
   */
  closingFee: AmountString;
  /**
   * Start date of the fee.
   */
  startStamp: TalerProtocolTimestamp;
  /**
   * End date of the fee.
   */
  endStamp: TalerProtocolTimestamp;
  /**
   * Signature made by the exchange master key.
   */
  sig: string;
}

export interface ExchangeWireAccount {
  payto_uri: string;
  conversion_url?: string;
  credit_restrictions: AccountRestriction[];
  debit_restrictions: AccountRestriction[];
  master_sig: EddsaSignatureString;
  bank_label?: string;
  priority?: number;
}

export type DenomOperationMap<T> = {
  [op in DenomOperation]: T;
};

export type DenomOperation = "deposit" | "withdraw" | "refresh" | "refund";

export interface FeeDescription {
  group: string;
  from: AbsoluteTime;
  until: AbsoluteTime;
  fee?: AmountString;
}

1.5.2.60. GetExchangeEntryByUrlOp#

/**
 * Get the current terms of a service of an exchange.
 */
export type GetExchangeEntryByUrlOp = {
  op: WalletApiOperation.GetExchangeEntryByUrl;
  request: GetExchangeEntryByUrlRequest;
  response: GetExchangeEntryByUrlResponse;
};
// GetExchangeEntryByUrl = "getExchangeEntryByUrl"

export interface GetExchangeEntryByUrlRequest {
  exchangeBaseUrl: string;
}

1.5.2.61. GetExchangeResourcesOp#

/**
 * Get resources associated with an exchange.
 */
export type GetExchangeResourcesOp = {
  op: WalletApiOperation.GetExchangeResources;
  request: GetExchangeResourcesRequest;
  response: GetExchangeResourcesResponse;
};
// GetExchangeResources = "getExchangeResources"

export interface GetExchangeResourcesRequest {
  exchangeBaseUrl: string;
}

export interface GetExchangeResourcesResponse {
  hasResources: boolean;
}

1.5.2.62. DeleteExchangeOp#

/**
 * Get resources associated with an exchange.
 */
export type DeleteExchangeOp = {
  op: WalletApiOperation.GetExchangeResources;
  request: DeleteExchangeRequest;
  response: EmptyObject;
};
// GetExchangeResources = "getExchangeResources"

export interface DeleteExchangeRequest {
  exchangeBaseUrl: string;
  purge?: boolean;
}

1.5.2.63. GetCurrencySpecificationOp#

export type GetCurrencySpecificationOp = {
  op: WalletApiOperation.GetCurrencySpecification;
  request: GetCurrencySpecificationRequest;
  response: GetCurrencySpecificationResponse;
};
// GetCurrencySpecification = "getCurrencySpecification"

export interface GetCurrencySpecificationRequest {
  scope: ScopeInfo;
}

export interface GetCurrencySpecificationResponse {
  currencySpecification: CurrencySpecification;
}

1.5.2.64. GenerateDepositGroupTxIdOp#

/**
 * Generate a fresh transaction ID for a deposit group.
 *
 * The resulting transaction ID can be specified when creating
 * a deposit group, so that the client can already start waiting for notifications
 * on that specific deposit group before the GreateDepositGroup request returns.
 */
export type GenerateDepositGroupTxIdOp = {
  op: WalletApiOperation.GenerateDepositGroupTxId;
  request: EmptyObject;
  response: TxIdResponse;
};
// GenerateDepositGroupTxId = "generateDepositGroupTxId"

export interface TxIdResponse {
  transactionId: TransactionIdStr;
}

1.5.2.65. CreateDepositGroupOp#

/**
 * Create a new deposit group.
 *
 * Deposit groups are used to deposit multiple coins to a bank
 * account, usually the wallet user's own bank account.
 */
export type CreateDepositGroupOp = {
  op: WalletApiOperation.CreateDepositGroup;
  request: CreateDepositGroupRequest;
  response: CreateDepositGroupResponse;
};
// CreateDepositGroup = "createDepositGroup"

export interface CreateDepositGroupRequest {
  depositPaytoUri: string;
  /**
   * Amount to deposit.
   */
  amount: AmountString;
  /**
   * Restrict the deposit to a certain scope.
   */
  restrictScope?: ScopeInfo;
  /**
   * Use a fixed merchant private key.
   */
  testingFixedPriv?: string;
  /**
   * Pre-allocated transaction ID.
   * Allows clients to easily handle notifications
   * that occur while the operation has been created but
   * before the creation request has returned.
   */
  transactionId?: TransactionIdStr;
}

export interface CreateDepositGroupResponse {
  depositGroupId: string;
  transactionId: TransactionIdStr;
}

1.5.2.66. CheckDepositOp#

export type CheckDepositOp = {
  op: WalletApiOperation.CheckDeposit;
  request: CheckDepositRequest;
  response: CheckDepositResponse;
};
// CheckDeposit = "checkDeposit"

1.5.2.67. PrepareDepositOp#

/**
 * @deprecated use CheckDepositOp instead
 */
export type PrepareDepositOp = {
  op: WalletApiOperation.PrepareDeposit;
  request: CheckDepositRequest;
  response: CheckDepositResponse;
};
// PrepareDeposit = "prepareDeposit"

1.5.2.68. ExportBackupRecoveryOp#

/**
 * Export the recovery information for the wallet.
 */
export type ExportBackupRecoveryOp = {
  op: WalletApiOperation.ExportBackupRecovery;
  request: EmptyObject;
  response: BackupRecovery;
};
// ExportBackupRecovery = "exportBackupRecovery"

1.5.2.69. ImportBackupRecoveryOp#

/**
 * Import recovery information into the wallet.
 */
export type ImportBackupRecoveryOp = {
  op: WalletApiOperation.ImportBackupRecovery;
  request: RecoveryLoadRequest;
  response: EmptyObject;
};
// ImportBackupRecovery = "importBackupRecovery"

/**
 * Load recovery information into the wallet.
 */
export interface RecoveryLoadRequest {
  recovery: BackupRecovery;
  strategy?: RecoveryMergeStrategy;
}

/**
 * Strategy for loading recovery information.
 */
export declare enum RecoveryMergeStrategy {
  /**
   * Keep the local wallet root key, import and take over providers.
   */
  Ours = "ours",
  /**
   * Migrate to the wallet root key from the recovery information.
   */
  Theirs = "theirs",
}

1.5.2.70. RunBackupCycleOp#

/**
 * Manually make and upload a backup.
 */
export type RunBackupCycleOp = {
  op: WalletApiOperation.RunBackupCycle;
  request: RunBackupCycleRequest;
  response: EmptyObject;
};
// RunBackupCycle = "runBackupCycle"

export interface RunBackupCycleRequest {
  /**
   * List of providers to backup or empty for all known providers.
   */
  providers?: Array<string>;
}

1.5.2.71. ExportBackupOp#

export type ExportBackupOp = {
  op: WalletApiOperation.ExportBackup;
  request: EmptyObject;
  response: EmptyObject;
};
// ExportBackup = "exportBackup"

1.5.2.72. ExportDbToFileOp#

/**
 * Export the database to a file.
 *
 * The target directory must already exist.
 */
export type ExportDbToFileOp = {
  op: WalletApiOperation.ExportDbToFile;
  request: ExportDbToFileRequest;
  response: ExportDbToFileResponse;
};
// ExportDbToFile = "exportDbToFile"

export interface ExportDbToFileRequest {
  /**
   * Directory that the DB should be exported into.
   */
  directory: string;
  /**
   * Stem of the exported DB filename.
   *
   * The final name will be ${directory}/${stem}.${extension},
   * where the extension depends on the used DB backend.
   */
  stem: string;
}

export interface ExportDbToFileResponse {
  /**
   * Full path to the backup.
   */
  path: string;
}

1.5.2.73. AddBackupProviderOp#

/**
 * Add a new backup provider.
 */
export type AddBackupProviderOp = {
  op: WalletApiOperation.AddBackupProvider;
  request: AddBackupProviderRequest;
  response: AddBackupProviderResponse;
};
// AddBackupProvider = "addBackupProvider"

export interface AddBackupProviderRequest {
  backupProviderBaseUrl: string;
  name: string;
  /**
   * Activate the provider.  Should only be done after
   * the user has reviewed the provider.
   */
  activate?: boolean;
}

export type AddBackupProviderResponse =
  | AddBackupProviderOk
  | AddBackupProviderPaymentRequired;

interface AddBackupProviderOk {
  status: "ok";
}

interface AddBackupProviderPaymentRequired {
  status: "payment-required";
  talerUri?: string;
}

1.5.2.74. RemoveBackupProviderOp#

export type RemoveBackupProviderOp = {
  op: WalletApiOperation.RemoveBackupProvider;
  request: RemoveBackupProviderRequest;
  response: EmptyObject;
};
// RemoveBackupProvider = "removeBackupProvider"

export interface RemoveBackupProviderRequest {
  provider: string;
}

1.5.2.75. GetBackupInfoOp#

/**
 * Get some useful stats about the backup state.
 */
export type GetBackupInfoOp = {
  op: WalletApiOperation.GetBackupInfo;
  request: EmptyObject;
  response: BackupInfo;
};
// GetBackupInfo = "getBackupInfo"

export interface BackupInfo {
  walletRootPub: string;
  deviceId: string;
  providers: ProviderInfo[];
}

/**
 * Information about one provider.
 *
 * We don't store the account key here,
 * as that's derived from the wallet root key.
 */
export interface ProviderInfo {
  active: boolean;
  syncProviderBaseUrl: string;
  name: string;
  terms?: BackupProviderTerms;
  /**
   * Last communication issue with the provider.
   */
  lastError?: TalerErrorDetail;
  lastSuccessfulBackupTimestamp?: TalerPreciseTimestamp;
  lastAttemptedBackupTimestamp?: TalerPreciseTimestamp;
  paymentProposalIds: string[];
  backupProblem?: BackupProblem;
  paymentStatus: ProviderPaymentStatus;
}

export interface BackupProviderTerms {
  supportedProtocolVersion: string;
  annualFee: AmountString;
  storageLimitInMegabytes: number;
}

export type BackupProblem =
  | BackupUnreadableProblem
  | BackupConflictingDeviceProblem;

export interface BackupUnreadableProblem {
  type: "backup-unreadable";
}

export interface BackupConflictingDeviceProblem {
  type: "backup-conflicting-device";
  otherDeviceId: string;
  myDeviceId: string;
  backupTimestamp: AbsoluteTime;
}

export type ProviderPaymentStatus =
  | ProviderPaymentTermsChanged
  | ProviderPaymentPaid
  | ProviderPaymentInsufficientBalance
  | ProviderPaymentUnpaid
  | ProviderPaymentPending;

export interface ProviderPaymentTermsChanged {
  type: ProviderPaymentType.TermsChanged;
  paidUntil: AbsoluteTime;
  oldTerms: BackupProviderTerms;
  newTerms: BackupProviderTerms;
}

export interface ProviderPaymentPaid {
  type: ProviderPaymentType.Paid;
  paidUntil: AbsoluteTime;
}

export interface ProviderPaymentInsufficientBalance {
  type: ProviderPaymentType.InsufficientBalance;
  amount: AmountString;
}

export interface ProviderPaymentUnpaid {
  type: ProviderPaymentType.Unpaid;
}

export interface ProviderPaymentPending {
  type: ProviderPaymentType.Pending;
  talerUri?: string;
}

1.5.2.76. SetWalletDeviceIdOp#

/**
 * Set the internal device ID of the wallet, used to
 * identify whether a different/new wallet is accessing
 * the backup of another wallet.
 */
export type SetWalletDeviceIdOp = {
  op: WalletApiOperation.SetWalletDeviceId;
  request: SetWalletDeviceIdRequest;
  response: EmptyObject;
};
// SetWalletDeviceId = "setWalletDeviceId"

export interface SetWalletDeviceIdRequest {
  /**
   * New wallet device ID to set.
   */
  walletDeviceId: string;
}

1.5.2.77. ListStoredBackupsOp#

export type ListStoredBackupsOp = {
  op: WalletApiOperation.ListStoredBackups;
  request: EmptyObject;
  response: StoredBackupList;
};
// ListStoredBackups = "listStoredBackups"

export interface StoredBackupList {
  storedBackups: {
    name: string;
  }[];
}

1.5.2.78. CreateStoredBackupsOp#

export type CreateStoredBackupsOp = {
  op: WalletApiOperation.CreateStoredBackup;
  request: EmptyObject;
  response: CreateStoredBackupResponse;
};
// CreateStoredBackup = "createStoredBackup"

export interface CreateStoredBackupResponse {
  name: string;
}

1.5.2.79. RecoverStoredBackupsOp#

export type RecoverStoredBackupsOp = {
  op: WalletApiOperation.RecoverStoredBackup;
  request: RecoverStoredBackupRequest;
  response: EmptyObject;
};
// RecoverStoredBackup = "recoverStoredBackup"

export interface RecoverStoredBackupRequest {
  name: string;
}

1.5.2.80. DeleteStoredBackupOp#

export type DeleteStoredBackupOp = {
  op: WalletApiOperation.DeleteStoredBackup;
  request: DeleteStoredBackupRequest;
  response: EmptyObject;
};
// DeleteStoredBackup = "deleteStoredBackup"

export interface DeleteStoredBackupRequest {
  name: string;
}

1.5.2.81. CheckPeerPushDebitOp#

/**
 * Check if initiating a peer push payment is possible
 * based on the funds in the wallet.
 */
export type CheckPeerPushDebitOp = {
  op: WalletApiOperation.CheckPeerPushDebit;
  request: CheckPeerPushDebitRequest;
  response: CheckPeerPushDebitOkResponse;
};
// CheckPeerPushDebit = "checkPeerPushDebit"

1.5.2.82. CheckPeerPushDebitV2Op#

/**
 * Check if initiating a peer push payment is possible
 * based on the funds in the wallet.
 */
export type CheckPeerPushDebitV2Op = {
  op: WalletApiOperation.CheckPeerPushDebitV2;
  request: CheckPeerPushDebitRequest;
  response: CheckPeerPushDebitResponse;
};
// CheckPeerPushDebitV2 = "checkPeerPushDebitV2"

export type CheckPeerPushDebitResponse =
  | CheckPeerPushDebitOkResponse
  | CheckPeerPushDebitInsufficientBalanceResponse;

export interface CheckPeerPushDebitInsufficientBalanceResponse {
  type: "insufficient-balance";
  insufficientBalanceDetails: PaymentInsufficientBalanceDetails;
}

1.5.2.83. InitiatePeerPushDebitOp#

/**
 * Initiate an outgoing peer push payment.
 */
export type InitiatePeerPushDebitOp = {
  op: WalletApiOperation.InitiatePeerPushDebit;
  request: InitiatePeerPushDebitRequest;
  response: InitiatePeerPushDebitResponse;
};
// InitiatePeerPushDebit = "initiatePeerPushDebit"

export interface InitiatePeerPushDebitRequest {
  exchangeBaseUrl?: string;
  /**
   * Restrict the scope of funds that can be spent via the given
   * scope info.
   */
  restrictScope?: ScopeInfo;
  partialContractTerms: PeerContractTerms;
}

export interface InitiatePeerPushDebitResponse {
  exchangeBaseUrl: string;
  pursePub: string;
  mergePriv: string;
  contractPriv: string;
  transactionId: TransactionIdStr;
}

1.5.2.84. PreparePeerPushCreditOp#

/**
 * Check an incoming peer push payment.
 */
export type PreparePeerPushCreditOp = {
  op: WalletApiOperation.PreparePeerPushCredit;
  request: PreparePeerPushCreditRequest;
  response: PreparePeerPushCreditResponse;
};
// PreparePeerPushCredit = "preparePeerPushCredit"

export interface PreparePeerPushCreditRequest {
  talerUri: string;
}

export interface PreparePeerPushCreditResponse {
  contractTerms: PeerContractTerms;
  amountRaw: AmountString;
  amountEffective: AmountString;
  transactionId: TransactionIdStr;
  exchangeBaseUrl: string;
  scopeInfo: ScopeInfo;
  /**
   * @deprecated
   */
  amount: AmountString;
}

1.5.2.85. ConfirmPeerPushCreditOp#

/**
 * Accept an incoming peer push payment.
 */
export type ConfirmPeerPushCreditOp = {
  op: WalletApiOperation.ConfirmPeerPushCredit;
  request: ConfirmPeerPushCreditRequest;
  response: AcceptPeerPushPaymentResponse;
};
// ConfirmPeerPushCredit = "confirmPeerPushCredit"

export interface ConfirmPeerPushCreditRequest {
  transactionId: string;
}

export interface AcceptPeerPushPaymentResponse {
  transactionId: TransactionIdStr;
}

1.5.2.86. CheckPeerPullCreditOp#

/**
 * Check fees for an outgoing peer pull payment.
 */
export type CheckPeerPullCreditOp = {
  op: WalletApiOperation.CheckPeerPullCredit;
  request: CheckPeerPullCreditRequest;
  response: CheckPeerPullCreditResponse;
};
// CheckPeerPullCredit = "checkPeerPullCredit"

export interface CheckPeerPullCreditRequest {
  /**
   * Require using this particular exchange for this operation.
   */
  exchangeBaseUrl?: string;
  restrictScope?: ScopeInfo;
  amount: AmountString;
  /**
   * ID provided by the client to cancel the request.
   *
   * If the same request is made again with the same clientCancellationId,
   * all previous requests are cancelled.
   *
   * The cancelled request will receive an error response with
   * an error code that indicates the cancellation.
   *
   * The cancellation is best-effort, responses might still arrive.
   */
  clientCancellationId?: string;
}

export interface CheckPeerPullCreditResponse {
  exchangeBaseUrl: string;
  amountRaw: AmountString;
  amountEffective: AmountString;
  /**
   * Number of coins that will be used,
   * can be used by the UI to warn if excessively large.
   */
  numCoins: number;
}

1.5.2.87. InitiatePeerPullCreditOp#

/**
 * Initiate an outgoing peer pull payment.
 */
export type InitiatePeerPullCreditOp = {
  op: WalletApiOperation.InitiatePeerPullCredit;
  request: InitiatePeerPullCreditRequest;
  response: InitiatePeerPullCreditResponse;
};
// InitiatePeerPullCredit = "initiatePeerPullCredit"

export interface InitiatePeerPullCreditRequest {
  exchangeBaseUrl?: string;
  partialContractTerms: PeerContractTerms;
}

export interface InitiatePeerPullCreditResponse {
  /**
   * Taler URI for the other party to make the payment
   * that was requested.
   *
   * @deprecated since it's not necessarily valid yet until the tx is in the right state
   */
  talerUri: string;
  transactionId: TransactionIdStr;
}

1.5.2.88. PreparePeerPullDebitOp#

/**
 * Prepare for an incoming peer pull payment.
 */
export type PreparePeerPullDebitOp = {
  op: WalletApiOperation.PreparePeerPullDebit;
  request: PreparePeerPullDebitRequest;
  response: PreparePeerPullDebitResponse;
};
// PreparePeerPullDebit = "preparePeerPullDebit"

export interface PreparePeerPullDebitRequest {
  talerUri: string;
}

export interface PreparePeerPullDebitResponse {
  contractTerms: PeerContractTerms;
  amountRaw: AmountString;
  amountEffective: AmountString;
  transactionId: TransactionIdStr;
  exchangeBaseUrl: string;
  scopeInfo: ScopeInfo;
  /**
   * @deprecated Redundant field with bad name, will be removed soon.
   */
  amount: AmountString;
}

1.5.2.89. ConfirmPeerPullDebitOp#

/**
 * Accept an incoming peer pull payment (i.e. pay the other party).
 */
export type ConfirmPeerPullDebitOp = {
  op: WalletApiOperation.ConfirmPeerPullDebit;
  request: ConfirmPeerPullDebitRequest;
  response: AcceptPeerPullPaymentResponse;
};
// ConfirmPeerPullDebit = "confirmPeerPullDebit"

export interface ConfirmPeerPullDebitRequest {
  transactionId: TransactionIdStr;
}

export interface AcceptPeerPullPaymentResponse {
  transactionId: TransactionIdStr;
}

1.5.2.90. ValidateIbanOp#

export type ValidateIbanOp = {
  op: WalletApiOperation.ValidateIban;
  request: ValidateIbanRequest;
  response: ValidateIbanResponse;
};
// ValidateIban = "validateIban"

export interface ValidateIbanRequest {
  iban: string;
}

export interface ValidateIbanResponse {
  valid: boolean;
}

1.5.2.91. CanonicalizeBaseUrlOp#

export type CanonicalizeBaseUrlOp = {
  op: WalletApiOperation.CanonicalizeBaseUrl;
  request: CanonicalizeBaseUrlRequest;
  response: CanonicalizeBaseUrlResponse;
};
// CanonicalizeBaseUrl = "canonicalizeBaseUrl"

export interface CanonicalizeBaseUrlRequest {
  url: string;
}

export interface CanonicalizeBaseUrlResponse {
  url: string;
}

1.5.2.92. GetQrCodesForPaytoOp#

export type GetQrCodesForPaytoOp = {
  op: WalletApiOperation.GetQrCodesForPayto;
  request: GetQrCodesForPaytoRequest;
  response: GetQrCodesForPaytoResponse;
};
// GetQrCodesForPayto = "getQrCodesForPayto"

export interface GetQrCodesForPaytoRequest {
  paytoUri: string;
}

export interface GetQrCodesForPaytoResponse {
  codes: QrCodeSpec[];
}

/**
 * Specification of a QR code that includes payment information.
 */
export interface QrCodeSpec {
  /**
   * Type of the QR code.
   *
   * Depending on the type, different visual styles
   * might be applied.
   */
  type: string;
  /**
   * Content of the QR code that should be rendered.
   */
  qrContent: string;
}

1.5.2.93. GetBankingChoicesForPaytoOp#

export type GetBankingChoicesForPaytoOp = {
  op: WalletApiOperation.GetBankingChoicesForPayto;
  request: GetBankingChoicesForPaytoRequest;
  response: GetBankingChoicesForPaytoResponse;
};
// GetBankingChoicesForPayto = "getBankingChoicesForPayto"

export interface GetBankingChoicesForPaytoRequest {
  paytoUri: string;
}

export interface GetBankingChoicesForPaytoResponse {
  choices: BankingChoiceSpec[];
}

export interface BankingChoiceSpec {
  label: string;
  type: "link";
  uri: string;
}

1.5.2.94. ExportDbOp#

/**
 * Export the wallet database's contents to JSON.
 */
export type ExportDbOp = {
  op: WalletApiOperation.ExportDb;
  request: EmptyObject;
  response: any;
};
// ExportDb = "exportDb"

1.5.2.95. ImportDbOp#

export type ImportDbOp = {
  op: WalletApiOperation.ImportDb;
  request: ImportDbRequest;
  response: EmptyObject;
};
// ImportDb = "importDb"

export interface ImportDbRequest {
  dump: any;
}

1.5.2.96. ClearDbOp#

/**
 * Dangerously clear the whole wallet database.
 */
export type ClearDbOp = {
  op: WalletApiOperation.ClearDb;
  request: EmptyObject;
  response: EmptyObject;
};
// ClearDb = "clearDb"

1.5.2.97. RecycleOp#

/**
 * Export a backup, clear the database and re-import it.
 */
export type RecycleOp = {
  op: WalletApiOperation.Recycle;
  request: EmptyObject;
  response: EmptyObject;
};
// Recycle = "recycle"

1.5.2.98. ApplyDevExperimentOp#

/**
 * Apply a developer experiment to the current wallet state.
 *
 * This allows UI developers / testers to play around without
 * an elaborate test environment.
 */
export type ApplyDevExperimentOp = {
  op: WalletApiOperation.ApplyDevExperiment;
  request: ApplyDevExperimentRequest;
  response: EmptyObject;
};
// ApplyDevExperiment = "applyDevExperiment"

export interface ApplyDevExperimentRequest {
  devExperimentUri: string;
}

1.5.2.99. RunIntegrationTestOp#

/**
 * Run a simple integration test on a test deployment
 * of the exchange and merchant.
 */
export type RunIntegrationTestOp = {
  op: WalletApiOperation.RunIntegrationTest;
  request: IntegrationTestArgs;
  response: EmptyObject;
};
// RunIntegrationTest = "runIntegrationTest"

export interface IntegrationTestArgs {
  exchangeBaseUrl: string;
  corebankApiBaseUrl: string;
  merchantBaseUrl: string;
  merchantAuthToken?: string;
  amountToWithdraw: AmountString;
  amountToSpend: AmountString;
}

1.5.2.100. RunIntegrationTestV2Op#

/**
 * Run a simple integration test on a test deployment
 * of the exchange and merchant.
 */
export type RunIntegrationTestV2Op = {
  op: WalletApiOperation.RunIntegrationTestV2;
  request: IntegrationTestV2Args;
  response: EmptyObject;
};
// RunIntegrationTestV2 = "runIntegrationTestV2"

export interface IntegrationTestV2Args {
  exchangeBaseUrl: string;
  corebankApiBaseUrl: string;
  merchantBaseUrl: string;
  merchantAuthToken?: string;
}

1.5.2.101. TestCryptoOp#

/**
 * Test crypto worker.
 */
export type TestCryptoOp = {
  op: WalletApiOperation.TestCrypto;
  request: EmptyObject;
  response: any;
};
// TestCrypto = "testCrypto"

1.5.2.102. WithdrawTestBalanceOp#

/**
 * Make withdrawal on a test deployment of the exchange
 * and merchant.
 */
export type WithdrawTestBalanceOp = {
  op: WalletApiOperation.WithdrawTestBalance;
  request: WithdrawTestBalanceRequest;
  response: WithdrawTestBalanceResult;
};
// WithdrawTestBalance = "withdrawTestBalance"

export interface WithdrawTestBalanceRequest {
  /**
   * Amount to withdraw.
   */
  amount: AmountString;
  /**
   * Corebank API base URL.
   */
  corebankApiBaseUrl: string;
  /**
   * Exchange to use for withdrawal.
   */
  exchangeBaseUrl: string;
  /**
   * Force the usage of a particular denomination selection.
   *
   * Only useful for testing.
   */
  forcedDenomSel?: ForcedDenomSel;
  /**
   * If set to true, treat the account created during
   * the withdrawal as a foreign withdrawal account.
   */
  useForeignAccount?: boolean;
}

1.5.2.103. WithdrawTestkudosOp#

/**
 * Make a withdrawal of testkudos on test.taler.net.
 */
export type WithdrawTestkudosOp = {
  op: WalletApiOperation.WithdrawTestkudos;
  request: EmptyObject;
  response: WithdrawTestBalanceResult;
};
// WithdrawTestkudos = "withdrawTestkudos"

1.5.2.104. TestPayOp#

/**
 * Make a test payment using a test deployment of
 * the exchange and merchant.
 */
export type TestPayOp = {
  op: WalletApiOperation.TestPay;
  request: TestPayArgs;
  response: TestPayResult;
};
// TestPay = "testPay"

export interface TestPayArgs {
  merchantBaseUrl: string;
  merchantAuthToken?: string;
  amount: AmountString;
  summary: string;
  forcedCoinSel?: ForcedCoinSel;
}

export interface TestPayResult {
  /**
   * Number of coins used for the payment.
   */
  numCoins: number;
}

1.5.2.105. GetActiveTasksOp#

export type GetActiveTasksOp = {
  op: WalletApiOperation.GetActiveTasks;
  request: EmptyObject;
  response: GetActiveTasksResponse;
};
// GetActiveTasks = "getActiveTasks"

export interface GetActiveTasksResponse {
  tasks: ActiveTask[];
}

export interface ActiveTask {
  taskId: string;
  transaction: TransactionIdStr | undefined;
  firstTry: AbsoluteTime | undefined;
  nextTry: AbsoluteTime | undefined;
  retryCounter: number | undefined;
  lastError: TalerErrorDetail | undefined;
}

1.5.2.106. DumpCoinsOp#

/**
 * Dump all coins of the wallet in a simple JSON format.
 */
export type DumpCoinsOp = {
  op: WalletApiOperation.DumpCoins;
  request: EmptyObject;
  response: CoinDumpJson;
};
// DumpCoins = "dumpCoins"

/**
 * Easy to process format for the public data of coins
 * managed by the wallet.
 */
export interface CoinDumpJson {
  coins: Array<{
    /**
     * The coin's denomination's public key.
     */
    denomPub: DenominationPubKey;
    /**
     * Hash of denom_pub.
     */
    denomPubHash: string;
    /**
     * Value of the denomination (without any fees).
     */
    denomValue: string;
    /**
     * Public key of the coin.
     */
    coinPub: string;
    /**
     * Base URL of the exchange for the coin.
     */
    exchangeBaseUrl: string;
    /**
     * Public key of the parent coin.
     * Only present if this coin was obtained via refreshing.
     */
    refreshParentCoinPub: string | undefined;
    /**
     * Public key of the reserve for this coin.
     * Only present if this coin was obtained via refreshing.
     */
    withdrawalReservePub: string | undefined;
    /**
     * Status of the coin.
     */
    coinStatus: CoinStatus;
    /**
     * Information about the age restriction
     */
    ageCommitmentProof: AgeCommitmentProof | undefined;
    history: WalletCoinHistoryItem[];
  }>;
}

export type DenominationPubKey = RsaDenominationPubKey | CsDenominationPubKey;

export interface RsaDenominationPubKey {
  readonly cipher: DenomKeyType.Rsa;
  readonly rsa_public_key: string;
  readonly age_mask: number;
}

export interface CsDenominationPubKey {
  readonly cipher: DenomKeyType.ClauseSchnorr;
  readonly age_mask: number;
  readonly cs_public_key: string;
}

/**
 * Status of a coin.
 */
export declare enum CoinStatus {
  /**
   * Withdrawn and never shown to anybody.
   */
  Fresh = "fresh",
  /**
   * Coin was lost as the denomination is not usable anymore.
   */
  DenomLoss = "denom-loss",
  /**
   * Fresh, but currently marked as "suspended", thus won't be used
   * for spending.  Used for testing.
   */
  FreshSuspended = "fresh-suspended",
  /**
   * A coin that has been spent and refreshed.
   */
  Dormant = "dormant",
}

export interface AgeCommitmentProof {
  commitment: AgeCommitment;
  proof: AgeProof;
}

export interface AgeCommitment {
  mask: number;
  /**
   * Public keys, one for each age group specified in the age mask.
   */
  publicKeys: Edx25519PublicKeyEnc[];
}

export type Edx25519PublicKeyEnc = FlavorP<string, "Edx25519PublicKeyEnc", 32>;

export type FlavorP<T, FlavorT extends string, S extends number> = T & {
  _flavor?: `taler.${FlavorT}`;
  _size?: S;
};

export interface AgeProof {
  /**
   * Private keys.  Typically smaller than the number of public keys,
   * because we drop private keys from age groups that are restricted.
   */
  privateKeys: Edx25519PrivateKeyEnc[];
}

export type Edx25519PrivateKeyEnc = FlavorP<
  string,
  "Edx25519PrivateKeyEnc",
  64
>;

export type WalletCoinHistoryItem =
  | {
      type: "withdraw";
      transactionId: TransactionIdStr;
    }
  | {
      type: "spend";
      transactionId: TransactionIdStr;
      amount: AmountString;
    }
  | {
      type: "refresh";
      transactionId: TransactionIdStr;
      amount: AmountString;
    }
  | {
      type: "recoup";
      transactionId: TransactionIdStr;
      amount: AmountString;
    }
  | {
      type: "refund";
      transactionId: TransactionIdStr;
      amount: AmountString;
    };

1.5.2.107. TestingSetTimetravelOp#

/**
 * Add an offset to the wallet's internal time.
 */
export type TestingSetTimetravelOp = {
  op: WalletApiOperation.TestingSetTimetravel;
  request: TestingSetTimetravelRequest;
  response: EmptyObject;
};
// TestingSetTimetravel = "testingSetTimetravel"

export interface TestingSetTimetravelRequest {
  offsetMs: number;
}

1.5.2.108. TestingWaitTransactionsFinalOp#

/**
 * Wait until all transactions are in a final state.
 */
export type TestingWaitTransactionsFinalOp = {
  op: WalletApiOperation.TestingWaitTransactionsFinal;
  request: EmptyObject;
  response: EmptyObject;
};
// TestingWaitTransactionsFinal = "testingWaitTransactionsFinal"

1.5.2.109. TestingWaitTasksDoneOp#

/**
 * Wait until all transactions are in a final state.
 */
export type TestingWaitTasksDoneOp = {
  op: WalletApiOperation.TestingWaitTasksDone;
  request: EmptyObject;
  response: EmptyObject;
};
// TestingWaitTasksDone = "testingWaitTasksDone"

1.5.2.110. TestingWaitRefreshesFinalOp#

/**
 * Wait until all refresh transactions are in a final state.
 */
export type TestingWaitRefreshesFinalOp = {
  op: WalletApiOperation.TestingWaitRefreshesFinal;
  request: EmptyObject;
  response: EmptyObject;
};
// TestingWaitRefreshesFinal = "testingWaitRefreshesFinal"

1.5.2.111. TestingWaitTransactionStateOp#

/**
 * Wait until a transaction is in a particular state.
 */
export type TestingWaitTransactionStateOp = {
  op: WalletApiOperation.TestingWaitTransactionState;
  request: TestingWaitTransactionRequest;
  response: EmptyObject;
};
// TestingWaitTransactionState = "testingWaitTransactionState"

export interface TestingWaitTransactionRequest {
  transactionId: TransactionIdStr;
  txState: TransactionStatePattern | TransactionStatePattern[];
}

export interface TransactionStatePattern {
  major: TransactionMajorState | TransactionStateWildcard;
  minor?: TransactionMinorState | TransactionStateWildcard;
}

1.5.2.112. TestingWaitExchangeStateOp#

/**
 * Wait until an exchange entry is in a particular state.
 */
export type TestingWaitExchangeStateOp = {
  op: WalletApiOperation.TestingWaitTransactionState;
  request: TestingWaitExchangeStateRequest;
  response: EmptyObject;
};
// TestingWaitTransactionState = "testingWaitTransactionState"

export interface TestingWaitExchangeStateRequest {
  exchangeBaseUrl: string;
  walletKycStatus?: ExchangeWalletKycStatus;
}

1.5.2.113. TestingPingOp#

export type TestingPingOp = {
  op: WalletApiOperation.TestingPing;
  request: EmptyObject;
  response: EmptyObject;
};
// TestingPing = "testingPing"

1.5.2.114. TestingGetReserveHistoryOp#

export type TestingGetReserveHistoryOp = {
  op: WalletApiOperation.TestingGetReserveHistory;
  request: TestingGetReserveHistoryRequest;
  response: any;
};
// TestingGetReserveHistory = "testingGetReserveHistory"

export interface TestingGetReserveHistoryRequest {
  reservePub: string;
  exchangeBaseUrl: string;
}

1.5.2.115. TestingResetAllRetriesOp#

/**
 * Reset all task/transaction retries,
 * resulting in immediate re-try of all operations.
 */
export type TestingResetAllRetriesOp = {
  op: WalletApiOperation.TestingResetAllRetries;
  request: EmptyObject;
  response: EmptyObject;
};
// TestingResetAllRetries = "testingResetAllRetries"

1.5.2.116. TestingGetDenomStatsOp#

/**
 * Get stats about an exchange denomination.
 */
export type TestingGetDenomStatsOp = {
  op: WalletApiOperation.TestingGetDenomStats;
  request: TestingGetDenomStatsRequest;
  response: TestingGetDenomStatsResponse;
};
// TestingGetDenomStats = "testingGetDenomStats"

export interface TestingGetDenomStatsRequest {
  exchangeBaseUrl: string;
}

export interface TestingGetDenomStatsResponse {
  numKnown: number;
  numOffered: number;
  numLost: number;
}

1.5.2.117. SetCoinSuspendedOp#

/**
 * Set a coin as (un-)suspended.
 * Suspended coins won't be used for payments.
 */
export type SetCoinSuspendedOp = {
  op: WalletApiOperation.SetCoinSuspended;
  request: SetCoinSuspendedRequest;
  response: EmptyObject;
};
// SetCoinSuspended = "setCoinSuspended"

export interface SetCoinSuspendedRequest {
  coinPub: string;
  suspended: boolean;
}

1.5.2.118. ForceRefreshOp#

/**
 * Force a refresh on coins where it would not
 * be necessary.
 */
export type ForceRefreshOp = {
  op: WalletApiOperation.ForceRefresh;
  request: ForceRefreshRequest;
  response: EmptyObject;
};
// ForceRefresh = "forceRefresh"

export interface ForceRefreshRequest {
  refreshCoinSpecs: RefreshCoinSpec[];
}

export interface RefreshCoinSpec {
  coinPub: string;
  amount?: AmountString;
}

1.5.3. Common Declarations#

export interface InitRequest {
  config?: PartialWalletRunConfig;
}

export interface PartialWalletRunConfig {
  builtin?: Partial<WalletRunConfig["builtin"]>;
  testing?: Partial<WalletRunConfig["testing"]>;
  features?: Partial<WalletRunConfig["features"]>;
  lazyTaskLoop?: Partial<WalletRunConfig["lazyTaskLoop"]>;
}

export interface WalletRunConfig {
  /**
   * Initialization values useful for a complete startup.
   *
   * These are values may be overridden by different wallets
   */
  builtin: {
    exchanges: BuiltinExchange[];
  };
  /**
   * Unsafe options which it should only be used to create
   * testing environment.
   */
  testing: {
    /**
     * Allow withdrawal of denominations even though they are about to expire.
     */
    denomselAllowLate: boolean;
    devModeActive: boolean;
    insecureTrustExchange: boolean;
    preventThrottling: boolean;
    skipDefaults: boolean;
    emitObservabilityEvents?: boolean;
  };
  /**
   * Configurations values that may be safe to show to the user
   */
  features: {
    allowHttp: boolean;
  };
  /**
   * Start processing tasks only when explicitly required, even after
   * init has been called.
   *
   * Useful when the wallet is started to make single read-only request,
   * as otherwise wallet-core starts making network request and process
   * unrelated pending tasks.
   */
  lazyTaskLoop: boolean;
}

export interface BuiltinExchange {
  exchangeBaseUrl: string;
  currencyHint: string;
}

export interface InitResponse {
  versionInfo: WalletCoreVersion;
}

export interface WalletCoreVersion {
  implementationSemver: string;
  implementationGitHash: string;
  /**
   * Wallet-core protocol version supported by this implementation
   * of the API ("server" version).
   */
  version: string;
  exchange: string;
  merchant: string;
  bankIntegrationApiRange: string;
  bankConversionApiRange: string;
  corebankApiRange: string;
  /**
   * @deprecated as bank was split into multiple APIs with separate versioning
   */
  bank: string;
  /**
   * @deprecated
   */
  hash: string | undefined;
  /**
   * @deprecated will be removed
   */
  devMode: boolean;
}

export type EmptyObject = Record<string, never>;

export type ScopeInfo = ScopeInfoGlobal | ScopeInfoExchange | ScopeInfoAuditor;

export type ScopeInfoGlobal = {
  type: ScopeType.Global;
  currency: string;
};

export type ScopeInfoExchange = {
  type: ScopeType.Exchange;
  currency: string;
  url: string;
};

export interface Exchange {
  url: string;
  priority: Integer;
  master_pub: EddsaPublicKey;
}

export type ScopeInfoAuditor = {
  type: ScopeType.Auditor;
  currency: string;
  url: string;
};

export type AmountString =
  | (string & {
      [__amount_str]: true;
    })
  | LitAmountString;

export type AccountRestriction =
  | RegexAccountRestriction
  | DenyAllAccountRestriction;

export interface RegexAccountRestriction {
  type: "regex";
  payto_regex: string;
  human_hint: string;
  human_hint_i18n?: InternationalizedString;
}

export interface InternationalizedString {
  [lang_tag: string]: string;
}

export interface DenyAllAccountRestriction {
  type: "deny";
}

export interface TransactionsResponse {
  transactions: Transaction[];
}

export type Transaction =
  | TransactionWithdrawal
  | TransactionPayment
  | TransactionRefund
  | TransactionRefresh
  | TransactionDeposit
  | TransactionPeerPullCredit
  | TransactionPeerPullDebit
  | TransactionPeerPushCredit
  | TransactionPeerPushDebit
  | TransactionInternalWithdrawal
  | TransactionRecoup
  | TransactionDenomLoss;

/**
 * A withdrawal transaction (either bank-integrated or manual).
 */
export interface TransactionWithdrawal extends TransactionCommon {
  type: TransactionType.Withdrawal;
  /**
   * Exchange of the withdrawal.
   */
  exchangeBaseUrl: string | undefined;
  /**
   * Amount that got subtracted from the reserve balance.
   */
  amountRaw: AmountString;
  /**
   * Amount that actually was (or will be) added to the wallet's balance.
   */
  amountEffective: AmountString;
  withdrawalDetails: WithdrawalDetails;
}

export interface TransactionCommon {
  transactionId: TransactionIdStr;
  type: TransactionType;
  timestamp: TalerPreciseTimestamp;
  /**
   * Scope of this tx
   */
  scopes: ScopeInfo[];
  /**
   * Transaction state, as per DD37.
   */
  txState: TransactionState;
  /**
   * Possible transitions based on the current state.
   */
  txActions: TransactionAction[];
  /**
   * Raw amount of the transaction (exclusive of fees or other extra costs).
   */
  amountRaw: AmountString;
  /**
   * Amount added or removed from the wallet's balance (including all fees and other costs).
   */
  amountEffective: AmountString;
  error?: TalerErrorDetail;
  abortReason?: TalerErrorDetail;
  failReason?: TalerErrorDetail;
  /**
   * If the transaction minor state is in KycRequired this field is going to
   * have the location where the user need to go to complete KYC information.
   */
  kycUrl?: string;
  /**
   * KYC payto hash. Useful for testing, not so useful for UIs.
   */
  kycPaytoHash?: string;
  /**
   * KYC access token. Useful for testing, not so useful for UIs.
   */
  kycAccessToken?: string;
  kycAuthTransferInfo?: KycAuthTransferInfo;
}

export type TransactionIdStr = `txn:${string}:${string}` & {
  [__txId]: true;
};

export declare enum TransactionType {
  Withdrawal = "withdrawal",
  InternalWithdrawal = "internal-withdrawal",
  Payment = "payment",
  Refund = "refund",
  Refresh = "refresh",
  Deposit = "deposit",
  PeerPushDebit = "peer-push-debit",
  PeerPushCredit = "peer-push-credit",
  PeerPullDebit = "peer-pull-debit",
  PeerPullCredit = "peer-pull-credit",
  Recoup = "recoup",
  DenomLoss = "denom-loss",
}

/**
 * Precise timestamp, typically used in the wallet-core
 * API but not in other Taler APIs so far.
 */
export interface TalerPreciseTimestamp {
  /**
   * Seconds (as integer) since epoch.
   */
  readonly t_s: number | "never";
  /**
   * Optional microsecond offset (non-negative integer).
   */
  readonly off_us?: number;
  readonly _flavor?: typeof flavor_TalerPreciseTimestamp;
}

export interface TalerProtocolTimestamp {
  /**
   * Seconds (as integer) since epoch.
   */
  readonly t_s: number | "never";
  readonly _flavor?: typeof flavor_TalerProtocolTimestamp;
}

export interface TransactionState {
  major: TransactionMajorState;
  minor?: TransactionMinorState;
}

export declare enum TransactionMajorState {
  None = "none",
  Pending = "pending",
  Done = "done",
  Aborting = "aborting",
  Aborted = "aborted",
  Dialog = "dialog",
  Finalizing = "finalizing",
  Suspended = "suspended",
  SuspendedFinalizing = "suspended-finalizing",
  SuspendedAborting = "suspended-aborting",
  Failed = "failed",
  Expired = "expired",
  Deleted = "deleted",
}

export declare enum TransactionMinorState {
  Unknown = "unknown",
  Deposit = "deposit",
  KycRequired = "kyc",
  MergeKycRequired = "merge-kyc",
  BalanceKycRequired = "balance-kyc",
  BalanceKycInit = "balance-kyc-init",
  KycAuthRequired = "kyc-auth",
  Track = "track",
  SubmitPayment = "submit-payment",
  RebindSession = "rebind-session",
  Refresh = "refresh",
  Pickup = "pickup",
  AutoRefund = "auto-refund",
  User = "user",
  Bank = "bank",
  Exchange = "exchange",
  ClaimProposal = "claim-proposal",
  CheckRefund = "check-refund",
  CreatePurse = "create-purse",
  DeletePurse = "delete-purse",
  RefreshExpired = "refresh-expired",
  Ready = "ready",
  Merge = "merge",
  Repurchase = "repurchase",
  BankRegisterReserve = "bank-register-reserve",
  BankConfirmTransfer = "bank-confirm-transfer",
  WithdrawCoins = "withdraw-coins",
  ExchangeWaitReserve = "exchange-wait-reserve",
  AbortingBank = "aborting-bank",
  Aborting = "aborting",
  Refused = "refused",
  Withdraw = "withdraw",
  MerchantOrderProposed = "merchant-order-proposed",
  Proposed = "proposed",
  RefundAvailable = "refund-available",
  AcceptRefund = "accept-refund",
  PaidByOther = "paid-by-other",
  CompletedByOtherWallet = "completed-by-other-wallet",
}

export declare enum TransactionAction {
  Delete = "delete",
  Suspend = "suspend",
  Resume = "resume",
  Abort = "abort",
  Fail = "fail",
  Retry = "retry",
}

export interface TalerErrorDetail {
  code: TalerErrorCode;
  when?: AbsoluteTime;
  hint?: string;
  [x: string]: unknown;
}

export interface AbsoluteTime {
  /**
   * Timestamp in milliseconds.
   */
  readonly t_ms: number | "never";
  readonly _flavor?: typeof flavor_AbsoluteTime;
  [opaque_AbsoluteTime]: true;
}

export interface Duration {
  /**
   * Duration in milliseconds.
   */
  readonly d_ms: number | "forever";
}

export interface TalerProtocolDuration {
  readonly d_us: number | "forever";
}

export interface KycAuthTransferInfo {
  /**
   * Payto URI of the account that must make the transfer.
   *
   * The KYC auth transfer will *not* work if it originates
   * from a different account.
   */
  debitPaytoUri: string;
  /**
   * Account public key that must be included in the subject.
   */
  accountPub: string;
  /**
   * Possible target payto URIs.
   */
  creditPaytoUris: string[];
}

export type WithdrawalDetails =
  | WithdrawalDetailsForManualTransfer
  | WithdrawalDetailsForTalerBankIntegrationApi;

interface WithdrawalDetailsForManualTransfer {
  type: WithdrawalType.ManualTransfer;
  /**
   * Payto URIs that the exchange supports.
   *
   * Already contains the amount and message.
   *
   * @deprecated in favor of exchangeCreditAccounts
   */
  exchangePaytoUris: string[];
  exchangeCreditAccountDetails?: WithdrawalExchangeAccountDetails[];
  reservePub: string;
  /**
   * Is the reserve ready for withdrawal?
   */
  reserveIsReady: boolean;
  /**
   * How long does the exchange wait to transfer back funds from a
   * reserve?
   */
  reserveClosingDelay: TalerProtocolDuration;
}

export interface WithdrawalExchangeAccountDetails {
  /**
   * Payto URI to credit the exchange.
   *
   * Depending on whether the (manual!) withdrawal is accepted or just
   * being checked, this already includes the subject with the
   * reserve public key.
   */
  paytoUri: string;
  /**
   * Status that indicates whether the account can be used
   * by the user to send funds for a withdrawal.
   *
   * ok: account should be shown to the user
   * error: account should not be shown to the user, UIs might render the error (in conversionError),
   *   especially in dev mode.
   */
  status: "ok" | "error";
  /**
   * Transfer amount. Might be in a different currency than the requested
   * amount for withdrawal.
   *
   * Absent if this is a conversion account and the conversion failed.
   */
  transferAmount?: AmountString;
  /**
   * Currency specification for the external currency.
   *
   * Only included if this account requires a currency conversion.
   */
  currencySpecification?: CurrencySpecification;
  /**
   * Further restrictions for sending money to the
   * exchange.
   */
  creditRestrictions?: AccountRestriction[];
  /**
   * Label given to the account or the account's bank by the exchange.
   */
  bankLabel?: string;
  priority?: number;
  /**
   * Error that happened when attempting to request the conversion rate.
   */
  conversionError?: TalerErrorDetail;
}

/**
 * DD51 https://docs.taler.net/design-documents/051-fractional-digits.html
 */
export interface CurrencySpecification {
  name: string;
  num_fractional_input_digits: Integer;
  num_fractional_normal_digits: Integer;
  num_fractional_trailing_zero_digits: Integer;
  alt_unit_names: {
    [log10: string]: string;
  };
}

interface WithdrawalDetailsForTalerBankIntegrationApi {
  type: WithdrawalType.TalerBankIntegrationApi;
  /**
   * Set to true if the bank has confirmed the withdrawal, false if not.
   * An unconfirmed withdrawal usually requires user-input and should be highlighted in the UI.
   * See also bankConfirmationUrl below.
   */
  confirmed: boolean;
  /**
   * If the withdrawal is unconfirmed, this can include a URL for user
   * initiated confirmation.
   */
  bankConfirmationUrl?: string;
  reservePub: string;
  /**
   * Is the reserve ready for withdrawal?
   */
  reserveIsReady: boolean;
  /**
   * Is the bank transfer for the withdrawal externally confirmed?
   */
  externalConfirmation?: boolean;
  exchangeCreditAccountDetails?: WithdrawalExchangeAccountDetails[];
}

export interface TransactionPayment extends TransactionCommon {
  type: TransactionType.Payment;
  /**
   * Additional information about the payment.
   */
  info: OrderShortInfo;
  /**
   * Full contract terms.
   *
   * Only included if explicitly included in the request.
   */
  contractTerms?: ContractTerms;
  /**
   * Amount that must be paid for the contract
   */
  amountRaw: AmountString;
  /**
   * Amount that was paid, including deposit, wire and refresh fees.
   */
  amountEffective: AmountString;
  /**
   * Amount that has been refunded by the merchant
   */
  totalRefundRaw: AmountString;
  /**
   * Amount will be added to the wallet's balance after fees and refreshing
   */
  totalRefundEffective: AmountString;
  /**
   * Amount pending to be picked up
   */
  refundPending: AmountString | undefined;
  /**
   * Reference to applied refunds
   */
  refunds: RefundInfoShort[];
  /**
   * Is the wallet currently checking for a refund?
   */
  refundQueryActive: boolean;
  /**
   * Does this purchase has an pos validation
   */
  posConfirmation: string | undefined;
}

export interface OrderShortInfo {
  /**
   * Order ID, uniquely identifies the order within a merchant instance
   */
  orderId: string;
  /**
   * Hash of the contract terms.
   */
  contractTermsHash: string;
  /**
   * More information about the merchant
   */
  merchant: MerchantInfo;
  /**
   * Summary of the order, given by the merchant
   */
  summary: string;
  /**
   * Map from IETF BCP 47 language tags to localized summaries
   */
  summary_i18n?: InternationalizedString;
  /**
   * URL of the fulfillment, given by the merchant
   */
  fulfillmentUrl?: string;
  /**
   * Plain text message that should be shown to the user
   * when the payment is complete.
   */
  fulfillmentMessage?: string;
  /**
   * Translations of fulfillmentMessage.
   */
  fulfillmentMessage_i18n?: InternationalizedString;
}

export interface MerchantInfo {
  name: string;
  email?: string;
  website?: string;
  logo?: ImageDataUrl;
  address?: Location;
  jurisdiction?: Location;
}

export interface Location {
  country?: string;
  country_subdivision?: string;
  district?: string;
  town?: string;
  town_location?: string;
  post_code?: string;
  street?: string;
  building_name?: string;
  building_number?: string;
  address_lines?: string[];
}

export interface ContractTerms {
  summary: string;
  summary_i18n?: {
    [lang_tag: string]: string;
  };
  order_id: string;
  amount: AmountString;
  public_reorder_url?: string;
  fulfillment_url?: string;
  fulfillment_message?: string;
  fulfillment_message_i18n?: {
    [lang_tag: string]: string;
  };
  max_fee: AmountString;
  products: Product[];
  timestamp: Timestamp;
  refund_deadline: Timestamp;
  pay_deadline: Timestamp;
  wire_transfer_deadline: Timestamp;
  merchant_pub: EddsaPublicKey;
  merchant_base_url: string;
  merchant: Merchant;
  h_wire: HashCode;
  wire_method: string;
  exchanges: Exchange[];
  delivery_location?: Location;
  delivery_date?: Timestamp;
  nonce: string;
  auto_refund?: RelativeTime;
  extra?: any;
  minimum_age?: Integer;
}

export interface Product {
  product_id?: string;
  description: string;
  description_i18n?: {
    [lang_tag: string]: string;
  };
  quantity?: Integer;
  unit?: string;
  price?: AmountString;
  image?: ImageDataUrl;
  taxes?: Tax[];
  delivery_date?: Timestamp;
}

export interface Tax {
  name: string;
  tax: AmountString;
}

export interface Merchant {
  name: string;
  email?: string;
  website?: string;
  logo?: ImageDataUrl;
  address?: Location;
  jurisdiction?: Location;
}

export interface RefundInfoShort {
  transactionId: string;
  timestamp: TalerProtocolTimestamp;
  amountEffective: AmountString;
  amountRaw: AmountString;
}

export interface TransactionRefund extends TransactionCommon {
  type: TransactionType.Refund;
  amountRaw: AmountString;
  amountEffective: AmountString;
  refundedTransactionId: string;
  paymentInfo: RefundPaymentInfo | undefined;
}

/**
 * Summary information about the payment that we got a refund for.
 */
export interface RefundPaymentInfo {
  summary: string;
  summary_i18n?: InternationalizedString;
  /**
   * More information about the merchant
   */
  merchant: MerchantInfo;
}

/**
 * A transaction shown for refreshes.
 * Only shown for (1) refreshes not associated with other transactions
 * and (2) refreshes in an error state.
 */
export interface TransactionRefresh extends TransactionCommon {
  type: TransactionType.Refresh;
  refreshReason: RefreshReason;
  /**
   * Transaction ID that caused this refresh.
   */
  originatingTransactionId?: string;
  /**
   * Always zero for refreshes
   */
  amountRaw: AmountString;
  /**
   * Fees, i.e. the effective, negative effect of the refresh
   * on the balance.
   *
   * Only applicable for stand-alone refreshes, and zero for
   * other refreshes where the transaction itself accounts for the
   * refresh fee.
   */
  amountEffective: AmountString;
  refreshInputAmount: AmountString;
  refreshOutputAmount: AmountString;
}

/**
 * Reasons for why a coin is being refreshed.
 */
export declare enum RefreshReason {
  Manual = "manual",
  PayMerchant = "pay-merchant",
  PayDeposit = "pay-deposit",
  PayPeerPush = "pay-peer-push",
  PayPeerPull = "pay-peer-pull",
  Refund = "refund",
  AbortPay = "abort-pay",
  AbortDeposit = "abort-deposit",
  AbortPeerPushDebit = "abort-peer-push-debit",
  AbortPeerPullDebit = "abort-peer-pull-debit",
  Recoup = "recoup",
  BackupRestored = "backup-restored",
  Scheduled = "scheduled",
}

/**
 * Deposit transaction, which effectively sends
 * money from this wallet somewhere else.
 */
export interface TransactionDeposit extends TransactionCommon {
  type: TransactionType.Deposit;
  depositGroupId: string;
  /**
   * Target for the deposit.
   */
  targetPaytoUri: string;
  /**
   * Raw amount that is being deposited
   */
  amountRaw: AmountString;
  /**
   * Deposit account public key.
   */
  accountPub: string;
  /**
   * Effective amount that is being deposited
   */
  amountEffective: AmountString;
  wireTransferDeadline: TalerProtocolTimestamp;
  wireTransferProgress: number;
  /**
   * Did all the deposit requests succeed?
   */
  deposited: boolean;
  trackingState: Array<DepositTransactionTrackingState>;
}

export interface DepositTransactionTrackingState {
  wireTransferId: string;
  timestampExecuted: TalerProtocolTimestamp;
  amountRaw: AmountString;
  wireFee: AmountString;
}

/**
 * Credit because we were paid for a P2P invoice we created.
 */
export interface TransactionPeerPullCredit extends TransactionCommon {
  type: TransactionType.PeerPullCredit;
  info: PeerInfoShort;
  /**
   * Exchange used.
   */
  exchangeBaseUrl: string;
  /**
   * Amount that got subtracted from the reserve balance.
   */
  amountRaw: AmountString;
  /**
   * Amount that actually was (or will be) added to the wallet's balance.
   */
  amountEffective: AmountString;
  /**
   * URI to send to the other party.
   *
   * Only available in the right state.
   */
  talerUri: string | undefined;
}

export interface PeerInfoShort {
  expiration: TalerProtocolTimestamp | undefined;
  summary: string | undefined;
}

/**
 * Debit because we paid someone's invoice.
 */
export interface TransactionPeerPullDebit extends TransactionCommon {
  type: TransactionType.PeerPullDebit;
  info: PeerInfoShort;
  /**
   * Exchange used.
   */
  exchangeBaseUrl: string;
  amountRaw: AmountString;
  amountEffective: AmountString;
}

/**
 * We received money via a P2P payment.
 */
export interface TransactionPeerPushCredit extends TransactionCommon {
  type: TransactionType.PeerPushCredit;
  info: PeerInfoShort;
  /**
   * Exchange used.
   */
  exchangeBaseUrl: string;
  /**
   * Amount that got subtracted from the reserve balance.
   */
  amountRaw: AmountString;
  /**
   * Amount that actually was (or will be) added to the wallet's balance.
   */
  amountEffective: AmountString;
}

/**
 * We sent money via a P2P payment.
 */
export interface TransactionPeerPushDebit extends TransactionCommon {
  type: TransactionType.PeerPushDebit;
  info: PeerInfoShort;
  /**
   * Exchange used.
   */
  exchangeBaseUrl: string;
  /**
   * Amount that got subtracted from the reserve balance.
   */
  amountRaw: AmountString;
  /**
   * Amount that actually was (or will be) added to the wallet's balance.
   */
  amountEffective: AmountString;
  /**
   * URI to accept the payment.
   *
   * Only present if the transaction is in a state where the other party can
   * accept the payment.
   */
  talerUri?: string;
}

/**
 * Internal withdrawal operation, only reported on request.
 *
 * Some transactions (peer-*-credit) internally do a withdrawal,
 * but only the peer-*-credit transaction is reported.
 *
 * The internal withdrawal transaction allows to access the details of
 * the underlying withdrawal for testing/debugging.
 *
 * It is usually not reported, so that amounts of transactions properly
 * add up, since the amountEffecive of the withdrawal is already reported
 * in the peer-*-credit transaction.
 */
export interface TransactionInternalWithdrawal extends TransactionCommon {
  type: TransactionType.InternalWithdrawal;
  /**
   * Exchange of the withdrawal.
   */
  exchangeBaseUrl: string;
  /**
   * Amount that got subtracted from the reserve balance.
   */
  amountRaw: AmountString;
  /**
   * Amount that actually was (or will be) added to the wallet's balance.
   */
  amountEffective: AmountString;
  withdrawalDetails: WithdrawalDetails;
}

/**
 * The exchange revoked a key and the wallet recoups funds.
 */
export interface TransactionRecoup extends TransactionCommon {
  type: TransactionType.Recoup;
}

/**
 * A transaction to indicate financial loss due to denominations
 * that became unusable for deposits.
 */
export interface TransactionDenomLoss extends TransactionCommon {
  type: TransactionType.DenomLoss;
  lossEventType: DenomLossEventType;
  exchangeBaseUrl: string;
}

export declare enum DenomLossEventType {
  DenomExpired = "denom-expired",
  DenomVanished = "denom-vanished",
  DenomUnoffered = "denom-unoffered",
}

export interface AbortTransactionRequest {
  transactionId: TransactionIdStr;
}

export interface WithdrawUriInfoResponse {
  operationId: string;
  status: WithdrawalOperationStatusFlag;
  confirmTransferUrl?: string;
  currency: string;
  amount: AmountString | undefined;
  /**
   * Set to true if the user is allowed to edit the amount.
   *
   * Note that even with a non-editable amount, the amount
   * might be undefined at the beginning of the withdrawal
   * process.
   */
  editableAmount: boolean;
  maxAmount: AmountString | undefined;
  wireFee: AmountString | undefined;
  defaultExchangeBaseUrl?: string;
  editableExchange: boolean;
  possibleExchanges: ExchangeListItem[];
}

export type WithdrawalOperationStatusFlag =
  | "pending"
  | "selected"
  | "aborted"
  | "confirmed";

/**
 * Info about an exchange entry in the wallet.
 */
export interface ExchangeListItem {
  exchangeBaseUrl: string;
  masterPub: string | undefined;
  currency: string;
  paytoUris: string[];
  tosStatus: ExchangeTosStatus;
  exchangeEntryStatus: ExchangeEntryStatus;
  exchangeUpdateStatus: ExchangeUpdateStatus;
  ageRestrictionOptions: number[];
  walletKycStatus?: ExchangeWalletKycStatus;
  walletKycReservePub?: string;
  walletKycAccessToken?: string;
  walletKycUrl?: string;
  /**
   * P2P payments are disabled with this exchange
   * (e.g. because no global fees are configured).
   */
  peerPaymentsDisabled: boolean;
  /**
   * Set to true if this exchange doesn't charge any fees.
   */
  noFees: boolean;
  scopeInfo: ScopeInfo;
  lastUpdateTimestamp: TalerPreciseTimestamp | undefined;
  /**
   * Information about the last error that occurred when trying
   * to update the exchange info.
   */
  lastUpdateErrorInfo?: OperationErrorInfo;
  unavailableReason?: TalerErrorDetail;
}

export declare enum ExchangeTosStatus {
  Pending = "pending",
  Proposed = "proposed",
  Accepted = "accepted",
  MissingTos = "missing-tos",
}

export declare enum ExchangeEntryStatus {
  Preset = "preset",
  Ephemeral = "ephemeral",
  Used = "used",
}

export declare enum ExchangeUpdateStatus {
  Initial = "initial",
  InitialUpdate = "initial-update",
  Suspended = "suspended",
  UnavailableUpdate = "unavailable-update",
  Ready = "ready",
  ReadyUpdate = "ready-update",
  OutdatedUpdate = "outdated-update",
}

export declare enum ExchangeWalletKycStatus {
  Done = "done",
  /**
   * Wallet needs to request KYC status.
   */
  LegiInit = "legi-init",
  /**
   * User requires KYC or AML.
   */
  Legi = "legi",
}

export interface OperationErrorInfo {
  error: TalerErrorDetail;
}

export interface ForcedDenomSel {
  denoms: {
    value: AmountString;
    count: number;
  }[];
}

export interface AcceptWithdrawalResponse {
  confirmTransferUrl?: string;
  transactionId: TransactionIdStr;
}

/**
 * Result of a prepare pay operation.
 */
export type PreparePayResult =
  | PreparePayResultInsufficientBalance
  | PreparePayResultAlreadyConfirmed
  | PreparePayResultPaymentPossible;

export interface PreparePayResultInsufficientBalance {
  status: PreparePayResultType.InsufficientBalance;
  transactionId: TransactionIdStr;
  /**
   * Scopes involved in this transaction.
   *
   * For the insufficient balance response, contains scopes
   * of *possible* payment providers.
   */
  scopes: ScopeInfo[];
  contractTerms: MerchantContractTermsV0;
  amountRaw: AmountString;
  talerUri: string;
  balanceDetails: PaymentInsufficientBalanceDetails;
}

export interface MerchantContractTermsV0 extends MerchantContractTermsCommon {
  version?: 0;
  amount: AmountString;
  max_fee: AmountString;
}

/**
 * Contract terms from a merchant.
 * FIXME: Add type field!
 */
interface MerchantContractTermsCommon {
  h_wire: string;
  auto_refund?: TalerProtocolDuration;
  wire_method: string;
  summary: string;
  summary_i18n?: InternationalizedString;
  order_id: string;
  nonce: string;
  pay_deadline: TalerProtocolTimestamp;
  merchant: MerchantInfo;
  merchant_pub: string;
  delivery_date?: TalerProtocolTimestamp;
  delivery_location?: Location;
  exchanges: Exchange[];
  products?: Product[];
  refund_deadline: TalerProtocolTimestamp;
  wire_transfer_deadline: TalerProtocolTimestamp;
  timestamp: TalerProtocolTimestamp;
  merchant_base_url: string;
  fulfillment_url?: string;
  public_reorder_url?: string;
  fulfillment_message?: string;
  fulfillment_message_i18n?: InternationalizedString;
  extra?: any;
  minimum_age?: Integer;
}

/**
 * Detailed reason for why the wallet's balance is insufficient.
 */
export interface PaymentInsufficientBalanceDetails {
  /**
   * Amount requested by the merchant.
   */
  amountRequested: AmountString;
  /**
   * Wire method for the requested payment, only applicable
   * for merchant payments.
   */
  wireMethod?: string | undefined;
  /**
   * Hint as to why the balance is insufficient.
   *
   * If this hint is not provided, the balance hints of
   * the individual exchanges should be shown, as the overall
   * reason might be a combination of the reasons for different exchanges.
   */
  causeHint?: InsufficientBalanceHint;
  /**
   * Balance of type "available" (see balance.ts for definition).
   */
  balanceAvailable: AmountString;
  /**
   * Balance of type "material" (see balance.ts for definition).
   */
  balanceMaterial: AmountString;
  /**
   * Balance of type "age-acceptable" (see balance.ts for definition).
   */
  balanceAgeAcceptable: AmountString;
  /**
   * Balance of type "merchant-acceptable" (see balance.ts for definition).
   */
  balanceReceiverAcceptable: AmountString;
  /**
   * Balance of type "merchant-depositable" (see balance.ts for definition).
   */
  balanceReceiverDepositable: AmountString;
  balanceExchangeDepositable: AmountString;
  /**
   * Maximum effective amount that the wallet can spend,
   * when all fees are paid by the wallet.
   */
  maxEffectiveSpendAmount: AmountString;
  perExchange: {
    [url: string]: {
      balanceAvailable: AmountString;
      balanceMaterial: AmountString;
      balanceExchangeDepositable: AmountString;
      balanceAgeAcceptable: AmountString;
      balanceReceiverAcceptable: AmountString;
      balanceReceiverDepositable: AmountString;
      maxEffectiveSpendAmount: AmountString;
      /**
       * Exchange doesn't have global fees configured for the relevant year,
       * p2p payments aren't possible.
       *
       * @deprecated (2025-02-18) use causeHint instead
       */
      missingGlobalFees: boolean;
      /**
       * Hint that UIs should show to explain the insufficient
       * balance.
       */
      causeHint?: InsufficientBalanceHint | undefined;
    };
  };
}

export declare enum InsufficientBalanceHint {
  /**
   *  Merchant doesn't accept money from exchange(s) that the wallet supports.
   */
  MerchantAcceptInsufficient = "merchant-accept-insufficient",
  /**
   * Merchant accepts funds from a matching exchange, but the funds can't be
   * deposited with the wire method.
   */
  MerchantDepositInsufficient = "merchant-deposit-insufficient",
  /**
   * While in principle the balance is sufficient,
   * the age restriction on coins causes the spendable
   * balance to be insufficient.
   */
  AgeRestricted = "age-restricted",
  /**
   * Wallet has enough available funds,
   * but the material funds are insufficient. Usually because there is a
   * pending refresh operation.
   */
  WalletBalanceMaterialInsufficient = "wallet-balance-material-insufficient",
  /**
   * The wallet simply doesn't have enough available funds.
   * This is the "obvious" case of insufficient balance.
   */
  WalletBalanceAvailableInsufficient = "wallet-balance-available-insufficient",
  /**
   * Exchange is missing the global fee configuration, thus fees are unknown
   * and funds from this exchange can't be used for p2p payments.
   */
  ExchangeMissingGlobalFees = "exchange-missing-global-fees",
  /**
   * Even though the balance looks sufficient for the instructed amount,
   * the fees can be covered by neither the merchant nor the remaining wallet
   * balance.
   */
  FeesNotCovered = "fees-not-covered",
}

export interface PreparePayResultAlreadyConfirmed {
  status: PreparePayResultType.AlreadyConfirmed;
  transactionId: TransactionIdStr;
  contractTerms: MerchantContractTermsV0;
  paid: boolean;
  amountRaw: AmountString;
  amountEffective: AmountString | undefined;
  /**
   * Scopes involved in this transaction.
   */
  scopes: ScopeInfo[];
  contractTermsHash: string;
  talerUri: string;
}

/**
 * Payment is possible.
 */
export interface PreparePayResultPaymentPossible {
  status: PreparePayResultType.PaymentPossible;
  transactionId: TransactionIdStr;
  contractTerms: MerchantContractTermsV0;
  /**
   * Scopes involved in this transaction.
   */
  scopes: ScopeInfo[];
  amountRaw: AmountString;
  amountEffective: AmountString;
  /**
   * FIXME: Unclear why this is needed.  Remove?
   */
  contractTermsHash: string;
  /**
   * FIXME: Unclear why this is needed!  Remove?
   */
  talerUri: string;
}

/**
 * Forced coin selection for deposits/payments.
 */
export interface ForcedCoinSel {
  coins: {
    value: AmountString;
    contribution: AmountString;
  }[];
}

export interface AddExchangeRequest {
  exchangeBaseUrl: string;
  ephemeral?: boolean;
  /**
   * @deprecated use a separate API call to start a forced exchange update instead
   */
  forceUpdate?: boolean;
}

export interface WalletBankAccountInfo {
  bankAccountId: string;
  paytoUri: string;
  /**
   * Did we previously complete a KYC process for this bank account?
   */
  kycCompleted: boolean;
  /**
   * Currencies supported by the bank, if known.
   */
  currencies: string[] | undefined;
  label: string | undefined;
}

export interface AcceptExchangeTosRequest {
  exchangeBaseUrl: string;
}

export interface WireTypeDetails {
  paymentTargetType: string;
  /**
   * Allowed hostnames for the deposit payto URI.
   * Only applicable to x-taler-bank.
   */
  talerBankHostnames?: string[];
}

export interface CheckDepositRequest {
  /**
   * Payto URI to identify the (bank) account that the exchange will wire
   * the money to.
   */
  depositPaytoUri: string;
  /**
   * Amount that should be deposited.
   *
   * Raw amount, fees will be added on top.
   */
  amount: AmountString;
  /**
   * Restrict the deposit to a certain scope.
   */
  restrictScope?: ScopeInfo;
  /**
   * ID provided by the client to cancel the request.
   *
   * If the same request is made again with the same clientCancellationId,
   * all previous requests are cancelled.
   *
   * The cancelled request will receive an error response with
   * an error code that indicates the cancellation.
   *
   * The cancellation is best-effort, responses might still arrive.
   */
  clientCancellationId?: string;
}

export interface CheckDepositResponse {
  totalDepositCost: AmountString;
  effectiveDepositAmount: AmountString;
  fees: DepositGroupFees;
  kycSoftLimit?: AmountString;
  kycHardLimit?: AmountString;
  /**
   * Base URL of exchanges that would likely require soft KYC.
   */
  kycExchanges?: string[];
}

export interface DepositGroupFees {
  coin: AmountString;
  wire: AmountString;
  refresh: AmountString;
}

export interface BackupRecovery {
  walletRootPriv: string;
  providers: {
    name: string;
    url: string;
  }[];
}

export interface CheckPeerPushDebitRequest {
  /**
   * Preferred exchange to use for the p2p payment.
   */
  exchangeBaseUrl?: string;
  /**
   * Instructed amount.
   *
   * FIXME: Allow specifying the instructed amount type.
   */
  amount: AmountString;
  /**
   * Restrict the scope of funds that can be spent via the given
   * scope info.
   */
  restrictScope?: ScopeInfo;
  /**
   * ID provided by the client to cancel the request.
   *
   * If the same request is made again with the same clientCancellationId,
   * all previous requests are cancelled.
   *
   * The cancelled request will receive an error response with
   * an error code that indicates the cancellation.
   *
   * The cancellation is best-effort, responses might still arrive.
   */
  clientCancellationId?: string;
}

export interface CheckPeerPushDebitOkResponse {
  type: "ok";
  amountRaw: AmountString;
  amountEffective: AmountString;
  /**
   * Exchange base URL.
   */
  exchangeBaseUrl: string;
  /**
   * Maximum expiration date, based on how close the coins
   * used for the payment are to expiry.
   *
   * The value is based on when the wallet would typically
   * automatically refresh the coins on its own, leaving enough
   * time to get a refund for the push payment and refresh the
   * coin.
   */
  maxExpirationDate: TalerProtocolTimestamp;
}

/**
 * Contract terms between two wallets (as opposed to a merchant and wallet).
 */
export interface PeerContractTerms {
  amount: AmountString;
  summary: string;
  purse_expiration: TalerProtocolTimestamp;
}

export interface WithdrawTestBalanceResult {
  /**
   * Transaction ID of the newly created withdrawal transaction.
   */
  transactionId: TransactionIdStr;
  /**
   * Account of the user registered for the withdrawal.
   */
  accountPaytoUri: string;
}