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

[2.6.0] gettxout RPC does not work #156

Closed
ixje opened this issue Jan 25, 2018 · 4 comments
Closed

[2.6.0] gettxout RPC does not work #156

ixje opened this issue Jan 25, 2018 · 4 comments
Labels
help wanted We suggest a careful read at https://docs.neo.org/. However, fell free to further discuss the topic.

Comments

@ixje
Copy link
Contributor

ixje commented Jan 25, 2018

I'm using the host: https://seed1.neo.org:20331
which runs v2.6.0

{
    "jsonrpc": "2.0",
    "id": 3,
    "result": {
        "port": 20333,
        "nonce": 518138340,
        "useragent": "/NEO:2.6.0/"
    }
}

Getting block 730901 from TestNet, I expect the outputs below (ommited some parts of the response for readability) (see also on a block explorer here)

{
  "jsonrpc": "2.0",
  "method": "getblock",
  "params": ["8e47b5a3f25ea286e01cb88fdf6933d8438ee6764ae9e9cfc2a22be90c4ba10d", 1],
  "id": 1
}

# expected
{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "hash": "0x8e47b5a3f25ea286e01cb88fdf6933d8438ee6764ae9e9cfc2a22be90c4ba10d",
        ...
        "index": 730901,
        ...
        "tx": [
            {
                "txid": "0x2f90e1bb81f12bdb9c8c22d6067f6a065d1d2e4911df872c9b69d7e403170a1b",
                "type": "MinerTransaction",
             ...
            },
            {
                "txid": "0x0ff23561c611ccda65470c9a4a5f1be31f2f4f61b98c75d051e1a72e85a302eb",
                "type": "ContractTransaction",
                 ...
                "vout": [
                    {
                        "n": 0,
                        "asset": "0x602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7",
                        "value": "20",
                        "address": "AVTfssLYDp3pTYQRfnsmaEG8vAQh5GQq2K"
                    },
                    {
                        "n": 1,
                        "asset": "0x602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7",
                        "value": "25",
                        "address": "AHYb3ySrHbhzouZ81ZMnCf8c7zYaoDg64x"
                    }
                ],
             ...
            }
        ],
    ...
    }
}

Using gettxout I get a null result.

{
   "jsonrpc": "2.0",
   "method": "gettxout",
   "params": ["0ff23561c611ccda65470c9a4a5f1be31f2f4f61b98c75d051e1a72e85a302eb", 0],
   "id": 1
}
# response
{
    "jsonrpc": "2.0",
    "id": 1,
    "result": null
}

where I according to the documentation should expect:

{
   "jsonrpc": "2.0",
   "id": 1,
   "result": {
                        "n": 0,
                        "asset": "602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7",
                        "value": "20",
                        "address": "AVTfssLYDp3pTYQRfnsmaEG8vAQh5GQq2K"
   }
}
@erikzhang erikzhang added the help wanted We suggest a careful read at https://docs.neo.org/. However, fell free to further discuss the topic. label Jan 25, 2018
@erikzhang
Copy link
Member

The RPC method gettxout returns unspent output only. If it is spent, the mothod returns null.

@ixje
Copy link
Contributor Author

ixje commented Jan 25, 2018

@erikzhang thanks for clarifying. Would it make sense to throw an RpcException like done in some other places? for example here

pseudo code

TransactionOutput  out = Blockchain.Default.GetUnspent(hash, index);
if (out == null) {
   throw new RpcException(-100, "Output already spent");
} else {
   return out.ToJson(index);
}

I can PR the above, or if you wish to keep it as null then I'll update docs.neo.org to elaborate on the return values.

@erikzhang
Copy link
Member

Please update http://docs.neo.org.
Thanks!

Celia18305 pushed a commit to neo-project/docs that referenced this issue Jan 26, 2018
Fix neo-project/neo#156 by clarifying
documentation regarding return values that caused the confusion.
@ixje
Copy link
Contributor Author

ixje commented Mar 8, 2018

Closing because I updated the documentation that clarifies the issue.

@ixje ixje closed this as completed Mar 8, 2018
Thacryba pushed a commit to simplitech/neo that referenced this issue Dec 12, 2019
Thacryba pushed a commit to simplitech/neo that referenced this issue Feb 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted We suggest a careful read at https://docs.neo.org/. However, fell free to further discuss the topic.
Projects
None yet
Development

No branches or pull requests

2 participants