Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.