forex.pm forex forum binary options trade - Binance - Сryptocurrency exchanges - Are OP_RETURN transactions not stored in chainstate database?
  • Welcome to forex.pm forex forum binary options trade. Please login or sign up.
 

Are OP_RETURN transactions not stored in chainstate database?

Started by Bitcoin, Feb 08, 2022, 06:12 pm

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bitcoin

Are OP_RETURN transactions not stored in chainstate database?

I'm running a bitcoin node on regtest. I'm writing scripts to interact with the chain-state database.


For my purpose, I'm creating, signing and sending a transaction to my node (pretty much following the instructions from here, specifically chapter 4 and 8)


{
  "amount": 0.00000000,
  "fee": -14.28700000,
  "confirmations": 200,
  "blockhash": "41dd1e98ab12148e8cd5c0ad06aab27beb4117f54b1e51916b7238535884cac2",
  "blockheight": 1001,
  "blockindex": 1,
  "blocktime": 1644326961,
  "txid": "9286a6f8e3814977efa6acd6320a4d4367f0bed85f9477c78da6c122086f49df",
  "walletconflicts": [
  ],
  "time": 1644326955,
  "timereceived": 1644326955,
  "bip125-replaceable": "no",
  "details": [
    {
      "category": "send",
      "amount": 0.00000000,
      "vout": 0,
      "fee": -14.28700000,
      "abandoned": false
    }
  ],
  "hex": "..."
}

Below is the transaction outputs:


 "vout": [
    {
      "value": 0.00000000,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_RETURN 6268696a6b6c0a",
        "hex": "6a076268696a6b6c0a",
        "type": "nulldata"
      }
    },
    {
      "value": 10.71300000,
      "n": 1,
      "scriptPubKey": {
        "asm": "0 e2698bbd6d475f022f8e5f852fa10ac761faa9c7",
        "hex": "0014e2698bbd6d475f022f8e5f852fa10ac761faa9c7",
        "reqSigs": 1,
        "type": "witness_v0_keyhash",
        "addresses": [
          "bcrt1quf5ch0tdga0sytuwt7zjlgg2casl42w8c2pr6d"
        ]
      }
    }
  ]

My problem: When I query the chainstate database and decode the TXIDs and output indexes, I see only the second output and not the first (i.e. the OP_RETURN one). I've retried on clean slate, other wallets, etc, but the problem still persists.


I've read 200 confirmations is as good as go, but I've tried the same after generating 400 more blocks too. Even still, that doesnt explain why I cant find my OP_RETURN UTXO in the chainstate folder.


For reference, this is my Python script that queries the chainstate folder:


db=plyvel.DB(chainstate_folder_path,compression=None)
arr=[]
for key,value in db:
    hexval=key.replace(b'C',b'')[::-1].hex()
    arr.append((int(hexval[:2]),hexval[2:]))

arr.sort(key=lambda x:x[1])
for i in arr:
    print(i)

What am I missing out? I really want to be able to parse my OP_RETURN UTXOs.


Source: Are OP_RETURN transactions not stored in chainstate database?