opensc
NPCI secure-component & UPI Lite / Lite X wallet reimplementation
Loading...
Searching...
No Matches
wallet.h
Go to the documentation of this file.
1#ifndef LITE_WALLET_H
2#define LITE_WALLET_H
3
4#include "lite/env.h"
5#include "lite/vault.h"
6
9
11enum {
14};
15
17enum {
24};
25
27typedef struct {
28 int bound;
30 char ltl[32];
31 char bal[32];
32 char acstatus[8];
34
36typedef struct {
37 double balance;
41
43typedef struct {
44 const char *amount;
45 const char *txn_id;
46 const char *ts;
47 const char *payer_lite_acc;
48 const char *payee_addr;
49 const char *app_id;
50 const char *mobile;
51 const char *device_id;
52} lite_txn;
53
55int lite_onboard(lite_env *env, const char *alias, const char *signed_state_json);
56
58int lite_is_bound(lite_env *env, const char *alias, lite_bind_info *out);
59
61int lite_balance(lite_env *env, const char *alias, lite_balance_info *out);
62
64int lite_sync(lite_env *env, const char *alias, const char *signed_state_json);
65
67int lite_spend(lite_env *env, const char *alias, const lite_txn *txn, int is_credit,
68 char *out, size_t cap);
69
71int lite_unbind(lite_env *env, const char *alias);
72
73#endif
The injected runtime environment (crypto, keystore, store, clock, RNG) the wallet runs against.
Result of lite_balance().
Definition wallet.h:36
double non_spendable
Pending credits not yet spendable.
Definition wallet.h:38
int pending_count
Number of queued PendingTxn entries.
Definition wallet.h:39
double balance
Spendable balance.
Definition wallet.h:37
Result of lite_is_bound().
Definition wallet.h:27
int bound
1 if bound.
Definition wallet.h:28
int sync_required
1 if a spend is pending sync.
Definition wallet.h:29
Everything the wallet needs, injected so tests can pin the clock, RNG and keys.
Definition env.h:26
A spend request. All fields are caller-owned strings.
Definition wallet.h:43
const char * app_id
App package id.
Definition wallet.h:49
const char * device_id
Device id.
Definition wallet.h:51
const char * payee_addr
Payee VPA/address.
Definition wallet.h:48
const char * mobile
Payer mobile number.
Definition wallet.h:50
const char * ts
Transaction timestamp.
Definition wallet.h:46
const char * txn_id
Transaction id.
Definition wallet.h:45
const char * amount
Transaction amount (decimal string).
Definition wallet.h:44
const char * payer_lite_acc
Payer's Lite account number.
Definition wallet.h:47
The NPCICLVAULT codec: an AES-GCM-encrypted JSON doc, separately signed, with tamper-reset.
int lite_balance(lite_env *env, const char *alias, lite_balance_info *out)
Computes spendable/non-spendable balance and pending count into out. LITE_OK or LITE_ERR.
int lite_unbind(lite_env *env, const char *alias)
Removes the device binding: deletes the alias keys and clears the vault record. LITE_OK.
int lite_spend(lite_env *env, const char *alias, const lite_txn *txn, int is_credit, char *out, size_t cap)
Signs a spend, writing {"riskParams":..,"signature":..} JSON to out. Enforces the PendingTxn gate....
int lite_onboard(lite_env *env, const char *alias, const char *signed_state_json)
Establishes vault + spend key + session key, then applies the first signed state blob....
int lite_is_bound(lite_env *env, const char *alias, lite_bind_info *out)
Reports binding status into out. Returns LITE_BIND_YES or LITE_BIND_NO.
@ LITE_BIND_NO
Not bound.
Definition wallet.h:12
@ LITE_BIND_YES
Bound.
Definition wallet.h:13
int lite_sync(lite_env *env, const char *alias, const char *signed_state_json)
Applies a signed state blob: verify, require a newer timestamp, replace state, clear PendingTxn....
@ LITE_SPEND_DECLINED
Limit / balance / ACSTATUS gate failed.
Definition wallet.h:23
@ LITE_SYNC_BAD_SIG
Incoming state signature invalid.
Definition wallet.h:19
@ LITE_SPEND_SYNC_REQUIRED
A prior spend is unsynced (PendingTxn non-empty).
Definition wallet.h:22
@ LITE_SYNC_OK
State applied.
Definition wallet.h:18
@ LITE_SYNC_DEACTIVATED
ACSTATUS=DA; device unbound.
Definition wallet.h:21
@ LITE_SYNC_STALE
Incoming timestamp not strictly newer: the rollback-relevant gate.
Definition wallet.h:20