bitcoind without txindex=1

0

1

I am currently running bitcoind with empty bitcoin.conf:

[root@nas .bitcoin]# cat bitcoin.conf 

#txindex=1

I am wonder why this works:

[root@nas .bitcoin]# bitcoin-cli getrawtransaction 1ea2a83c8e418fde3f512b67bb9db1e52e690a143430c813d152a5b7fe125cf1 1
{
  "hex": "010000000115fc42901b6f0a3f4a34d506b807ebf03d97f017782a794d7301125f880dbe25000000008c493046022100f34f800f9abaf3c67435d1693cbb10732b506fb5fa792de10bcd6eed0449d56c02210083f392d6e3ce6a5ceafc01482339e022a37b54285561463b88cbc18cd8ab5e5c014104a41046648e01774cb2ce9c6bf27e1f9a64e89a95f26218cacf0ee0bb52ba479a11c5b77b8834235bb73fea84ccf899c9f266a0430871a8149a1b7f6ac1c41033ffffffff02c057d069080000001976a914a6e842531b39d49d89570bcd01ddb92dec87cc1188ac404b4c00000000001976a914951ffc558ffbf20d47f96a06df69a369e244c78288ac00000000",
  "txid": "1ea2a83c8e418fde3f512b67bb9db1e52e690a143430c813d152a5b7fe125cf1",
  "hash": "1ea2a83c8e418fde3f512b67bb9db1e52e690a143430c813d152a5b7fe125cf1",
  "size": 259,
  "vsize": 259,
  "version": 1,
  "locktime": 0,
  "vin": [
    {
      "txid": "25be0d885f1201734d792a7817f0973df0eb07b806d5344a3f0a6f1b9042fc15",
      "vout": 0,
      "scriptSig": {
        "asm": "3046022100f34f800f9abaf3c67435d1693cbb10732b506fb5fa792de10bcd6eed0449d56c02210083f392d6e3ce6a5ceafc01482339e022a37b54285561463b88cbc18cd8ab5e5c[ALL] 04a41046648e01774cb2ce9c6bf27e1f9a64e89a95f26218cacf0ee0bb52ba479a11c5b77b8834235bb73fea84ccf899c9f266a0430871a8149a1b7f6ac1c41033",
        "hex": "493046022100f34f800f9abaf3c67435d1693cbb10732b506fb5fa792de10bcd6eed0449d56c02210083f392d6e3ce6a5ceafc01482339e022a37b54285561463b88cbc18cd8ab5e5c014104a41046648e01774cb2ce9c6bf27e1f9a64e89a95f26218cacf0ee0bb52ba479a11c5b77b8834235bb73fea84ccf899c9f266a0430871a8149a1b7f6ac1c41033"
      },
      "sequence": 4294967295
    }
  ],
  "vout": [
    {
      "value": 361.35000000,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 a6e842531b39d49d89570bcd01ddb92dec87cc11 OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914a6e842531b39d49d89570bcd01ddb92dec87cc1188ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "1GDXQVHZaDVxGXqyXdS9yMCsDYKdE5x7rS"
        ]
      }
    }, 
    {
      "value": 0.05000000,
      "n": 1,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 951ffc558ffbf20d47f96a06df69a369e244c782 OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914951ffc558ffbf20d47f96a06df69a369e244c78288ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "1EbVzzEXiuK4Y7xStsfTEHrGeNj3aoeEfZ"
        ]
      }
    }
  ],
  "blockhash": "000000000000a08eb97316b473e6c55e61ac1899471e24ec040899898bf5da00",
  "confirmations": 71681,
  "time": 1297408136,
  "blocktime": 1297408136
}

Additionally, if my question is wrong, then question is what txindex=1 do.

Nick

Posted 2017-09-06T08:25:38.933

Reputation: 191

1Is this a transaction that you sent, or that credits an address in your wallet? Those are stored in wallet.dat and can always be queried, even without txindex.Nate Eldredge 2017-09-06T13:20:59.200

Otherwise, did you ever have txindex enabled before? Running with txindex adds transactions to the chainstate database, but I don't think they are removed if you disable the option, unless you -reindex.Nate Eldredge 2017-09-06T13:24:47.750

Answers

2

I am wonder why this works.

Because all options have the default value.

The question is what txindex=1 do.

I can't find this option in the documentation

From the documentation

-txindex Maintain a full transaction index, used by the getrawtransaction rpc call (default: 0)

If you're using Bitcoin Core just for your own personal use, you probably don't need the -txindex=1 option. But, if you're using Bitcoin core for development or blockchain analysis of some sort, you will need to set -txindex=1 to be able to get transactions data for any transaction in the blockchain.

Зелёный

Posted 2017-09-06T08:25:38.933

Reputation: 871

ok, but isn't the default value is 0 ? then why it works? in conf file I have # in front. Even this is not considered as comment, it changes the optionNick 2017-09-06T09:26:45.157

AFAIK there is no such option txindex=1 for bitcoin.conf(check the documentation) this option is only for bitcoind, so when it does nothing then you add it ti the bitcoin.conf, any kind of unknow options must be ignored, I assume.

Зелёный 2017-09-06T09:28:55.917

ok, but i never started bitcond with -txindex=1, i did it with just -daemonNick 2017-09-06T09:32:05.283

@Nick no matter 1 or 0, only with -txindex or without, just like with -daemon or without.Зелёный 2017-09-06T09:33:15.600

I found something strange, I did found a transaction I can not access. then restarted with txindex and now it is accessible. So generally without txindex, some tx are accessible, some are not.Nick 2017-09-06T09:46:52.377

1@Nick txindex its for utxo for unspent transactions.Зелёный 2017-09-06T09:48:39.090

is this because unspent transactions are important in case their coins come to our own address in the future?Nick 2017-09-06T10:44:24.173

can't get what you're asking. utxo it's a just unspent bitcoins, txindex mostly used to check the transactions input or output. I'm also a crypto-noob, so something I dont understand.Зелёный 2017-09-06T10:51:22.143

1

It works because your transaction is still in mempool. Once transaction leaves the mempool when confirmed you need txindex=1 to query it from the disk.

dark knight

Posted 2017-09-06T08:25:38.933

Reputation: 1 532

It seems kind of unlikely that a transaction with 71681 confirmations would be in the mempool...Nate Eldredge 2017-09-06T13:20:06.303

not true, I tried with transactions from 2009 and early 2010Nick 2017-09-06T13:56:25.930