stellar-lib icon indicating copy to clipboard operation
stellar-lib copied to clipboard

How to use requestSubscribe to subscribe to account transactions

Open andruby opened this issue 11 years ago • 8 comments

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?

andruby avatar Aug 27 '14 21:08 andruby

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.

jedmccaleb avatar Aug 29 '14 20:08 jedmccaleb

Thanks for the update @jedmccaleb. Are you overhauling stellar-lib somewhere publicly?

andruby avatar Sep 03 '14 08:09 andruby

Yeah it will happen here

jedmccaleb avatar Sep 03 '14 23:09 jedmccaleb

@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 avatar Sep 05 '14 01:09 deckar01

@deckar01 Awesome. Thanks. I will try your code tonight.

andruby avatar Sep 05 '14 08:09 andruby

Hello. why the result is empty?

ngocleanh avatar Oct 04 '14 07:10 ngocleanh

ngocleanh: Not sure what you are trying to do?

jedmccaleb avatar Oct 04 '14 13:10 jedmccaleb

How to use requestSubscribe to subscribe to account transactions with real-time?

ngocleanh avatar Oct 06 '14 03:10 ngocleanh