Blockstream / esplora

Explorer for Bitcoin and Liquid
MIT License
1.01k stars 398 forks source link

/tx/:txid/outspend/:vout returns 200 when :txid doesn't exist #316

Open LLFourn opened 3 years ago

LLFourn commented 3 years ago
 $ curl -v https://blockstream.info/api/tx/0000000000000000000000000000000000000000000000000000000000000000/outspend/0
< HTTP/2 200
< server: nginx
< date: Tue, 01 Jun 2021 00:47:42 GMT
< content-type: application/json
< content-length: 15
< cache-control: public, max-age=10
< access-control-allow-origin: *
< access-control-expose-headers: x-total-results
< via: 1.1 google
< alt-svc: clear
<
* Connection #0 to host blockstream.info left intact
{"spent":false}
cmdruid commented 1 year ago

Just came across this issue as well. It is very misleading and the API should return the normal "Transaction not found" instead of a success message with a json response.

The method is located in rest.rs#L1084 and is missing the following check (which you can see in the next method):

let tx = query
  .lookup_txn(&hash)
  .ok_or_else(|| HttpError::not_found("Transaction not found".to_string()))?;

The method should be making this check instead of returning a default response, because the response implies the transaction exists, when it does not.