Created
May 20, 2014 17:23
-
-
Save psypersky/26f24e6b4cf6b4a5b117 to your computer and use it in GitHub Desktop.
This file contains 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
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