-
Notifications
You must be signed in to change notification settings - Fork 302
Expand file tree
/
Copy pathiWallets.ts
More file actions
294 lines (264 loc) · 8.16 KB
/
iWallets.ts
File metadata and controls
294 lines (264 loc) · 8.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
import * as t from 'io-ts';
import { IRequestTracer } from '../../api';
import { KeychainsTriplet, LightningKeychainsTriplet } from '../baseCoin';
import { Keychain } from '../keychain';
import { IWallet, PaginationOptions, WalletShare } from './iWallet';
import { Wallet } from './wallet';
export interface WalletWithKeychains extends KeychainsTriplet {
responseType: 'WalletWithKeychains';
wallet: IWallet;
warning?: string;
encryptedWalletPassphrase?: string;
}
export interface LightningWalletWithKeychains extends LightningKeychainsTriplet {
responseType: 'LightningWalletWithKeychains';
wallet: IWallet;
warning?: string;
encryptedWalletPassphrase?: string;
}
export interface GoAccountWalletWithUserKeychain {
responseType: 'GoAccountWalletWithUserKeychain';
wallet: IWallet;
userKeychain: Keychain;
warning?: string;
encryptedWalletPassphrase?: string;
}
export interface GetWalletOptions {
allTokens?: boolean;
reqId?: IRequestTracer;
id?: string;
includeBalance?: boolean;
}
export interface GenerateBaseMpcWalletOptions {
multisigType: 'tss';
label: string;
enterprise: string;
walletVersion?: number;
}
export interface GenerateMpcWalletOptions extends GenerateBaseMpcWalletOptions {
passphrase: string;
originalPasscodeEncryptionCode?: string;
}
export interface GenerateSMCMpcWalletOptions extends GenerateBaseMpcWalletOptions {
bitgoKeyId: string;
commonKeychain: string;
coldDerivationSeed?: string;
}
export interface GenerateWalletOptions {
label?: string;
passphrase?: string;
userKey?: string;
backupXpub?: string;
backupXpubProvider?: string;
passcodeEncryptionCode?: string;
enterprise?: string;
disableTransactionNotifications?: boolean;
gasPrice?: number;
eip1559?: {
maxFeePerGas: string;
maxPriorityFeePerGas: string;
};
walletVersion?: number;
disableKRSEmail?: boolean;
krsSpecific?: {
[index: string]: boolean | string | number;
};
coldDerivationSeed?: string;
rootPrivateKey?: string;
multisigType?: 'onchain' | 'tss' | 'blsdkg';
isDistributedCustody?: boolean;
bitgoKeyId?: string;
commonKeychain?: string;
type?: 'hot' | 'cold' | 'custodial' | 'trading';
subType?: 'lightningCustody' | 'lightningSelfCustody';
evmKeyRingReferenceWalletId?: string;
}
export const GenerateLightningWalletOptionsCodec = t.intersection(
[
t.strict({
label: t.string,
passphrase: t.string,
enterprise: t.string,
passcodeEncryptionCode: t.string,
subType: t.union([t.literal('lightningCustody'), t.literal('lightningSelfCustody')]),
}),
t.partial({
lightningProvider: t.union([t.literal('amboss'), t.literal('voltage')]),
}),
],
'GenerateLightningWalletOptions'
);
export type GenerateLightningWalletOptions = t.TypeOf<typeof GenerateLightningWalletOptionsCodec>;
export const GenerateGoAccountWalletOptionsCodec = t.strict(
{
label: t.string,
passphrase: t.string,
enterprise: t.string,
passcodeEncryptionCode: t.string,
type: t.literal('trading'),
},
'GenerateGoAccountWalletOptions'
);
export type GenerateGoAccountWalletOptions = t.TypeOf<typeof GenerateGoAccountWalletOptionsCodec>;
export interface GetWalletByAddressOptions {
address?: string;
reqId?: IRequestTracer;
}
export interface UpdateShareOptions {
walletShareId?: string;
state?: string;
encryptedPrv?: string;
keyId?: string;
signature?: string;
payload?: string;
pub?: string;
/**
* Optional WebAuthn PRF-based encryption info.
* When provided, the wallet private key is additionally encrypted with the
* PRF-derived passphrase so the server can store a WebAuthn-protected copy.
* The passphrase itself is never sent to the server.
*/
webauthnInfo?: {
otpDeviceId: string;
prfSalt: string;
encryptedPrv: string;
};
}
export interface AcceptShareOptions {
overrideEncryptedPrv?: string;
walletShareId?: string;
userPassword?: string;
newWalletPassphrase?: string;
webauthnInfo?: AcceptShareWebauthnInfo;
}
export interface AcceptShareWebauthnInfo {
otpDeviceId: string;
prfSalt: string;
passphrase: string;
}
export interface BulkAcceptShareOptions {
walletShareIds: string[];
userLoginPassword: string;
newWalletPassphrase?: string;
webauthnInfo?: AcceptShareWebauthnInfo;
}
export interface AcceptShareOptionsRequest {
walletShareId: string;
encryptedPrv: string;
/**
* The public associated to the encrypted private key.
* Required for userMultiKeyRotationRequired shares.
*/
pub?: string;
/**
* Optional WebAuthn PRF-based encryption info.
* When provided, the wallet private key is additionally encrypted with the
* PRF-derived passphrase so the server can store a WebAuthn-protected copy.
* The passphrase itself is never sent to the server.
*/
webauthnInfo?: {
otpDeviceId: string;
prfSalt: string;
encryptedPrv: string;
};
}
export interface BulkUpdateWalletShareOptions {
shares: {
walletShareId: string;
status: 'accept' | 'reject';
}[];
userLoginPassword?: string;
newWalletPassphrase?: string;
}
export interface BulkUpdateWalletShareOptionsRequest {
walletShareId: string;
encryptedPrv?: string;
status: 'accept' | 'reject';
keyId?: string;
signature?: string;
payload?: string;
pub?: string;
}
export interface BulkUpdateWalletShareResponse {
acceptedWalletShares: string[];
rejectedWalletShares: string[];
walletShareUpdateErrors: {
walletShareId: string;
reason: string;
}[];
}
export interface AddWalletOptions {
coinSpecific?: any;
enterprise?: string;
isCold?: IsCold;
isCustodial?: IsCustodial;
keys?: string[];
keySignatures?: KeySignatures;
label: string;
multisigType?: 'onchain' | 'tss' | 'blsdkg';
address?: string;
m?: number;
n?: number;
tags?: string[];
type?: string;
walletVersion?: number;
eip1559?: Eip1559;
clientFlags?: string[];
// Additional params needed for xrp
rootPub?: string;
// In XRP, XLM and CSPR this private key is used only for wallet creation purposes,
// once the wallet is initialized then we update its weight to 0 making it an invalid key.
// https://www.stellar.org/developers/guides/concepts/multi-sig.html#additional-signing-keys
rootPrivateKey?: string;
initializationTxs?: any;
disableTransactionNotifications?: boolean;
gasPrice?: number;
evmKeyRingReferenceWalletId?: string;
}
type KeySignatures = {
backup?: string;
bitgo?: string;
};
/** @deprecated */
type IsCold = boolean;
/** @deprecated */
type IsCustodial = boolean;
type Eip1559 = {
maxPriorityFeePerGas: string;
maxFeePerGas: string;
};
export interface ListWalletOptions extends PaginationOptions {
skip?: number;
getbalances?: boolean;
allTokens?: boolean;
skipReceiveAddress?: boolean; // If skipReceiveAddress is set to true, the receiveAddress property will not be returned in the wallet object.
}
export interface WalletShares {
incoming: WalletShare[]; // WalletShares that the user has to accept
outgoing: WalletShare[]; // WalletShares that the user has created
}
export interface AcceptShareResponse {
walletShareId: string;
}
export interface BulkAcceptShareResponse {
acceptedWalletShares: AcceptShareResponse[];
}
export interface IWallets {
get(params?: GetWalletOptions): Promise<Wallet>;
list(params?: ListWalletOptions): Promise<{ wallets: IWallet[] }>;
add(params?: AddWalletOptions): Promise<any>;
generateWallet(
params?: GenerateWalletOptions
): Promise<WalletWithKeychains | LightningWalletWithKeychains | GoAccountWalletWithUserKeychain>;
listShares(params?: Record<string, unknown>): Promise<any>;
getShare(params?: { walletShareId?: string }): Promise<any>;
updateShare(params?: UpdateShareOptions): Promise<any>;
resendShareInvite(params?: { walletShareId?: string }): Promise<any>;
cancelShare(params?: { walletShareId?: string }): Promise<any>;
acceptShare(params?: AcceptShareOptions): Promise<any>;
getWallet(params?: GetWalletOptions): Promise<IWallet>;
getWalletByAddress(params?: GetWalletByAddressOptions): Promise<IWallet>;
getTotalBalances(params?: Record<string, never>): Promise<any>;
bulkAcceptShare(params: BulkAcceptShareOptions): Promise<BulkAcceptShareResponse>;
listSharesV2(): Promise<WalletShares>;
}