X9Developers / XSN

XSN - Stakenet, the first cryptocurrency with Trustless Proof of Stake
https://stakenet.io
MIT License
93 stars 49 forks source link

Wrong results on getaddressutxos command #83

Closed AlexITC closed 5 years ago

AlexITC commented 6 years ago

The getaddressutxos is supposed to return all the utxos for the given address, while playing a bit with the command, it seems to not be accurate.

As a example, look into this:

➜  xsncore-1.0.9 bin/xsn-cli getaddressutxos '{ "addresses": ["XcqpUChZhNkVDgQqFF9U4DdewDGUMWwG53"] }'
[
]

The command says that the given address doesn't have any utxos (see the same in the explorer).

On the other hand, a database tracking the utxos says that it have two non-zero utxos:

xsn_blockchain_2=# select index, value, hex_script, txid from transaction_outputs where spent_on is null and value > 0 and address = 'XcqpUChZhNkVDgQqFF9U4DdewDGUMWwG53';
 index |       value       |                               hex_script                               |                               txid                               
-------+-------------------+------------------------------------------------------------------------+------------------------------------------------------------------
     0 | 0.000035580000000 | 2103f46aecb86ca6f0404f9339e6ff242d82cd36e23612bad62f840986a570ddfd13ac | eabfd68fce47655e076ae589e0b69d80d2be15d31b2941006978c7f57006cd4e
     0 | 0.000044740000000 | 2103f46aecb86ca6f0404f9339e6ff242d82cd36e23612bad62f840986a570ddfd13ac | 0bedf3abb4b388b8205e4f861ae8f82d87285812fa383046989fcde6a736114d
(2 rows)

If I take the txid and the output index to query the RPC API with the gettxout command, it confirms that those two outputs are unspent outputs:

➜  xsncore-1.0.9 bin/xsn-cli gettxout 0bedf3abb4b388b8205e4f861ae8f82d87285812fa383046989fcde6a736114d 0
{
  "bestblock": "ac5dced3d62db5910d32b377c0fe3d8424596a698e11de8baed851f01e818f36",
  "confirmations": 166353,
  "value": 0.00004474,
  "scriptPubKey": {
    "asm": "03f46aecb86ca6f0404f9339e6ff242d82cd36e23612bad62f840986a570ddfd13 OP_CHECKSIG",
    "hex": "2103f46aecb86ca6f0404f9339e6ff242d82cd36e23612bad62f840986a570ddfd13ac",
    "reqSigs": 1,
    "type": "pubkey",
    "addresses": [
      "XcqpUChZhNkVDgQqFF9U4DdewDGUMWwG53"
    ]
  },
  "coinbase": true
}
➜  xsncore-1.0.9 bin/xsn-cli gettxout eabfd68fce47655e076ae589e0b69d80d2be15d31b2941006978c7f57006cd4e 0
{
  "bestblock": "ac5dced3d62db5910d32b377c0fe3d8424596a698e11de8baed851f01e818f36",
  "confirmations": 166359,
  "value": 0.00003558,
  "scriptPubKey": {
    "asm": "03f46aecb86ca6f0404f9339e6ff242d82cd36e23612bad62f840986a570ddfd13 OP_CHECKSIG",
    "hex": "2103f46aecb86ca6f0404f9339e6ff242d82cd36e23612bad62f840986a570ddfd13ac",
    "reqSigs": 1,
    "type": "pubkey",
    "addresses": [
      "XcqpUChZhNkVDgQqFF9U4DdewDGUMWwG53"
    ]
  },
  "coinbase": true
}

This is making difficult to verify that the database utxos are correct.

bwang22 commented 5 years ago

getaddressutxos is no longer available