{"action":"closed","issue":{"url":"https://api.github.com/repos/bitpay/bitcore-wallet-client/issues/203","labels_url":"https://api.github.com/repos/bitpay/bitcore-wallet-client/issues/203/labels{/name}","comments_url":"https://api.github.com/repos/bitpay/bitcore-wallet-client/issues/203/comments","events_url":"https://api.github.com/repos/bitpay/bitcore-wallet-client/issues/203/events","html_url":"https://github.com/bitpay/bitcore-wallet-client/issues/203","id":123959334,"number":203,"title":"browserify complains about sjcl library could not be resolved in ./lib","user":{"login":"dabura667","id":6586275,"avatar_url":"https://avatars.githubusercontent.com/u/6586275?v=3","gravatar_id":"","url":"https://api.github.com/users/dabura667","html_url":"https://github.com/dabura667","followers_url":"https://api.github.com/users/dabura667/followers","following_url":"https://api.github.com/users/dabura667/following{/other_user}","gists_url":"https://api.github.com/users/dabura667/gists{/gist_id}","starred_url":"https://api.github.com/users/dabura667/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dabura667/subscriptions","organizations_url":"https://api.github.com/users/dabura667/orgs","repos_url":"https://api.github.com/users/dabura667/repos","events_url":"https://api.github.com/users/dabura667/events{/privacy}","received_events_url":"https://api.github.com/users/dabura667/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-27T04:21:33Z","updated_at":"2015-12-27T05:01:58Z","closed_at":"2015-12-27T05:01:58Z","body":"Here are some notes I took while trying to make a browser interface to help support offline key generation for Copay wallets in my organization.\r\n\r\n```javascript\r\n// Note about browserification: It complains about missing sjcl from lib...\r\n// To fix this add sjcl folder in .\\bitcore-wallet-client\\node_modules and create package.json, index.js, and copy sjcl.js (minified) from the main repo.\r\n// Change the package.json manually to have the name sjcl, and reference index.js. \r\n// index.js is just module.exports = require('./sjcl.js')... which should then allow browserify to package sjcl into the browserified version.\r\n\r\n// Generate a new js file for the browser from the modified bwc library.\r\n\r\n// browserify -r bitcore-wallet-client -s Client -o bitcore-wallet-client.js\r\n// uglifyjs bitcore-wallet-client.js -c -m --keep-fnames -o bitcore-wallet-client.min.js\r\n\r\n// Create new offline client\r\nvar myclient = new Client({\r\n  baseUrl: \"http://localhost:8478/bwslololol/api/\",\r\n  verbose: false,\r\n});\r\n\r\n// Create wallet with Mnemonic\r\n// options:\r\n// opts.network || 'livenet', opts.passphrase, opts.language || 'en', opts.account || 0\r\nmyclient.seedFromRandomWithMnemonic({});\r\n\r\n// show mnemonic\r\n//myclient.credentials.mnemonic;\r\n\r\n// Set address type to P2PKH for SINGLE sig. Default is P2SH.\r\nmyclient.credentials.addressType = 'P2PKH';\r\n\r\n// Not needed, but to encrypt the private key.\r\n//myclient.credentials.setPrivateKeyEncryption('password');\r\n\r\n// export without signing capabilities\r\nmyclient.export({noSign:true});\r\n\r\n// bring json to online PC\r\n\r\n// Create new online client\r\nvar onlineClient = new Client({\r\n  baseUrl: \"https://bws.bitpay.com/bws/api/\",\r\n  verbose: false,\r\n});\r\n\r\n// Import the nosign json string\r\nonlineClient.import('json from nosign export');\r\n\r\n// Create the nosign new wallet on BWS\r\nonlineClient.createWallet(\"NAME OF WALLET\", \"NAME OF COPAYER\", 1, 1, {network: 'livenet'}, function(err, secret) {});\r\n\r\n// Encrypt the newly registered wallet json encrypted (Copay requires encrypted json)\r\n// Note: Desktop Copay can only read from file, but mobile can read from copy paste text.\r\nClient.sjcl.encrypt('passwordforimport',onlineClient.export());\r\n```"}}