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

Added is_mine property to listtokens return value if token balance is… #930

Merged

Conversation

mxaddict
Copy link
Contributor

@mxaddict mxaddict commented Feb 8, 2022

closes #923

@mxaddict mxaddict force-pushed the add-is-mine-to-listtokens-rpc-command branch from 0595d8c to 8ead11a Compare February 8, 2022 23:12
@aguycalled
Copy link
Member

i think what sakdeniz meant with this request was to filter the entries which are owned by the wallet (independently of the balance). you can check the logic at the minttoken or mintnft rpc commands to see how to check if a token is owned (line 1622 rpcwallet.cpp for example)

@mxaddict
Copy link
Contributor Author

mxaddict commented Feb 9, 2022

I see, should the (mine) param for listtokens be updated as well? Cause that shows tokens that have balance, but might not be owned by the wallet.

@aguycalled
Copy link
Member

yes probably, those tokens can easily be filtered without the current mine just checking for balance > 0 client side

@mxaddict
Copy link
Contributor Author

mxaddict commented Feb 9, 2022

yes probably, those tokens can easily be filtered without the current mine just checking for balance > 0 client side

Alright

@mxaddict
Copy link
Contributor Author

mxaddict commented Feb 9, 2022

@aguycalled I've updated the logic, does this look good?

@aguycalled
Copy link
Member

i would need to test it, but initially it looks to me like it would label as mine tokens which are not owned by the wallet

@navbuilder
Copy link

A new build of 8ead11a has completed succesfully!
Binaries available at https://build.nav.community/binaries/add-is-mine-to-listtokens-rpc-command

@navbuilder
Copy link

A new build of 2d7e434 has completed succesfully!
Binaries available at https://build.nav.community/binaries/add-is-mine-to-listtokens-rpc-command

@mxaddict
Copy link
Contributor Author

mxaddict commented Feb 9, 2022

@aguycalled this seems to be working with my testing but @sakdeniz said he was having issues, I'm still trying to investigate.

@sakdeniz could you let me know what steps you took so I can replicate your issue with this.

@aguycalled
Copy link
Member

from what I read in the code

             // Is this token ours?
             bool fTokenIsMine = true;

isMine is by default yes

             if (!pwalletMain->HaveBLSCTTokenKey(it->second.key))
             {

this block runs only if the wallet does not have the key for the token

                 if (pk.GetG1Element() != it->second.key)
                     fTokenIsMine = false;

wallet compares the stored key with the assigned to the token.

in my opinion it should be false by default and set it to true if the stored key equals the assigned to the token

but giving this opinion just from reading the code

@mxaddict
Copy link
Contributor Author

mxaddict commented Feb 9, 2022

Does this code return true even if the spend key does not own the token/nft?

pwalletMain->HaveBLSCTTokenKey(it->second.key)

@mxaddict
Copy link
Contributor Author

mxaddict commented Feb 9, 2022

If it returns true when spendkey does not own the token or nft, I think we will need to update the logic in mintnft and minttoken as well.

@mxaddict
Copy link
Contributor Author

mxaddict commented Feb 9, 2022

@aguycalled this seems to be working with my testing but @sakdeniz said he was having issues, I'm still trying to investigate.

@sakdeniz could you let me know what steps you took so I can replicate your issue with this.

@sakdeniz I think you might have been running the first build (Which was only checking balance)

@navbuilder
Copy link

A new build of a9cafef has completed succesfully!
Binaries available at https://build.nav.community/binaries/add-is-mine-to-listtokens-rpc-command

Copy link
Contributor

@chasingkirkjufell chasingkirkjufell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested gitian build on windows 10

@chasingkirkjufell
Copy link
Contributor

just wondering, why not add a filter for the rpc instead? like listtokens mine wouldn't that be more straight forward and the output will be clean instead of trying to go through all of them and find the one has is_mine: true

@sakdeniz
Copy link

Tested with latest build, and it works fine.

@navbuilder
Copy link

A new build of fb3804b has completed succesfully!
Binaries available at https://build.nav.community/binaries/add-is-mine-to-listtokens-rpc-command

@mxaddict mxaddict merged commit a4c9382 into navcoin:master Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add is_mine property to listtokens rpc method
5 participants