in3rsha / bitcoin-to-neo4j

Import the Bitcoin blockchain in to a Neo4j graph database.
GNU General Public License v3.0
208 stars 55 forks source link

Add Public Key Export Feature #30

Open DaCryptoRaccoon opened 1 year ago

DaCryptoRaccoon commented 1 year ago

Hello.

I would like to know if it is possible to extract the public keys from the chain in the following format?

0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9 025cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc 022f01e5e15cca351daff3843fb70f3c2f0a1bdd05e5af888a67784ef3e10a2a01 02352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5 03f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530 0296516a8f65774275278d0d7420a88df0ac44bd64c7bae07c3fe397c5b3300b23 0308bc89c2f919ed158885c35600844d49890905c79b357322609c45706ce6b514 0243601d61c836387485e9514ab5c8924dd2cfd466af34ac95002727e1659d60f7 03a7a4c30291ac1db24b4ab00c442aa832f7794b5a0959bec6e8d7fee802289dcd

Either the leading 02 or 03 indicates the keys in the data.

I was able to use another tool to extract all the 160hashes and addresses from the blocks folder reading from the blk files.

But I have not worked out a way to collect this data yet.

Best regards

Raccoon

in3rsha commented 1 year ago

I'm not aware of any tool that does this. I would have said bitcoin-iterate would be your best bet, but it doesn't output public keys only and so it would involve a lot of parsing of the data.

So if you're going to be parsing data anyway, it would probably be easiest to write your own custom parsing tool to get all the public keys from the raw blk files.

The public keys are in different locations in a transaction for different locking scripts.

If you can write your own transaction decoder (or use an existing one), you should be able to use it to get the public keys you're looking for. You'll just need to figure out where they're located in the different locking scripts.