MCPcopy Create free account
hub / github.com/cernekee/EasyToken / importToken

Method importToken

src/app/easytoken/ImportActivity.java:140–169  ·  view source on GitHub ↗
(String data, boolean decrypt)

Source from the content-addressed store, hash-verified

138 }
139
140 private LibStoken importToken(String data, boolean decrypt) {
141 Uri uri = Uri.parse(data);
142 String path = uri.getPath();
143 boolean isFile = false;
144
145 if (path != null &&
146 ("file".equals(uri.getScheme()) || "content".equals(uri.getScheme()))) {
147 /*
148 * Arguably we shouldn't take file:// URIs from QR codes,
149 * and maybe we should be more careful about what we accept
150 * from other apps too
151 */
152 isFile = true;
153 data = Misc.readStringFromUri(this, uri);
154 if (data == null) {
155 showError(ImportInstructionsFragment.INST_FILE_ERROR, path);
156 return null;
157 }
158 }
159
160 LibStoken lib = new LibStoken();
161 if (lib.importString(data) != LibStoken.SUCCESS ||
162 (decrypt && lib.decryptSeed(null, null) != LibStoken.SUCCESS)) {
163 showError(ImportInstructionsFragment.INST_BAD_TOKEN, isFile ? "" : data);
164 lib.destroy();
165 return null;
166 }
167
168 return lib;
169 }
170
171 private boolean guessDevID(LibStoken lib, String id) {
172 // This checks the devid hash, but on v2 tokens it is only 15 bits and is

Callers 3

handleImportStepMethod · 0.95
onUnlockDoneMethod · 0.95
onConfirmDoneMethod · 0.95

Calls 3

readStringFromUriMethod · 0.95
showErrorMethod · 0.95
destroyMethod · 0.80

Tested by

no test coverage detected