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

Is there a quick rpc api to get the balance directly? #363

Closed
arch0x opened this issue Oct 9, 2019 · 10 comments
Closed

Is there a quick rpc api to get the balance directly? #363

arch0x opened this issue Oct 9, 2019 · 10 comments
Assignees

Comments

@arch0x
Copy link

arch0x commented Oct 9, 2019

I looked at #227 and looked at ruby's getbalance source code. I found it difficult to get the balance. Is there an easier way?

@Keith-CY
Copy link
Member

Keith-CY commented Oct 9, 2019

There isn't any API to get the balance directly.

But you can use this method to request cells belong to specific lockhash and calculate the balance by summing their capacity.

@arch0x
Copy link
Author

arch0x commented Oct 9, 2019

After loadcells, I still need to if (output_data.nil? || output_data == "0x") && output.type.nil? like ruby ​​to handle these conditions?

@Keith-CY
Copy link
Member

Keith-CY commented Oct 9, 2019

Yes, the cell returned by this method has a field named dataHash whose value is the hash of output_data and if its value equals to EMPTY_DATA_HASH, it's safe to be spent out.

@arch0x
Copy link
Author

arch0x commented Oct 10, 2019

loadCells throws TypeError: The number 32341 should be a bigint or a hex string error, where 32341 is the value of the start parameter I passed in

@ashchan
Copy link
Contributor

ashchan commented Oct 10, 2019

Pass ‘BigInt(32341)’ instead.

@arch0x
Copy link
Author

arch0x commented Oct 11, 2019

I think it is a bug in sdk, see code.

groups[i][0] and groups[i][1] type error.

@arch0x
Copy link
Author

arch0x commented Oct 11, 2019

In the definition of loadCells, the start parameter is number | string. locaCells

@arch0x
Copy link
Author

arch0x commented Oct 11, 2019

I tried to use string to pass start and I only passed the loadHash parameter, which is the above error.

@Keith-CY Keith-CY added the bug Something isn't working label Oct 11, 2019
@Keith-CY Keith-CY removed the bug Something isn't working label Oct 11, 2019
Keith-CY added a commit that referenced this issue Oct 11, 2019
use bigint instead of number in signatures of rpc methods

BREAKING CHANGE: use bigint instead of number in signatures of rpc methods

re #363, fix #365
Keith-CY added a commit that referenced this issue Oct 12, 2019
use bigint instead of number in signatures of rpc methods

BREAKING CHANGE: use bigint instead of number in signatures of rpc methods

re #363, fix #365
@Keith-CY
Copy link
Member

I tried to use string to pass start and I only passed the loadHash parameter, which is the above error.

@nervosnetwork/ckb-sdk-core@v0.22.1 is ready and the signature of loadCells has been updated to accept bigint, please have a try.

Thanks.

@arch0x
Copy link
Author

arch0x commented Nov 8, 2019

The loadCells function works fine.

@ashchan ashchan closed this as completed Nov 8, 2019
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