This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const f = async (param, callback=false) => { | |
try { | |
const data = await request.get(url); | |
if(callback) callback(null, data); // If callback, then call it | |
return data; // Then return data, it returns as a promise.resolve automatically | |
} catch(err) { | |
if(callback) callback(err); // If callback, then call it | |
throw err; // Then throw, it returns promise.reject automatically | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const keyHash = (params) => { | |
let hash = ''; | |
_.each(params, (val, key) => { | |
hash+=`${key}:${val}`; | |
}); | |
return hash; | |
} | |
const execQueryCached = async (params) => { | |
const hash = keyHash(params); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const keyHash = (params) => { | |
let hash = ''; | |
_.each(params, (val, key) => { | |
hash+=`${key}:${val}`; | |
}); | |
return hash; | |
} | |
const genericRead = async (params, callback = false) => { | |
const hash = keyHash(method, params); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const secureRandom = require('secure-random'); | |
const bip39 = require('bip39'); | |
const hdkey = require('hdkey'); | |
const ripemd160 = require('ripemd160'); | |
const sha256 = require('js-sha256'); | |
const bitcoin = require("bitcoinjs-lib") | |
const SEED = bip39.generateMnemonic(256, secureRandom.randomBuffer, bip39.wordlists.english); //generates string | |
console.log(SEED); | |
const seed = bip39.mnemonicToSeedSync(SEED); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const auth = () => { | |
let token; | |
if (secrets.length > 0) { | |
const idx = Math.floor(Math.random() * secrets.length); | |
token = jwt.sign({ key: secrets[idx].API_KEY, nonce: moment().valueOf() }, secrets[idx].API_SECRET); | |
} else { | |
token = jwt.sign({ key: API_KEY, nonce: moment().valueOf() }, API_SECRET); | |
} | |
return { 'Authorization': `bearer ${token}`, 'Content-Type': 'application/json' }; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity 0.4.18; | |
interface tokenRecipient {function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external;} | |
contract owned { | |
address public owner; | |
function owned() internal { | |
owner = msg.sender; | |
} |