get block or transaction data via rpc api when in the ibd process #27388

issue DRAWCORE opened this issue on April 1, 2023
  1. DRAWCORE commented at 10:03 AM on April 1, 2023: none

    Please describe the feature you'd like to see added.

    Can I get the block or transaction data via the rpc api when the bitcoin core is still in the ibd process that has not been finished? For example , can I get the downloaded block data via calling the getblock api while the client is still in the ibd process?

    Is your feature related to a problem, if so please describe it.

    No response

    Describe the solution you'd like

    No response

    Describe any alternatives you've considered

    No response

    Please leave any additional context

    No response

  2. DRAWCORE added the label Feature on Apr 1, 2023
  3. pinheadmz commented at 11:58 AM on April 1, 2023: member

    Yes this should work, did you try it? Here's example commands starting bitcoind in a fresh datadir with -txindex:

    --> bitcoin-cli -datadir=/home/pinheadmz/bcd-test getblockcount
    400
    
    --> bitcoin-cli -datadir=/home/pinheadmz/bcd-test getblock 000000007bc154e0fa7ea32218a72fe2c1bb9f86cf8c9ebf9a715ed27fdb229a
    {
      "hash": "000000007bc154e0fa7ea32218a72fe2c1bb9f86cf8c9ebf9a715ed27fdb229a",
      "confirmations": 9282,
      "strippedsize": 215,
      "size": 215,
      "weight": 860,
      "height": 100,
      "version": 1,
      "versionHex": "00000001",
      "merkleroot": "2d05f0c9c3e1c226e63b5fac240137687544cf631cd616fd34fd188fc9020866",
      "tx": [
        "2d05f0c9c3e1c226e63b5fac240137687544cf631cd616fd34fd188fc9020866"
      ],
      "time": 1231660825,
      "mediantime": 1231656204,
      "nonce": 1573057331,
      "bits": "1d00ffff",
      "difficulty": 1,
      "chainwork": "0000000000000000000000000000000000000000000000000000006500650065",
      "nTx": 1,
      "previousblockhash": "00000000cd9b12643e6854cb25939b39cd7a1ad0af31a9bd8b2efe67854b1995",
      "nextblockhash": "00000000b69bd8e4dc60580117617a466d5c76ada85fb7b87e9baea01f9d9984"
    }
    
    --> bitcoin-cli -datadir=/home/pinheadmz/bcd-test getrawtransaction 2d05f0c9c3e1c226e63b5fac240137687
    544cf631cd616fd34fd188fc9020866
    01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d014dffffffff0100f2052a01000000434104e70a02f5af48a1989bf630d92523c9d14c45c75f7d1b998e962bff6ff9995fc5bdb44f1793b37495d80324acba7c8f537caaf8432b8d47987313060cc82d8a93ac00000000
    
    --> bitcoin-cli -datadir=/home/pinheadmz/bcd-test getblockcount
    36881
    
  4. DRAWCORE commented at 1:16 PM on April 1, 2023: none

    Yes this should work, did you try it? Here's example commands starting bitcoind in a fresh datadir with -txindex:

    --> bitcoin-cli -datadir=/home/pinheadmz/bcd-test getblockcount
    400
    
    --> bitcoin-cli -datadir=/home/pinheadmz/bcd-test getblock 000000007bc154e0fa7ea32218a72fe2c1bb9f86cf8c9ebf9a715ed27fdb229a
    {
      "hash": "000000007bc154e0fa7ea32218a72fe2c1bb9f86cf8c9ebf9a715ed27fdb229a",
      "confirmations": 9282,
      "strippedsize": 215,
      "size": 215,
      "weight": 860,
      "height": 100,
      "version": 1,
      "versionHex": "00000001",
      "merkleroot": "2d05f0c9c3e1c226e63b5fac240137687544cf631cd616fd34fd188fc9020866",
      "tx": [
        "2d05f0c9c3e1c226e63b5fac240137687544cf631cd616fd34fd188fc9020866"
      ],
      "time": 1231660825,
      "mediantime": 1231656204,
      "nonce": 1573057331,
      "bits": "1d00ffff",
      "difficulty": 1,
      "chainwork": "0000000000000000000000000000000000000000000000000000006500650065",
      "nTx": 1,
      "previousblockhash": "00000000cd9b12643e6854cb25939b39cd7a1ad0af31a9bd8b2efe67854b1995",
      "nextblockhash": "00000000b69bd8e4dc60580117617a466d5c76ada85fb7b87e9baea01f9d9984"
    }
    
    --> bitcoin-cli -datadir=/home/pinheadmz/bcd-test getrawtransaction 2d05f0c9c3e1c226e63b5fac240137687
    544cf631cd616fd34fd188fc9020866
    01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d014dffffffff0100f2052a01000000434104e70a02f5af48a1989bf630d92523c9d14c45c75f7d1b998e962bff6ff9995fc5bdb44f1793b37495d80324acba7c8f537caaf8432b8d47987313060cc82d8a93ac00000000
    
    --> bitcoin-cli -datadir=/home/pinheadmz/bcd-test getblockcount
    36881
    

    thanks, you mean that I can get the downloaded block and tx data via rpc api even though the bitcoin core is still in the ibd process and has not downloaded the full ledger data in the mainnet , right?

  5. pinheadmz commented at 1:26 PM on April 1, 2023: member

    Yes with the rpc you can access anything that you have already downloaded

  6. maflcko closed this on Apr 2, 2023

  7. maflcko removed the label Feature on Apr 2, 2023
  8. maflcko added the label Questions and Help on Apr 2, 2023
  9. bitcoin locked this on Apr 1, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-26 06:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me