1

I am trying to figure out the Daemon RPC API.

Requesting a block with get_block(), the block header has a field miner_tx_hash.

The block also contains a JSON field miner_tx, which contains the coinbase transaction input "gen" and a single matching output. This I understand.

If I use get_transactions() with the value of miner_tx_hash, it seems to find a transaction, but this transaction seems quite different from miner_tx embedded in the block. The one I get from get_transactions() has many more inputs and outputs etc.

Also, I thought there would be a single miner_tx_hash value in a block, but there seem to be multiple.

Currently, there is no mention of miner_tx_hash as a field in any of the methods in the API docs. If you search the page, some example outputs contain it but no explanation.

So what exactly the miner_tx_hash field in the block, and what is its relation to the miner_tx and other transactions in the block?

1 Answer 1

1

So what exactly the miner_tx_hash field in the block, and what is its relation to the miner_tx and other transactions in the block?

miner_tx_hash is just that - the transaction hash of the miner transaction. The miner transaction is the transaction that pays out the reward for mining the block. The inputs to this tx are type gen as they literally generate new Monero.

If I use get_transactions() with the value of miner_tx_hash, it seems to find a transaction, but this transaction seems quite different from miner_tx embedded in the block. The one I get from get_transactions() has many more inputs and outputs etc.

Perhaps you are calling or parsing incorrectly. Here is a concrete example using testnet:

curl -d '{"jsonrpc":"2.0","id":"0","method":"get_block","params":{"height":1234567}}' \
  http://localhost:28081/json_rpc \
  | jq .result.block_header.miner_tx_hash

Extracts the miner tx hash: c37d119798660baed9ee62b3fc7323f98487b2e9c6a155be843e238e31fdb415

And:

curl -d '{"jsonrpc":"2.0","id":"0","method":"get_block","params":{"height":1234567}}' \
  http://localhost:28081/json_rpc \
  | jq .result.json | jq -r | jq .miner_tx

Will extract the miner tx (form the same result, get_block with height 1234567):

{
  "version": 2,
  "unlock_time": 1234627,
  "vin": [
    {
      "gen": {
        "height": 1234567
      }
    }
  ],
  "vout": [
    {
      "amount": 6059550665332,
      "target": {
        "key": "81fb44f0bbd9e38e467461aed50ded48f2301ee0b0d553a1d0bc5a8a07cd0263"
      }
    }
  ],
  "extra": [
    1, ..., 78
  ],
  "rct_signatures": {
    "type": 0
  }
}

Now using get_transactions with the miner tx hash obtained above:

curl -d '{"txs_hashes":["c37d119798660baed9ee62b3fc7323f98487b2e9c6a155be843e238e31fdb415"],"decode_as_json":true}' \
  http://localhost:28081/get_transactions \
  | jq .txs[0].as_json | jq -r

Yields:

{
  "version": 2, 
  "unlock_time": 1234627, 
  "vin": [ {
      "gen": {
        "height": 1234567
      }
    }
  ], 
  "vout": [ {
      "amount": 6059550665332, 
      "target": {
        "key": "81fb44f0bbd9e38e467461aed50ded48f2301ee0b0d553a1d0bc5a8a07cd0263"
      }
    }
  ], 
  "extra": [ 1, ..., 78
  ], 
  "rct_signatures": {
    "type": 0
  }
}

Identical.

1
  • Thanks, I see you are correct. I guess I got confused somewhere along going through all the txs, txouts, etc. There is only one miner_tx_hash and the rest are in tx_hashes. And the miner hash matches if queried as you say. There is some difference in the early coinbase transactions containing multiple vout and the current ones seem to only have one. Maybe I got confused about that. Is that change from obfuscating the amounts?
    – kg_sYy
    Commented Jan 6, 2020 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.