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

fetch-balance returns a poorly-formatted JSON response in v2. #234

Closed
NotoriousPyro opened this issue Jan 23, 2018 · 5 comments
Closed

fetch-balance returns a poorly-formatted JSON response in v2. #234

NotoriousPyro opened this issue Jan 23, 2018 · 5 comments

Comments

@NotoriousPyro
Copy link

NotoriousPyro commented Jan 23, 2018

Similarly to #226 and #225
When querying fetch-balance via v2, the objects are embedded within another object and causes increased complexity to interface with the API and increased chance to break by having to write extra decoding info.

curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"fetch-balance","params":["MBH5mtwPvNFqMqb6S9HN5hNCG5Wbu8WaCb"],"id":1}' http://127.0.0.1:8820/rpc/v2

{
        "id" : 1,
        "jsonrpc" : "2.0",
        "result" :
        {
                "balance" :
                {
                        "address" : "MBH5mtwPvNFqMqb6S9HN5hNCG5Wbu8WaCb",
                        "confirmed" : 354535699733,
                        "frozen" : 0,
                        "received" : 354535699733,
                        "unspent" : 354535699733
                }
        }
}

This is easier to work with:

{
        "id" : 1,
        "jsonrpc" : "2.0",
        "result" :
        {
                "address" : "MBH5mtwPvNFqMqb6S9HN5hNCG5Wbu8WaCb",
                "confirmed" : 354535699733,
                "frozen" : 0,
                "received" : 354535699733,
                "unspent" : 354535699733
        }
}

@betachen
Copy link
Member

betachen commented Feb 1, 2018

@NotoriousPyro Thanks a lot.
We can released a new version v3 for this, to fix these poorly-formatted.

@NotoriousPyro
Copy link
Author

Hello @betachen,

The problem of releasing v3, is that v2 is already a broken implementation and doesn't do what it was intended to (for backwards compatibility) as v2 is not compatible with v1 responses.

I don't see any improvement in v2, just that the responses have now been placed in new objects.

@NotoriousPyro
Copy link
Author

In fact, on my pool at metaverse.farm I use a combination of v2 and v1 calls because not all my v1 calls can be easily replaced by v2 without more work that I am unwilling to do (as it will break again, with v3)

@betachen
Copy link
Member

Okay, combination v1 and v2 is useable, v3 will be release later, may 0.8.0。
v2 is finished, regarding to the v1 response is not developers friendly.
We will fix these poorly-formatted JSON issue in next API version.

@luozhaohui
Copy link
Contributor

Fixed in APIv3 getbalance

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