Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@psypersky
Created May 20, 2014 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psypersky/26f24e6b4cf6b4a5b117 to your computer and use it in GitHub Desktop.
Save psypersky/26f24e6b4cf6b4a5b117 to your computer and use it in GitHub Desktop.
exports.createMoneypots = function(userId, pots, callback) {
//TODO: Implement Eric's Daemon :p
var tasks = pots.map(function(pot) {
return function(callback) {
var key = bitcoin.ECKey.makeRandom();
var privKey = key.toWIF();
var pubKey = key.pub.getAddress().toString();
var active = true;
var fundedUsd = pot.amount;
var btSubscriptionId = pot.subscriptionId;
var tag = pot.name;
db.addMoneyPot(userId, privKey, pubKey, tag, active, fundedUsd, btSubscriptionId, function(err) {
if(err) {
//if (err instanceof Error)
return callback(new Error('Error adding a moneypots to the database for user -> ' + userId + ' \n' + err));
}
callback(null);
});
}
});
async.parallel(tasks, callback);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment