1 | var fs = require('fs')
|
2 | , path = require('path')
|
3 | , libPubkey = require('../lib/pubkey')
|
4 |
|
5 | function loadPubkey (walletDir, cb) {
|
6 | fs.readFile(path.join(walletDir, 'id_salty.pub'), {encoding: 'utf8'}, function (err, str) {
|
7 | if (err && err.code === 'ENOENT') {
|
8 | return cb(null, null)
|
9 | }
|
10 | if (err) return cb(err)
|
11 | try {
|
12 | var pubkey = libPubkey.parse(str)
|
13 | }
|
14 | catch (e) {
|
15 | return cb(e)
|
16 | }
|
17 | cb(null, pubkey)
|
18 | })
|
19 | }
|
20 |
|
21 | module.exports = loadPubkey |
\ | No newline at end of file |