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

issue DRAWCORE openend 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?

    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:

     0--> bitcoin-cli -datadir=/home/pinheadmz/bcd-test getblockcount
     1400
     2
     3--> bitcoin-cli -datadir=/home/pinheadmz/bcd-test getblock 000000007bc154e0fa7ea32218a72fe2c1bb9f86cf8c9ebf9a715ed27fdb229a
     4{
     5  "hash": "000000007bc154e0fa7ea32218a72fe2c1bb9f86cf8c9ebf9a715ed27fdb229a",
     6  "confirmations": 9282,
     7  "strippedsize": 215,
     8  "size": 215,
     9  "weight": 860,
    10  "height": 100,
    11  "version": 1,
    12  "versionHex": "00000001",
    13  "merkleroot": "2d05f0c9c3e1c226e63b5fac240137687544cf631cd616fd34fd188fc9020866",
    14  "tx": [
    15    "2d05f0c9c3e1c226e63b5fac240137687544cf631cd616fd34fd188fc9020866"
    16  ],
    17  "time": 1231660825,
    18  "mediantime": 1231656204,
    19  "nonce": 1573057331,
    20  "bits": "1d00ffff",
    21  "difficulty": 1,
    22  "chainwork": "0000000000000000000000000000000000000000000000000000006500650065",
    23  "nTx": 1,
    24  "previousblockhash": "00000000cd9b12643e6854cb25939b39cd7a1ad0af31a9bd8b2efe67854b1995",
    25  "nextblockhash": "00000000b69bd8e4dc60580117617a466d5c76ada85fb7b87e9baea01f9d9984"
    26}
    27
    28--> bitcoin-cli -datadir=/home/pinheadmz/bcd-test getrawtransaction 2d05f0c9c3e1c226e63b5fac240137687
    29544cf631cd616fd34fd188fc9020866
    3001000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d014dffffffff0100f2052a01000000434104e70a02f5af48a1989bf630d92523c9d14c45c75f7d1b998e962bff6ff9995fc5bdb44f1793b37495d80324acba7c8f537caaf8432b8d47987313060cc82d8a93ac00000000
    31
    32--> bitcoin-cli -datadir=/home/pinheadmz/bcd-test getblockcount
    3336881
    
  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:

     0--> bitcoin-cli -datadir=/home/pinheadmz/bcd-test getblockcount
     1400
     2
     3--> bitcoin-cli -datadir=/home/pinheadmz/bcd-test getblock 000000007bc154e0fa7ea32218a72fe2c1bb9f86cf8c9ebf9a715ed27fdb229a
     4{
     5  "hash": "000000007bc154e0fa7ea32218a72fe2c1bb9f86cf8c9ebf9a715ed27fdb229a",
     6  "confirmations": 9282,
     7  "strippedsize": 215,
     8  "size": 215,
     9  "weight": 860,
    10  "height": 100,
    11  "version": 1,
    12  "versionHex": "00000001",
    13  "merkleroot": "2d05f0c9c3e1c226e63b5fac240137687544cf631cd616fd34fd188fc9020866",
    14  "tx": [
    15    "2d05f0c9c3e1c226e63b5fac240137687544cf631cd616fd34fd188fc9020866"
    16  ],
    17  "time": 1231660825,
    18  "mediantime": 1231656204,
    19  "nonce": 1573057331,
    20  "bits": "1d00ffff",
    21  "difficulty": 1,
    22  "chainwork": "0000000000000000000000000000000000000000000000000000006500650065",
    23  "nTx": 1,
    24  "previousblockhash": "00000000cd9b12643e6854cb25939b39cd7a1ad0af31a9bd8b2efe67854b1995",
    25  "nextblockhash": "00000000b69bd8e4dc60580117617a466d5c76ada85fb7b87e9baea01f9d9984"
    26}
    27
    28--> bitcoin-cli -datadir=/home/pinheadmz/bcd-test getrawtransaction 2d05f0c9c3e1c226e63b5fac240137687
    29544cf631cd616fd34fd188fc9020866
    3001000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d014dffffffff0100f2052a01000000434104e70a02f5af48a1989bf630d92523c9d14c45c75f7d1b998e962bff6ff9995fc5bdb44f1793b37495d80324acba7c8f537caaf8432b8d47987313060cc82d8a93ac00000000
    31
    32--> bitcoin-cli -datadir=/home/pinheadmz/bcd-test getblockcount
    3336881
    

    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: 2024-12-21 15:12 UTC

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