2

Is there any way that we can do an API call to the Monero daemon RPC to get all the ring members for a given transaction hash?

jtgrassie
  • 19,111
  • 4
  • 14
  • 51
Sri davei
  • 167
  • 4

1 Answers1

2

After calling get_transactions, you will have a list of the ring members in the vin.key_offsets field. You can then lookup these outputs using a call to get_outs.

An example of both calls:

curl -X POST http://127.0.0.1:18081/get_transactions -d '{"txs_hashes":["a6eb34ec1893ce43630efc2f2dfa98cde2d5e7f37c18d1d8303f3a6436a4cc9f"],"decode_as_json":true}' -H 'Content-Type: application/json

Returns 5164903, 2019770, 392759, 121787, 5621, 4659, 833, 1353, 6326, 487, 682 as the key_offsets (the ring members).

Each output after the first is incremented by the sum of the previous indexes. So the first member is at index 5164903, the 2nd at 7184673 and so on.

So translated, these outputs are then:

5164903, 7184673, 7577432, 7699219, 7704840, 7709499, 7710332, 7711685, 7718011, 7718498, 7719180

To get further information on each ring member, you can then call get_outs like following (which gets the first and last):

curl -X POST http://127.0.0.1:18081/get_outs -d '{"get_txid":true,"outputs":[{"index":5164903},{"index":7719180}]}' -H 'Content-Type: application/json'

Which returns:

{
  "outs": [{
    "height": 1545783,
    "key": "6dcc42839619ea4e1b1cb1b28d45659916207a445ec00e06ece45a7b7bfc1264",
    "mask": "449ce062721cbde5f282eeb292eb27636539b29c81a396fddeede73c72d0a66e",
    "txid": "124f70eb30ace64d577d82f193e0057b07fc4bdb053bf228dfc00b4e1099b1f1",
    "unlocked": true
  },{
    "height": 1694891,
    "key": "1089839b83fd45f7ab87a64398aad45176be4e6ee44872cf37c544358904d61c",
    "mask": "3f22409779524a01dc998e58fbccb58a02ca37e6e6be784f11d7b67dbdaf87e3",
    "txid": "4b1580e241b5499dd19faebc6c3c2dbf9bbb8a6c8144f538863fb3e71db10bd1",
    "unlocked": true
  }],
  "status": "OK",
  "untrusted": false
}
jtgrassie
  • 19,111
  • 4
  • 14
  • 51
  • if there are different key_offset fields.. so do we still add it up? – Sri davei Dec 04 '18 at 22:54
  • 1
    If there was another vin in the tx (thus with it's own key_offsets field), it get's calculated/transformed in the same way - there is no relation to any other vin.key_offsets in the tx - each set of key_offsets is independent. Each offset in the set is the sum of the previous offsets in the set. – jtgrassie Dec 05 '18 at 02:08
  • I was looking at some returns. And i see that there are some values that there are same key_offsets in the same transaction. EX- [272], [272]. Does that they are same ring members? – Sri davei Dec 06 '18 at 04:15
  • 1
    Calculation is as I described. Give me a tx id and I can show you the translation. – jtgrassie Dec 06 '18 at 12:45
  • Tx - 9ecdadf8b95aa0a7b754559f5fd7a9bb0f5014c4107b3dc6b3331430b5ea984d And Tx- 405d367f7076cb39cae4f37067f4e716e77fbce62556d5d49487e41568e7cead – Sri davei Dec 07 '18 at 20:58
  • 1
    Firstly those are both very old transactions (pre-RingCT), however, calculation is still as I described. [272] translates to 272. The fact there are two vins each with separate key_offsets with [272], they are referring to the same output (which happen to be in a block with only a coinbase tx - block 00000273). – jtgrassie Dec 07 '18 at 21:53
  • what was the block height from which RingCT was implemented? – Sri davei Dec 08 '18 at 18:52
  • 1
    Block height 1220517 – jtgrassie Dec 08 '18 at 21:22
  • cool thats a lot!! – Sri davei Dec 08 '18 at 21:33