mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-25 06:35:48 +00:00
Update pathfind command arguments
This commit is contained in:
@@ -9,16 +9,18 @@ var extend = require('extend');
|
|||||||
* Only one path find request is allowed per connection, so when another path
|
* Only one path find request is allowed per connection, so when another path
|
||||||
* find request is triggered it will supercede the existing one, making it emit
|
* find request is triggered it will supercede the existing one, making it emit
|
||||||
* the 'end' and 'superceded' events.
|
* the 'end' and 'superceded' events.
|
||||||
|
*
|
||||||
|
* Options:
|
||||||
|
* src_account
|
||||||
|
* dst_account
|
||||||
|
* dst_amount,
|
||||||
|
* src_currencies
|
||||||
*/
|
*/
|
||||||
function PathFind(remote, src_account, dst_account, dst_amount, src_currencies) {
|
|
||||||
|
function PathFind(remote, options) {
|
||||||
EventEmitter.call(this);
|
EventEmitter.call(this);
|
||||||
|
|
||||||
this.remote = remote;
|
this.remote = remote;
|
||||||
|
this.path_options = options;
|
||||||
this.src_account = src_account;
|
|
||||||
this.dst_account = dst_account;
|
|
||||||
this.dst_amount = dst_amount;
|
|
||||||
this.src_currencies = src_currencies;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
util.inherits(PathFind, EventEmitter);
|
util.inherits(PathFind, EventEmitter);
|
||||||
@@ -35,11 +37,7 @@ util.inherits(PathFind, EventEmitter);
|
|||||||
PathFind.prototype.create = function () {
|
PathFind.prototype.create = function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
var req = this.remote.request_path_find_create(this.src_account,
|
var req = this.remote.request_path_find_create(this.path_options, handleInitialPath);
|
||||||
this.dst_account,
|
|
||||||
this.dst_amount,
|
|
||||||
this.src_currencies,
|
|
||||||
handleInitialPath);
|
|
||||||
|
|
||||||
function handleInitialPath(err, msg) {
|
function handleInitialPath(err, msg) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
@@ -1083,15 +1083,20 @@ Remote.prototype.account = function (accountID) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Remote.prototype.path_find = function (src_account, dst_account, dst_amount, src_currencies) {
|
Remote.prototype.path_find = function (src_account, dst_account, dst_amount, src_currencies) {
|
||||||
|
var options;
|
||||||
|
|
||||||
if (typeof src_account === 'object') {
|
if (typeof src_account === 'object') {
|
||||||
var options = src_account;
|
options = src_account;
|
||||||
src_currencies = options.src_currencies;
|
} else {
|
||||||
dst_amount = options.dst_amount;
|
options = {
|
||||||
dst_account = options.dst_account;
|
src_currencies : options.src_currencies,
|
||||||
src_account = options.src_account;
|
dst_amount : options.dst_amount,
|
||||||
|
dst_account : options.dst_account || options.destination || options.to,
|
||||||
|
src_account : options.src_account || options.source || options.from
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var path_find = new PathFind(this, src_account, dst_account, dst_amount, src_currencies);
|
var path_find = new PathFind(this, options);
|
||||||
|
|
||||||
if (this._cur_path_find) {
|
if (this._cur_path_find) {
|
||||||
this._cur_path_find.notify_superceded();
|
this._cur_path_find.notify_superceded();
|
||||||
@@ -1277,6 +1282,10 @@ Remote.prototype.request_ripple_balance = function (account, issuer, currency, l
|
|||||||
Remote.prepare_currencies = function(ci) {
|
Remote.prepare_currencies = function(ci) {
|
||||||
var ci_new = { };
|
var ci_new = { };
|
||||||
|
|
||||||
|
if (typeof ci === 'string') {
|
||||||
|
ci = { currency: ci }
|
||||||
|
}
|
||||||
|
|
||||||
if (ci.hasOwnProperty('issuer')) {
|
if (ci.hasOwnProperty('issuer')) {
|
||||||
ci_new.issuer = UInt160.json_rewrite(ci.issuer);
|
ci_new.issuer = UInt160.json_rewrite(ci.issuer);
|
||||||
}
|
}
|
||||||
@@ -1292,10 +1301,10 @@ Remote.prototype.request_ripple_path_find = function (src_account, dst_account,
|
|||||||
if (typeof src_account === 'object') {
|
if (typeof src_account === 'object') {
|
||||||
var options = src_account;
|
var options = src_account;
|
||||||
callback = dst_account;
|
callback = dst_account;
|
||||||
src_currencies = options.src_currencies;
|
src_currencies = options.src_currencies || options.currencies;
|
||||||
dst_amount = options.dst_amount;
|
dst_amount = options.dst_amount || options.amount;
|
||||||
dst_account = options.dst_account;
|
dst_account = options.dst_account || options.destination || options.to;
|
||||||
src_account = options.src_account;
|
src_account = options.src_account || options.source || options.from;
|
||||||
}
|
}
|
||||||
|
|
||||||
var request = new Request(this, 'ripple_path_find');
|
var request = new Request(this, 'ripple_path_find');
|
||||||
@@ -1317,10 +1326,10 @@ Remote.prototype.request_path_find_create = function (src_account, dst_account,
|
|||||||
if (typeof src_account === 'object') {
|
if (typeof src_account === 'object') {
|
||||||
var options = src_account;
|
var options = src_account;
|
||||||
callback = dst_account;
|
callback = dst_account;
|
||||||
src_currencies = options.src_currencies;
|
src_currencies = options.src_currencies || options.currencies;
|
||||||
dst_amount = options.dst_amount;
|
dst_amount = options.dst_amount || options.amount;
|
||||||
dst_account = options.dst_account;
|
dst_account = options.dst_account || options.destination || options.to;
|
||||||
src_account = options.src_account;
|
src_account = options.src_account || options.source || options.from;
|
||||||
}
|
}
|
||||||
|
|
||||||
var request = new Request(this, 'path_find');
|
var request = new Request(this, 'path_find');
|
||||||
|
|||||||
Reference in New Issue
Block a user