Created
March 5, 2015 01:56
-
-
Save julianeon/9403e0c21d9be97f3ecd to your computer and use it in GitHub Desktop.
Ripple lib pathfinding example.
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
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