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

API v1/wallet/owner/retrieve_outputs does not return unspent output when tx_id is specified #2637

Closed
JacobPlaster opened this issue Feb 28, 2019 · 10 comments

Comments

@JacobPlaster
Copy link

JacobPlaster commented Feb 28, 2019

Describe the bug
The retrieve outputs endpoint does not return the spent outputs when both show_spent and tx_id are set as query parameters.

i.e http://127.0.0.1:3420/v1/wallet/owner/retrieve_outputs?refresh&show_spent&tx_id=0

To Reproduce
Steps to reproduce the behavior:

  1. Run start owner wallet API
  2. Request to retreive a spent output using its id http://127.0.0.1:3420//v1/wallet/owner/retrieve_outputs?refresh&show_spent&tx_id=0
  3. Expect: so see the output
  4. Actual: see empty array

Relevant Information
When retreiving outputs without sepcifying the tx_id but with show_spent then the output with id=0 exists in the array of all outputs.
Also if the output is unspent, then the above url works fine.

Desktop (please complete the following information):

  • OS: Ubuntu 18.04.2 LTS
  • Version: grin 1.0.1 & 1.0.2
@garyyu
Copy link
Contributor

garyyu commented Feb 28, 2019

I can't reproduce your reported problem on my wallet, my current version is 1.0.2 but I don't want to back to older version.
Could you upgrade your version and test again?

@JacobPlaster
Copy link
Author

JacobPlaster commented Feb 28, 2019

@garyyu yeah sure, bare with me, thanks for the quick reply

@JacobPlaster
Copy link
Author

Im still receiving this problem on version 1.0.2 @garyyu. Make sure that when attempting to reproduce you use the id of a spent output. The api works perfectly fine with an unspent output

@JacobPlaster
Copy link
Author

JacobPlaster commented Feb 28, 2019

also the parameter must be tx_id and not id. Using id just returns all outputs. I mention this explicity because in the docs it says to use id=[number] which seems incorrect

@garyyu
Copy link
Contributor

garyyu commented Mar 1, 2019

@JacobPlaster

Make sure that when attempting to reproduce you use the id of a spent output. The api works perfectly fine with an unspent output

I understand your "problem" now. In current version, that's a designed behavior.

When an output is spent, it became a input for a new UTXO, and that spent output is listed as the "spent output" in that spending tx_id, instead of the old tx_id.

Now I'm thinking whether it's a good idea to add an additional field for example old_tx_id to record that.

Using id just returns all outputs. I mention this explicity because in the docs it says to use id=[number] which seems incorrect

I suppose only tx_id=x can be used, as described in wallet API doc. No id=x parameter for this API.

@JacobPlaster
Copy link
Author

Ahhh I see, that makes complete sense @garyyu. Thanks for the detailed description and a way to include the old tx values would definitely be sufficient.

So the wider problem is that I need to extract a numerical number of confirmations of the given transaction. The /v1/wallet/owner/retrieve_outputs?refresh&show_spent&tx_id=0 includes the height of the output and combining this with http://127.0.0.1:3413/v1/status to geth the current height of the node we can work out the numerical number of confirmations. Since the problem that I have stated above this method begins to fail once the output is spent.

My quesitons is: do you know if there is a better or alternative way to get a numerical count for confirmations?

@garyyu
Copy link
Contributor

garyyu commented Mar 1, 2019

btw, please PM me at Gitter :-) @garyyu
https://gitter.im/grin_community/support

do you know if there is a better or alternative way to get a numerical count for confirmations?

I propose you read https://github.com/mimblewimble/docs/wiki/Wallet-API-Guide#transactions--outputs-confirmation-query

@zl03jsj
Copy link

zl03jsj commented Apr 25, 2019

hi, @garyyu
I got the same problem as the brother @JacobPlaster
have you found a approach to get confirmation number, if the 'output' has already been spent as a input within another transaction..

@JacobPlaster
Copy link
Author

Hi @zl03jsj,

Me and @garyyu continued to discus this problem using the grin support channel. Although this is not ideal, once the output has been spent it is currently impossible to calculate the confirmations because that output no longer exists on the node but you can still safely assume that the transaction has been confirmed due to a newer unspent output existing.

So the logic for this could be as follows: calculate confirmations using unspent output height. If this does not exist then check the newly created outputs (that have a higher id than the previous). If one exists then we can assume that the output has been confirmed. The only problem I still have with this is that we still cant get a numerical number to represent 'confirmations'.

@garyyu could you provide an insight on this? I see that the feature updaet mimblewimble/grin-wallet#9 to solve this problem was closed?

@zl03jsj
Copy link

zl03jsj commented Apr 27, 2019

very appreciate for your reply @JacobPlaster.

yes, what you said is a way to detect weather a transaction is confirmed or not
how a bout use the owner-wallet-api: /v1/wallet/owner/retrieve_txs?refresh&id=x
i see there is a 'confirmed' member in the response. would that be ok?

and it would be better to get a way to get a transaction's 'confirmations'
even all the 'outputs' of the transaction had been spent..
it is a business requirements..

thanks again.. (:-

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