Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var async = require('async');
var assert = require('assert');
var extend = require('extend');
var Amount = require('ripple-lib').Amount;
var Remote = require('ripple-lib').Remote;
var Transaction = require('ripple-lib').Transaction;
var UInt160 = require('ripple-lib').UInt160;
var Server = require('./server').Server;
var path = require("path");
var server = { };
function get_config() {
var cfg = require(__dirname + '/config-example');
// See if the person testing wants to override the configuration by creating a
// file called test/config.js.
try {
cfg = extend({}, cfg, require(__dirname + '/config'));
} catch (e) { }
return cfg;
};
// separated from the currency by a single space.
if (source_currency_strings) {
var sourceCurrencyStrings = source_currency_strings.split(',');
for (var c = 0; c < sourceCurrencyStrings.length; c++) {
// Remove leading and trailing spaces
sourceCurrencyStrings[c] = sourceCurrencyStrings[c].replace(
/(^[ ])|([ ]$)/g, '');
// If there is a space, there should be a valid issuer after the space
if (/ /.test(sourceCurrencyStrings[c])) {
var currencyIssuerArray = sourceCurrencyStrings[c].split(' ');
var currencyObject = {
currency: currencyIssuerArray[0],
issuer: currencyIssuerArray[1]
};
if (validator.isValid(currencyObject.currency, 'Currency')
&& ripple.UInt160.is_valid(currencyObject.issuer)) {
source_currencies.push(currencyObject);
} else {
callback(new InvalidRequestError('Invalid parameter: '
+ 'source_currencies. Must be a list of valid currencies'));
return;
}
} else if (validator.isValid(sourceCurrencyStrings[c], 'Currency')) {
source_currencies.push({currency: sourceCurrencyStrings[c]});
} else {
callback(new InvalidRequestError('Invalid parameter: '
+ 'source_currencies. Must be a list of valid currencies'));
return;
}
}
}
winston.error('invalid base currency issuer: ' + req.body.base.issuer);
res.send(500, { error: 'invalid base currency issuer: ' + req.body.base.issuer });
return;
}
}
// parse trade currency details
var tradeCurr;
if (!req.body.trade.issuer) {
if (req.body.trade.currency === 'XRP') {
tradeCurr = ['XRP'];
} else {
res.send(500, { error: 'must specify issuer for all currencies other than XRP' });
return;
}
} else if (req.body.trade.issuer && ripple.UInt160.is_valid(req.body.trade.issuer)) {
tradeCurr = [req.body.trade.currency.toUpperCase(), req.body.trade.issuer];
} else {
var tradeGatewayAddress = gatewayNameToAddress(req.body.trade.issuer, req.body.trade.currency.toUpperCase());
if (tradeGatewayAddress) {
tradeCurr = [req.body.trade.currency.toUpperCase(), tradeGatewayAddress];
} else {
winston.error('invalid trade currency issuer: ' + req.body.trade.issuer);
res.send(500, { error: 'invalid trade currency issuer: ' + req.body.trade.issuer });
return;
}
}
// parse startTime and endTime
var startTime, endTime;
if (!req.body.startTime && !req.body.endTime) {
var reporter = require('../lib/reporter');
var RL = require('ripple-lib');
var hyperglue = require('hyperglue');
var config = require('../config');
var fs = require('fs');
var contents = fs.readFileSync(__dirname+ '/email.html');
var contents_txt = fs.readFileSync(__dirname+ '/email.txt', 'utf8');
var UInt160 = RL.UInt160;
var scan = function(db,cb) {
db('blob')
.join('campaigns','blob.address','=','campaigns.address','LEFT OUTER')
.where('campaigns.isFunded','=',null)
.orWhere('campaigns.isFunded','=',false)
.andWhere('campaigns.locked','=','') // we ignore already locked users
.select('blob.address','campaigns.locked','blob.email','blob.username','campaigns.start_time','campaigns.last_emailed','campaigns.campaign','campaigns.isFunded')
.then(function(rows) {
cb(rows);
})
.catch(function(e) {
reporter.log("Caught E:", e);
});
}
exports.scan = scan
var checkLedger = function(address,remote,cb) {
#!/usr/bin/node
var Amount = require("ripple-lib").Amount;
var Currency = require("ripple-lib").Currency;
var Remote = require("ripple-lib").Remote;
var Transaction = require("ripple-lib").Transaction;
var UInt160 = require("ripple-lib").UInt160;
var async = require("async");
var extend = require("extend");
var irc = require("irc");
var gateways = require("./config").gateways;
var hotwallets = require("./config").hotwallets;
var irc_config = require("./config").irc_config;
var remote_config = require("./config").remote_config;
// extend(require("ripple-lib/src/js/config"), require("./config"));
var self = this;
self.total_coins = undefined;
self.load_factor = undefined;
var remote;
var _ = require('lodash');
var moment = require('moment');
var UInt160 = require('ripple-lib').UInt160;
var gatewayList = require('./gateways.json');
var path = require('path');
var fs = require('fs');
var assetPath = path.resolve(__dirname + '/gatewayAssets/');
var files = fs.readdirSync(assetPath);
var assets = { };
//prepare assets
files.forEach(function(file) {
var parts = file.split('.');
var gateway = parts.shift();
if (!gateway) return;
if (!assets[gateway]) {
assets[gateway] = [];
function validateOptions(callback) {
if (!ripple.UInt160.is_valid(opts.account)) {
return callback(new Error('Parameter "account" is not a valid Ripple address'));
}
if (!opts.secret) {
return callback(new Error('Parameter "secret" is not a valid Ripple secret'));
}
callback();
};
function parseCurrency (c) {
var currency,
name,
issuer;
if (!c.currency) return;
else {
currency = c.currency.toUpperCase();
if (currency == 'XRP') {
if (c.issuer) return null; //XRP should not have an issuer
return {currency:'XRP'};
}
else if (currency != 'XRP' && !c.issuer) return null; //IOUs must have an issuer
else if (ripple.UInt160.is_valid(c.issuer)) {
issuer = c.issuer;
name = utils.getGatewayName(issuer);
} else {
name = c.issuer;
issuer = utils.gatewayNameToAddress(name, currency);
if (!issuer) return null; //invalid issuer name or address
}
}
return {currency:currency, issuer:issuer, name:name};
}
DI.getFailedTransactions = function(options, callback) {
assert.strictEqual(typeof options, 'object');
assert.strictEqual(typeof options.account, 'string');
assert(ripple.UInt160.is_valid(options.account),
'Specified account is invalid');
this.db('transaction_history')
.where(function() {
var failedQuery = this.where('state', 'failed')
.andWhere('finalized', true)
.andWhere('source_account', options.account);
if (options.type) {
failedQuery.andWhere('type', options.type);
}
if (options.ledger_index_min && options.ledger_index_min !== -1) {
failedQuery.andWhere('ledger', '>=', options.ledger_index_min);
}
#!/usr/bin/node
var async = require('async');
var Remote = require('ripple-lib').Remote;
var Transaction = require('ripple-lib').Transaction;
var UInt160 = require('ripple-lib').UInt160;
var Amount = require('ripple-lib').Amount;
var book_key = function (book) {
return book.taker_pays.currency
+ ":" + book.taker_pays.issuer
+ ":" + book.taker_gets.currency
+ ":" + book.taker_gets.issuer;
};
var book_key_cross = function (book) {
return book.taker_gets.currency
+ ":" + book.taker_gets.issuer
+ ":" + book.taker_pays.currency
+ ":" + book.taker_pays.issuer;
};