UNPKG

dogecoin-gatewayd-plugin

Version:

Three unix processes designed to automate the integration between a ripple gateway using gatewayd and a dogecoind server.

55 lines (45 loc) 1.7 kB
// Generated by CoffeeScript 1.7.1 var DogecoinBridge, async; async = require("async"); DogecoinBridge = (function() { function DogecoinBridge(gatewayd, rippleAddress) { this.gatewayd = gatewayd; this.rippleAddress = rippleAddress; } DogecoinBridge.prototype.getDogecoinBridge = function(callback) { return async.waterfall([this._getExternalAccount.bind(this), this._getNewDogecoinAddress.bind(this), this._registerDogeBridge.bind(this)], callback); }; DogecoinBridge.prototype._getExternalAccount = function(callback) { return this.gatewayd.data.models.externalAccounts.find({ where: { uid: this.rippleAddress } }).complete(callback); }; DogecoinBridge.prototype._getNewDogecoinAddress = function(externalAccount, callback) { if (externalAccount) { return callback(null, externalAccount, null); } else { return request.get(this.gatewayd.config.get("dogecoinExpressDomain") + "/v1/getnewaddress").auth("admin", this.gatewayd.config.get("dogecoinExpressApiKey")).end(function(error, response) { if (error) { return callback(error, null, null); } else { return callback(null, null, response.body.address); } }); } }; DogecoinBridge.prototype._registerDogeBridge = function(externalAccount, dogecoinAddress, callback) { if (externalAccount) { return callback(null, externalAccount); } else { return this.gatewayd.data.models.externalAccounts.create({ name: dogecoinAddress, uid: this.rippleAddress, user_id: 1 }).complete(callback); } }; return DogecoinBridge; })(); module.exports = DogecoinBridge;