Closed tuloski closed 6 years ago
The raw rippled API definitely supports it, though I'm not sure about RippleAPI
Thanks. But I'm almost sure it was supported in old versions.
Define old version :) ?
When it was called ripple-lib, before it became rippleAPI, probably up to release 0.13
Yeah, with RippleAPI, they decided to wash over the raw rippled api, with different names/semantics etc. I'm sure there's probably some way you could make use of the connection though.
https://ripple.com/build/rippled-apis/#transaction-streams
You need to subscribe
to the transactions_proposed
stream
I upvote this issue. The subscribe function disappeared on the newer version (right now it's 0.17.x). The ripple-lib library used in Ripple Websocket demo is version 0.11. Also compare it with this working snippet of subscription : http://code.runnable.com/VNyyD5TVKuVs7aZu/ripple-lib-subscribe-for-node-js With this library we can only listen to a ledger event. So it's not a stream, it basically just calls an API everytime a ledger closes.
api.connect().then(() => {
api.getOrderbook(address, orderbook).then(orderbook => {
console.log(JSON.stringify(orderbook, null, 2));
});
});
api.on('ledger', ledger => {
api.getOrderbook(address, orderbook).then(orderbook => {
console.log(JSON.stringify(orderbook, null, 2));
});
});
And unfortunately Ripple makes it clear there is no way to get unvalidated transactions (accounts_proposed
) with this API.
RippleAPI only provides access to validated, immutable transaction data.
@sublimator Do you know "how to subscribe
to the transactions_proposed
stream"? using RippleAPI?
I found the version 0.7.34 has this method: remote.request_subscribe().accounts(data.account,false).request();
. But with 0.17.x, how to do that?
You can subscribe to websocket streams using a library like ws (no ripple-lib required).
Here's an example of a validations
subscription:
https://github.com/wilsonianb/validation-count-reporter/blob/d03f74c20f80da420a291760693cbc5d5bcec9f7/index.js#L102-L156
@wilsonianb Thanks very much!
This will also be available in an upcoming release of ripple-lib; see https://github.com/ripple/ripple-lib/blob/14704ee/docs/index.md#listening-to-streams
Is there a way to subscribe to a server and get a stream of all transactions that are put in the open ledger before the ledger closes? I didn't see anything in the docs.