Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websocket to subscribe to many addresses #276

Closed
canguruhh opened this issue Mar 20, 2018 · 3 comments
Closed

Websocket to subscribe to many addresses #276

canguruhh opened this issue Mar 20, 2018 · 3 comments

Comments

@canguruhh
Copy link
Member

It would be great to be able to subscribe to many addresses to detect new transactions related to specified addresses.

@baaa
Copy link

baaa commented Aug 14, 2018

#321 could be helpful

@luozhaohui
Copy link
Contributor

luozhaohui commented Aug 22, 2018

This enhancement will be released on v0.8.3 next month.

1. Subscribe to all addresses:

{"event": "subscribe", "channel": "tx", "address":[]}

or

 {"event": "subscribe", "channel": "tx", "address":""}

2. Subscribe to one address:

{"event": "subscribe", "channel": "tx", "address":["MJNo92g6DavpaCZbYjrH45iQ8eAKnLqmms"]}

or

{"event": "subscribe", "channel": "tx", "address":"MJNo92g6DavpaCZbYjrH45iQ8eAKnLqmms"}

3. Subscribe to many addresses:

{"event": "subscribe", "channel": "tx", "address":["MJNo92g6DavpaCZbYjrH45iQ8eAKnLqmms", "MVk2n7kxKor1DqcxBNLLyXFbexq4kZ3rfp"]}

4. Publish information

Add topic to the publish information. The value of "topic" filed can be "all", a address or a list of addresses.

{
    "channel" : "tx",
    "event" : "publish",
    "result" : 
    {
        "hash" : "d0102c0b5c55398eaca7e75780e4c5f7bdd7d79ca3853dbd5ae7e6120cfe9ad6",
        "height" : 0,
        "inputs" : 
        [
            {
                "address" : "tJNo92g6DavpaCZbYjrH45iQ8eAKnLqmms",
                "previous_output" : 
                {
                    "hash" : "414aab9bbb2b7fdad4b80cf7c83ec97d9714114120107c114c9deb033508cb88",
                    "index" : 1
                },
                "script" : "[ 304402201f1b1a3bf217f609ff993a2213b4ef313feec436f27b589443b3526c41fe12ab02201ed05726d6e968893ac6b798e764ca34e4e597d5311641816c66dfe26af3672901 ] [ 0270ea1252af455e5d1ada1dfda9d47387dd0c483ead95f70e08a6379d03962453 ]",
                "sequence" : 4294967295
            }
        ],
        "lock_time" : "0",
        "outputs" : 
        [
            {
                "address" : "t7cFpPtYDSrR4w873wF2zKjbHgsHBUPnGC",
                "attachment" : 
                {
                    "type" : "etp"
                },
                "index" : 0,
                "locked_height_range" : 0,
                "script" : "dup hash160 [ 077fc0219517c6924ffd89a891a6e035d77db544 ] equalverify checksig",
                "value" : 1234
            },
            {
                "address" : "tJNo92g6DavpaCZbYjrH45iQ8eAKnLqmms",
                "attachment" : 
                {
                    "type" : "etp"
                },
                "index" : 1,
                "locked_height_range" : 0,
                "script" : "dup hash160 [ 7d9d74d3ca1f594f3e45416ca9509f77cd550f39 ] equalverify checksig",
                "value" : 79968766
            }
        ],
        "version" : "4"
    },
    "topic" : 
    [
        "tJNo92g6DavpaCZbYjrH45iQ8eAKnLqmms",
        "t7cFpPtYDSrR4w873wF2zKjbHgsHBUPnGC"
    ]
}

@luozhaohui
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants