Skip to content

Instantly share code, notes, and snippets.

@julianeon
Created March 5, 2015 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save julianeon/9403e0c21d9be97f3ecd to your computer and use it in GitHub Desktop.
Save julianeon/9403e0c21d9be97f3ecd to your computer and use it in GitHub Desktop.
Ripple lib pathfinding example.
var ripple = require('ripple-lib');
var remote = new ripple.Remote({
servers: [ 'wss://s1.ripple.com:443' ]
});
var pathFind = function(responseCallback) {
try {
var currency = 'USD';
var amount = ripple.Amount.from_human('0.001 USD')
amount.set_issuer('rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B');
console.log('Pathfinding...');
remote.request_path_find_create('r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59', 'r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59', amount)
.on('success', function(res) {
console.log('success');
console.log(JSON.stringify(res,null,4));
})
.on('path_find_all', function(res) {
console.log(res);
console.log('path_find');
})
.on('close', function(res) {
console.log('Close');
console.log(res);
})
.on('error', function(err) {
console.log(err);
})
.request();
}
catch (e) {
console.log(e);
}
};
remote.connect();
remote.on('connect', function () {
console.log('Connected');
pathFind();
});
remote.on('disconnect', function () {
console.log('Disconnected');
process.kill();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment