Bitcoin Forum
May 28, 2024, 11:28:58 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How do I see the contents of the blockchain on a full node  (Read 127 times)
LtMotioN (OP)
Member
**
Offline Offline

Activity: 210
Merit: 29


View Profile
June 04, 2018, 09:35:27 AM
 #1

Hi guys
Is it possible to read the contents of my copy of the blockchain as a txt file or anything? I havent setup a full node yet due to the size of it but I would like to do a few things with the content.

I have checked for other monero forks that I have a copy of the chain for but didn't see anything where I could see the ledger in. I specifically want to see this for BTC.

Dogs are nice, I don't like cats though.
bob123
Legendary
*
Offline Offline

Activity: 1624
Merit: 2481



View Profile WWW
June 04, 2018, 12:18:51 PM
 #2

You can't directly read the 'blockchain' as plain text.

What information exactly do you want to extract?


If you are trying to extract mass data, you need to write a small script which will handle everything for you. I'd suggest python-bitcoinlib.


If you are only trying to extract a few blocks, you can use blockchain.info's API.
You can search for the block, then append ?format=hex or ?format=json to the end of the URL.

Example for the latest block (https://blockchain.info/de/block/0000000000000000001edf438f4cab8dab298b16774b97b00d8ab2e9544c3b80):

HEX: https://blockchain.info/de/block/0000000000000000001edf438f4cab8dab298b16774b97b00d8ab2e9544c3b80?format=hex
JSON: https://blockchain.info/de/block/0000000000000000001edf438f4cab8dab298b16774b97b00d8ab2e9544c3b80?format=json

LtMotioN (OP)
Member
**
Offline Offline

Activity: 210
Merit: 29


View Profile
June 04, 2018, 07:21:50 PM
 #3

Thanks bob. Yea I am busy learning this stuff. I basically want to monitor my wallet myself off my own node.

Ill check into these things you sent. Have a good one mate.

Dogs are nice, I don't like cats though.
bob123
Legendary
*
Offline Offline

Activity: 1624
Merit: 2481



View Profile WWW
June 08, 2018, 01:46:51 PM
Merited by ABCbits (2)
 #4

Thanks bob. Yea I am busy learning this stuff. I basically want to monitor my wallet myself off my own node.

Ill check into these things you sent. Have a good one mate.

The information i have written was regarding gathering information using blockchain.info's API.

If you want to use your daemon, you can write a small script.


Simply edit your bitcoin.conf file and add blocknotify or walletnotify (depending on what you need):
Code:
blocknotify=/path/to_your/script.sh %s
walletnotify=/path/to_your/script2.sh %s

walletnotify will be called if:
1) You receive a transaction to one of your addresses
2) First confirmation of a TX to one of your addresses
3) You send a transaction

blocknotify will be called each time you receive a new block.


Then you can do whatever you want and implement any logic/logging in script.sh and script2.sh.

goddog
Member
**
Offline Offline

Activity: 168
Merit: 47

8426 2618 9F5F C7BF 22BD E814 763A 57A1 AA19 E681


View Profile
June 08, 2018, 02:14:01 PM
 #5

example:
Code:
$ bitcoin-cli getblockhash 12345
00000000b8980ec1fe96bc1b4425788ddc88dd36699521a448ebca2020b38699

Code:
$ bitcoin-cli getblock 00000000b8980ec1fe96bc1b4425788ddc88dd36699521a448ebca2020b38699
{
  "hash": "00000000b8980ec1fe96bc1b4425788ddc88dd36699521a448ebca2020b38699",
  "confirmations": 500199,
  "strippedsize": 216,
  "size": 216,
  "weight": 864,
  "height": 12345,
  "version": 1,
  "versionHex": "00000001",
  "merkleroot": "fd1dc97a826eb93b485b6bada84a807ee81181f7ab2720cefb5fa96729363157",
  "tx": [
    "fd1dc97a826eb93b485b6bada84a807ee81181f7ab2720cefb5fa96729363157"
  ],
  "time": 1240784732,
  "mediantime": 1240781715,
  "nonce": 784807199,
  "bits": "1d00ffff",
  "difficulty": 1,
  "chainwork": "0000000000000000000000000000000000000000000000000000303a303a303a",
  "previousblockhash": "0000000076876082384460fb5a231cc5a5e874b9762e15a4e7b1fc068f749cdf",
  "nextblockhash": "00000000a08518aae9f8f95cc295d1331b937b12e1e885b44ed07d95f9a625e5"
}
Code:
$ bitcoin-cli getrawtransaction fd1dc97a826eb93b485b6bada84a807ee81181f7ab2720cefb5fa96729363157 true
{
  "txid": "fd1dc97a826eb93b485b6bada84a807ee81181f7ab2720cefb5fa96729363157",
  "hash": "fd1dc97a826eb93b485b6bada84a807ee81181f7ab2720cefb5fa96729363157",
  "version": 1,
  "size": 135,
  "vsize": 135,
  "locktime": 0,
  "vin": [
    {
      "coinbase": "04ffff001d02aa06",
      "sequence": 4294967295
    }
  ],
  "vout": [
    {
      "value": 50.00000000,
      "n": 0,
      "scriptPubKey": {
        "asm": "04c5d62274610e82819939c3341a4addc72634664d73b11ba761de42839aa3496f93b3b3ee80e497eb5a68439b02f04e9aeb1604fbcaa074aa82f0f7574f9f110d OP_CHECKSIG",
        "hex": "4104c5d62274610e82819939c3341a4addc72634664d73b11ba761de42839aa3496f93b3b3ee80e497eb5a68439b02f04e9aeb1604fbcaa074aa82f0f7574f9f110dac",
        "reqSigs": 1,
        "type": "pubkey",
        "addresses": [
          "18x6rfvHEgH1iTbkJTjRpYJrfSAhWdUiQM"
        ]
      }
    }
  ],
  "hex": "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0804ffff001d02aa06ffffffff0100f2052a01000000434104c5d62274610e82819939c3341a4addc72634664d73b11ba761de42839aa3496f93b3b3ee80e497eb5a68439b02f04e9aeb1604fbcaa074aa82f0f7574f9f110dac00000000",
  "blockhash": "00000000b8980ec1fe96bc1b4425788ddc88dd36699521a448ebca2020b38699",
  "confirmations": 500221,
  "time": 1240784732,
  "blocktime": 1240784732
}
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!