/
keystore.go
440 lines (378 loc) · 14.9 KB
/
keystore.go
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
// Code generated by MockGen. DO NOT EDIT.
// Source: keystore/types/types.go
// Package mocks is a generated GoMock package.
package mocks
import (
gomock "github.com/golang/mock/gomock"
ed25519 "github.com/make-os/kit/crypto/ed25519"
types "github.com/make-os/kit/keystore/types"
io "io"
reflect "reflect"
time "time"
)
// MockStoredKey is a mock of StoredKey interface
type MockStoredKey struct {
ctrl *gomock.Controller
recorder *MockStoredKeyMockRecorder
}
// MockStoredKeyMockRecorder is the mock recorder for MockStoredKey
type MockStoredKeyMockRecorder struct {
mock *MockStoredKey
}
// NewMockStoredKey creates a new mock instance
func NewMockStoredKey(ctrl *gomock.Controller) *MockStoredKey {
mock := &MockStoredKey{ctrl: ctrl}
mock.recorder = &MockStoredKeyMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use
func (m *MockStoredKey) EXPECT() *MockStoredKeyMockRecorder {
return m.recorder
}
// GetMeta mocks base method
func (m *MockStoredKey) GetMeta() types.StoredKeyMeta {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetMeta")
ret0, _ := ret[0].(types.StoredKeyMeta)
return ret0
}
// GetMeta indicates an expected call of GetMeta
func (mr *MockStoredKeyMockRecorder) GetMeta() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMeta", reflect.TypeOf((*MockStoredKey)(nil).GetMeta))
}
// GetKey mocks base method
func (m *MockStoredKey) GetKey() *ed25519.Key {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetKey")
ret0, _ := ret[0].(*ed25519.Key)
return ret0
}
// GetKey indicates an expected call of GetKey
func (mr *MockStoredKeyMockRecorder) GetKey() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetKey", reflect.TypeOf((*MockStoredKey)(nil).GetKey))
}
// GetPayload mocks base method
func (m *MockStoredKey) GetPayload() *types.KeyPayload {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetPayload")
ret0, _ := ret[0].(*types.KeyPayload)
return ret0
}
// GetPayload indicates an expected call of GetPayload
func (mr *MockStoredKeyMockRecorder) GetPayload() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPayload", reflect.TypeOf((*MockStoredKey)(nil).GetPayload))
}
// Unlock mocks base method
func (m *MockStoredKey) Unlock(passphrase string) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Unlock", passphrase)
ret0, _ := ret[0].(error)
return ret0
}
// Unlock indicates an expected call of Unlock
func (mr *MockStoredKeyMockRecorder) Unlock(passphrase interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Unlock", reflect.TypeOf((*MockStoredKey)(nil).Unlock), passphrase)
}
// GetFilename mocks base method
func (m *MockStoredKey) GetFilename() string {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetFilename")
ret0, _ := ret[0].(string)
return ret0
}
// GetFilename indicates an expected call of GetFilename
func (mr *MockStoredKeyMockRecorder) GetFilename() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFilename", reflect.TypeOf((*MockStoredKey)(nil).GetFilename))
}
// GetUserAddress mocks base method
func (m *MockStoredKey) GetUserAddress() string {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetUserAddress")
ret0, _ := ret[0].(string)
return ret0
}
// GetUserAddress indicates an expected call of GetUserAddress
func (mr *MockStoredKeyMockRecorder) GetUserAddress() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserAddress", reflect.TypeOf((*MockStoredKey)(nil).GetUserAddress))
}
// GetPushKeyAddress mocks base method
func (m *MockStoredKey) GetPushKeyAddress() string {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetPushKeyAddress")
ret0, _ := ret[0].(string)
return ret0
}
// GetPushKeyAddress indicates an expected call of GetPushKeyAddress
func (mr *MockStoredKeyMockRecorder) GetPushKeyAddress() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPushKeyAddress", reflect.TypeOf((*MockStoredKey)(nil).GetPushKeyAddress))
}
// IsUnprotected mocks base method
func (m *MockStoredKey) IsUnprotected() bool {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IsUnprotected")
ret0, _ := ret[0].(bool)
return ret0
}
// IsUnprotected indicates an expected call of IsUnprotected
func (mr *MockStoredKeyMockRecorder) IsUnprotected() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsUnprotected", reflect.TypeOf((*MockStoredKey)(nil).IsUnprotected))
}
// GetType mocks base method
func (m *MockStoredKey) GetType() types.KeyType {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetType")
ret0, _ := ret[0].(types.KeyType)
return ret0
}
// GetType indicates an expected call of GetType
func (mr *MockStoredKeyMockRecorder) GetType() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetType", reflect.TypeOf((*MockStoredKey)(nil).GetType))
}
// GetUnlockedData mocks base method
func (m *MockStoredKey) GetUnlockedData() []byte {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetUnlockedData")
ret0, _ := ret[0].([]byte)
return ret0
}
// GetUnlockedData indicates an expected call of GetUnlockedData
func (mr *MockStoredKeyMockRecorder) GetUnlockedData() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUnlockedData", reflect.TypeOf((*MockStoredKey)(nil).GetUnlockedData))
}
// GetCreatedAt mocks base method
func (m *MockStoredKey) GetCreatedAt() time.Time {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetCreatedAt")
ret0, _ := ret[0].(time.Time)
return ret0
}
// GetCreatedAt indicates an expected call of GetCreatedAt
func (mr *MockStoredKeyMockRecorder) GetCreatedAt() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCreatedAt", reflect.TypeOf((*MockStoredKey)(nil).GetCreatedAt))
}
// MockKeystore is a mock of Keystore interface
type MockKeystore struct {
ctrl *gomock.Controller
recorder *MockKeystoreMockRecorder
}
// MockKeystoreMockRecorder is the mock recorder for MockKeystore
type MockKeystoreMockRecorder struct {
mock *MockKeystore
}
// NewMockKeystore creates a new mock instance
func NewMockKeystore(ctrl *gomock.Controller) *MockKeystore {
mock := &MockKeystore{ctrl: ctrl}
mock.recorder = &MockKeystoreMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use
func (m *MockKeystore) EXPECT() *MockKeystoreMockRecorder {
return m.recorder
}
// SetOutput mocks base method
func (m *MockKeystore) SetOutput(out io.Writer) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "SetOutput", out)
}
// SetOutput indicates an expected call of SetOutput
func (mr *MockKeystoreMockRecorder) SetOutput(out interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetOutput", reflect.TypeOf((*MockKeystore)(nil).SetOutput), out)
}
// AskForPassword mocks base method
func (m *MockKeystore) AskForPassword(prompt ...string) (string, error) {
m.ctrl.T.Helper()
varargs := []interface{}{}
for _, a := range prompt {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "AskForPassword", varargs...)
ret0, _ := ret[0].(string)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// AskForPassword indicates an expected call of AskForPassword
func (mr *MockKeystoreMockRecorder) AskForPassword(prompt ...interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AskForPassword", reflect.TypeOf((*MockKeystore)(nil).AskForPassword), prompt...)
}
// AskForPasswordOnce mocks base method
func (m *MockKeystore) AskForPasswordOnce(prompt ...string) (string, error) {
m.ctrl.T.Helper()
varargs := []interface{}{}
for _, a := range prompt {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "AskForPasswordOnce", varargs...)
ret0, _ := ret[0].(string)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// AskForPasswordOnce indicates an expected call of AskForPasswordOnce
func (mr *MockKeystoreMockRecorder) AskForPasswordOnce(prompt ...interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AskForPasswordOnce", reflect.TypeOf((*MockKeystore)(nil).AskForPasswordOnce), prompt...)
}
// UnlockKeyUI mocks base method
func (m *MockKeystore) UnlockKeyUI(addressOrIndex, passphrase, promptMsg string) (types.StoredKey, string, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UnlockKeyUI", addressOrIndex, passphrase, promptMsg)
ret0, _ := ret[0].(types.StoredKey)
ret1, _ := ret[1].(string)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// UnlockKeyUI indicates an expected call of UnlockKeyUI
func (mr *MockKeystoreMockRecorder) UnlockKeyUI(addressOrIndex, passphrase, promptMsg interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnlockKeyUI", reflect.TypeOf((*MockKeystore)(nil).UnlockKeyUI), addressOrIndex, passphrase, promptMsg)
}
// UpdateCmd mocks base method
func (m *MockKeystore) UpdateCmd(addressOrIndex, passphrase string) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UpdateCmd", addressOrIndex, passphrase)
ret0, _ := ret[0].(error)
return ret0
}
// UpdateCmd indicates an expected call of UpdateCmd
func (mr *MockKeystoreMockRecorder) UpdateCmd(addressOrIndex, passphrase interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateCmd", reflect.TypeOf((*MockKeystore)(nil).UpdateCmd), addressOrIndex, passphrase)
}
// GetCmd mocks base method
func (m *MockKeystore) GetCmd(addrOrIdx, pass string, showPrivKey bool) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetCmd", addrOrIdx, pass, showPrivKey)
ret0, _ := ret[0].(error)
return ret0
}
// GetCmd indicates an expected call of GetCmd
func (mr *MockKeystoreMockRecorder) GetCmd(addrOrIdx, pass, showPrivKey interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCmd", reflect.TypeOf((*MockKeystore)(nil).GetCmd), addrOrIdx, pass, showPrivKey)
}
// ImportCmd mocks base method
func (m *MockKeystore) ImportCmd(keyfile string, keyType types.KeyType, pass string) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ImportCmd", keyfile, keyType, pass)
ret0, _ := ret[0].(error)
return ret0
}
// ImportCmd indicates an expected call of ImportCmd
func (mr *MockKeystoreMockRecorder) ImportCmd(keyfile, keyType, pass interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ImportCmd", reflect.TypeOf((*MockKeystore)(nil).ImportCmd), keyfile, keyType, pass)
}
// Exist mocks base method
func (m *MockKeystore) Exist(address string) (bool, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Exist", address)
ret0, _ := ret[0].(bool)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Exist indicates an expected call of Exist
func (mr *MockKeystoreMockRecorder) Exist(address interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Exist", reflect.TypeOf((*MockKeystore)(nil).Exist), address)
}
// GetByIndex mocks base method
func (m *MockKeystore) GetByIndex(i int) (types.StoredKey, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetByIndex", i)
ret0, _ := ret[0].(types.StoredKey)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetByIndex indicates an expected call of GetByIndex
func (mr *MockKeystoreMockRecorder) GetByIndex(i interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByIndex", reflect.TypeOf((*MockKeystore)(nil).GetByIndex), i)
}
// GetByIndexOrAddress mocks base method
func (m *MockKeystore) GetByIndexOrAddress(idxOrAddr string) (types.StoredKey, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetByIndexOrAddress", idxOrAddr)
ret0, _ := ret[0].(types.StoredKey)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetByIndexOrAddress indicates an expected call of GetByIndexOrAddress
func (mr *MockKeystoreMockRecorder) GetByIndexOrAddress(idxOrAddr interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByIndexOrAddress", reflect.TypeOf((*MockKeystore)(nil).GetByIndexOrAddress), idxOrAddr)
}
// GetByAddress mocks base method
func (m *MockKeystore) GetByAddress(addr string) (types.StoredKey, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetByAddress", addr)
ret0, _ := ret[0].(types.StoredKey)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetByAddress indicates an expected call of GetByAddress
func (mr *MockKeystoreMockRecorder) GetByAddress(addr interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByAddress", reflect.TypeOf((*MockKeystore)(nil).GetByAddress), addr)
}
// CreateKey mocks base method
func (m *MockKeystore) CreateKey(key *ed25519.Key, keyType types.KeyType, passphrase string) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CreateKey", key, keyType, passphrase)
ret0, _ := ret[0].(error)
return ret0
}
// CreateKey indicates an expected call of CreateKey
func (mr *MockKeystoreMockRecorder) CreateKey(key, keyType, passphrase interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateKey", reflect.TypeOf((*MockKeystore)(nil).CreateKey), key, keyType, passphrase)
}
// CreateCmd mocks base method
func (m *MockKeystore) CreateCmd(keyType types.KeyType, seed int64, passphrase string, nopass bool) (*ed25519.Key, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CreateCmd", keyType, seed, passphrase, nopass)
ret0, _ := ret[0].(*ed25519.Key)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CreateCmd indicates an expected call of CreateCmd
func (mr *MockKeystoreMockRecorder) CreateCmd(keyType, seed, passphrase, nopass interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateCmd", reflect.TypeOf((*MockKeystore)(nil).CreateCmd), keyType, seed, passphrase, nopass)
}
// List mocks base method
func (m *MockKeystore) List() ([]types.StoredKey, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "List")
ret0, _ := ret[0].([]types.StoredKey)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// List indicates an expected call of List
func (mr *MockKeystoreMockRecorder) List() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockKeystore)(nil).List))
}
// ListCmd mocks base method
func (m *MockKeystore) ListCmd(out io.Writer) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ListCmd", out)
ret0, _ := ret[0].(error)
return ret0
}
// ListCmd indicates an expected call of ListCmd
func (mr *MockKeystoreMockRecorder) ListCmd(out interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListCmd", reflect.TypeOf((*MockKeystore)(nil).ListCmd), out)
}