stellar-lib
stellar-lib copied to clipboard
How to use requestSubscribe to subscribe to account transactions
According to https://www.stellar.org/api/#api-subscribe you can subscribe to transactions for a list of accounts. This works well using plain websockets outside of stellar-lib.
I would expect the library to support something like requestSubscribe({accounts: ["id1", "id2"]}), but that didn't work. Is this functionality already supported but not documented or should I fork and contribute it myself?
We are in the process of overhauling stellar-lib since it is a giant mess. I think it is easier to just use the stellard API for now. That said you can probably subscribe to multiple accounts with stellar-lib but you will need to look through the code to see how.
Thanks for the update @jedmccaleb. Are you overhauling stellar-lib somewhere publicly?
Yeah it will happen here
@andruby Thanks for your interest.
Once you have a remote object that is connected to the network [1] you can set the accounts you are interested in [2] and subscribe to their transactions [3].
remote.account('address goes here');
remote.account('another address goes here');
...
remote.requestSubscribe('transactions', callback);
We are planning to make stellar-lib's interfaces parody stellard's API more closely. As we update stellar-lib we will provide comprehensive documentation and testing.
[1] https://github.com/stellar/stellar-lib/blob/master/docs/GUIDES.md [2] https://github.com/stellar/stellar-lib/blob/master/src/remote.js#L1673 [3] https://github.com/stellar/stellar-lib/blob/master/src/remote.js#L1002
@deckar01 Awesome. Thanks. I will try your code tonight.
Hello. why the result is empty?
ngocleanh: Not sure what you are trying to do?
How to use requestSubscribe to subscribe to account transactions with real-time?