1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#ifndef __sovrin__wallet__included__
#define __sovrin__wallet__included__
#ifdef __cplusplus
extern "C" {
#endif
/// Registers custom wallet implementation.
///
/// It allows library user to provide custom wallet implementation.
///
/// #Params
/// command_handle: Command handle to map callback to caller context.
/// xtype: Wallet type name.
/// create: WalletType create operation handler
/// open: WalletType open operation handler
/// set: Wallet set operation handler
/// get: Wallet get operation handler
/// get_not_expired: Wallet get_not_expired operation handler
/// list: Wallet list operation handler
/// close: Wallet close operation handler
/// delete: WalletType delete operation handler
/// free: Handler that allows to de-allocate strings allocated in caller code
///
/// #Returns
/// Error code
extern sovrin_error_t sovrin_register_wallet_type(sovrin_handle_t command_handle
const char* xtype,
sovrin_error_t (*createFn)(const char* name,
const char* config,
const char* credentials),
sovrin_error_t (*openFn)(const char* name,
const char* config,
const char* runtime_config,
const char* credentials,
sovrin_handle_t* handle),
sovrin_error_t (*setFn)(sovrin_handle_t handle,
const char* key,
const char* value),
sovrin_error_t (*getFn)(sovrin_handle_t handle,
const char* key,
const char *const *value_ptr),
sovrin_error_t (*getNotExiredFn)(sovrin_handle_t handle,
const char* key,
const char *const *value_ptr),
sovrin_error_t (*listFn)(sovrin_handle_t handle,
const char* key,
const char *const *values_json_ptr),
sovrin_error_t (*closeFn)(sovrin_handle_t handle),
sovrin_error_t (*deleteFn)(const char* name,
const char* config,
const char* credentials),
sovrin_error_t (*freeFn)(sovrin_handle_t handle, const char* str)
);
/// Creates a new secure wallet with the given unique name.
///
/// #Params
/// pool_name: Name of the pool that corresponds to this wallet.
/// name: Name of the wallet.
/// xtype(optional): Type of the wallet. Defaults to 'default'.
/// Custom types can be registered with sovrin_register_wallet_type call.
/// config(optional): Wallet configuration json. List of supported keys are defined by wallet type.
/// if NULL, then default config will be used.
/// credentials(optional): Wallet credentials json. List of supported keys are defined by wallet type.
/// if NULL, then default config will be used.
///
/// #Returns
/// Error code
///
/// #Errors
/// Common*
/// Wallet*
extern sovrin_error_t sovrin_create_wallet(sovrin_handle_t command_handle,
const char* pool_name,
const char* name,
const char* xtype,
const char* config,
const char* credentials,
void (*fn)(sovrin_handle_t xcommand_handle, sovrin_error_t err)
);
/// Opens the wallet with specific name.
///
/// Wallet with corresponded name must be previously created with sovrin_create_wallet method.
/// It is impossible to open wallet with the same name more than once.
///
/// #Params
/// name: Name of the wallet.
/// runtime_config (optional): Runtime wallet configuration json. if NULL, then default runtime_config will be used. Example:
/// {
/// "freshnessTime": string (optional), Amount of minutes to consider wallet value as fresh. Defaults to 24*60.
/// ... List of additional supported keys are defined by wallet type.
/// }
/// credentials(optional): Wallet credentials json. List of supported keys are defined by wallet type.
/// if NULL, then default credentials will be used.
///
/// #Returns
/// Handle to opened wallet to use in methods that require wallet access.
///
/// #Errors
/// Common*
/// Wallet*
extern sovrin_error_t sovrin_open_wallet(sovrin_handle_t command_handle,
const char* name,
const char* runtime_config,
const char* credentials,
void (*fn)(sovrin_handle_t xcommand_handle, sovrin_error_t err, sovrin_handle_t handle)
);
/// Closes opened wallet and frees allocated resources.
///
/// #Params
/// handle: wallet handle returned by sovrin_open_wallet.
///
/// #Returns
/// Error code
///
/// #Errors
/// Common*
/// Wallet*
extern sovrin_error_t sovrin_close_wallet(sovrin_handle_t command_handle,
sovrin_handle_t handle,
void (*fn)(sovrin_handle_t xcommand_handle, sovrin_error_t err)
);
/// Deletes created wallet.
///
/// #Params
/// name: Name of the wallet to delete.
/// credentials(optional): Wallet credentials json. List of supported keys are defined by wallet type.
/// if NULL, then default credentials will be used.
///
/// #Returns
/// Error code
///
/// #Errors
/// Common*
/// Wallet*
extern sovrin_error_t sovrin_delete_wallet(sovrin_handle_t command_handle,
const char* name,
const char* credentials,
void (*fn)(sovrin_handle_t xcommand_handle, sovrin_error_t err)
);
/// Sets a seq_no (the corresponding Ledger transaction unique sequence number) for the a value
/// in a secure wallet identified by the given string.
/// The string identifying the value in the wallet is returned when the value is stored in the wallet.
///
/// #Params
/// wallet_handle: wallet handler (created by open_wallet).
/// command_handle: command handle to map callback to user context.
/// wallet_key: unique string identifying the value in the wallet.
/// seq_no: transaction sequence number.
///
/// #Returns
/// Error code
///
/// #Errors
/// Common*
/// Wallet*
extern sovrin_error_t sovrin_wallet_set_seq_no_for_value(sovrin_handle_t command_handle,
sovrin_handle_t wallet_handle,
const char* wallet_key,
sovrin_i32_t seq_no,
void (*fn)(sovrin_handle_t xcommand_handle, sovrin_error_t err)
);
#ifdef __cplusplus
}
#endif
#endif