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.

  • 1
    Is 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 Sep 6 '17 at 13:20
  • 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 Sep 6 '17 at 13:24
up vote 2 down vote accepted

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.

  • 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 option – Nick Sep 6 '17 at 9:26
  • 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. – Зелёный Sep 6 '17 at 9:28
  • ok, but i never started bitcond with -txindex=1, i did it with just -daemon – Nick Sep 6 '17 at 9:32
  • @Nick no matter 1 or 0, only with -txindex or without, just like with -daemon or without. – Зелёный Sep 6 '17 at 9:33
  • 1
    @Nick txindex its for utxo for unspent transactions. – Зелёный Sep 6 '17 at 9:48

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.

  • It seems kind of unlikely that a transaction with 71681 confirmations would be in the mempool... – Nate Eldredge Sep 6 '17 at 13:20
  • not true, I tried with transactions from 2009 and early 2010 – Nick Sep 6 '17 at 13:56

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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