Bitcoin Forum
April 26, 2024, 03:56:17 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: « 1 [2]  All
  Print  
Author Topic: "Easy way" to extract the UTXO from Bitcoin Core?  (Read 3784 times)
DeathAndTaxes (OP)
Donator
Legendary
*
Offline Offline

Activity: 1218
Merit: 1079


Gerald Davis


View Profile
June 13, 2014, 04:15:49 PM
 #21

Thanks to everyone who helped.  I got the demo working and correctly parsing UXTO entries.

Code:
E:\Repos\UxtoParser\UxtoParser.Demo\bin\Debug>UxtoParser.Demo.exe decodetx 14015bd586c0c7a28979ca294b114441f23bfc97be17cd6077b9e12e2709fec3
Raw Key:
63c3fe09272ee1b97760cd17be97fc3bf24144114b29ca7989a2c7c086d55b0114

Raw Value:
010c013600946cb2e08075bcbaf157e47bcb67eb2b2339d24268800f514104e6da9c60084b43d28266243c636bcdaf4d8f17b5954e078d2dece7d4659e0dee3419a40b939c24ac813c692a323ca5207a6fb387ffe28e48f706c95dbf46648f210226cb0561011d9045f6371cb09086ba7148d9942328bcf135ccdda921022eac137ab02d826df0af54e92a352945c9892df6cd77f1a7c390fc82c8b0edea53ae8f9d01

Decoded Record
Version: 1
Code: 12 (IsCoinbase?: False  OutZeroSpendable?: False OutOneSpendable?: True BitmaskLen: 1)
Bitmask: 0x01
BlockHeight: 265985

TxId : Index                                                                Value               Type  SLen Script
14015bd586c0c7a28979ca294b114441f23bfc97be17cd6077b9e12e2709fec3:1           6000         PubKeyHash    20 946cb2e08075bcbaf157e47bcb67eb2b2339d242
14015bd586c0c7a28979ca294b114441f23bfc97be17cd6077b9e12e2709fec3:2          12000          RawScript   137 514104e6da9c60084b43d28266243c636bcdaf4d8f17b5954e078d2dece7d4659e0dee3419a40b939c24ac813c692a323ca5207a6fb387ffe28e48f706c95dbf46648561011d9045f6371cb09086ba7148d9942328bcf1dd78cb6edb35ccdda921022eac137ab02d826df0af54e92a352945c9892df6cd77f1a7c390fc82c8b0edea53ae

Code:
E:\Repos\UxtoParser\UxtoParser.Demo\bin\Debug>UxtoParser.Demo.exe decodetx e6556c82129245c5a5bc1e71151588c3c8ef5e86abd41940ad61178f5374a652
Raw Key:
6352a674538f1761ad4019d4ab865eefc8c3881515711ebca5c5459212826c55e6

Raw Value:
010a118edad22b005a25e8152cdeae9419b34595104e874bf93a8f0183a4a7550040d2918f30a7d55e8b7000983b24b1116179e27a838488be7f00415435a335bc5aa1417bcdd8dea10ce725ed7aaf91cd68

Decoded Record
Version: 1
Code: 0x10 (IsCoinbase?: False  OutZeroSpendable?: True OutOneSpendable?: False BitmaskLen: 1)
Bitmask: 0x11
BlockHeight: 305000

TxId : Index                                                                Value               Type  SLen Script
e6556c82129245c5a5bc1e71151588c3c8ef5e86abd41940ad61178f5374a652:0        3662099         PubKeyHash    20 5a25e8152cdeae9419b34595104e874bf93a8f01
e6556c82129245c5a5bc1e71151588c3c8ef5e86abd41940ad61178f5374a652:2        1000003         PubKeyHash    20 40d2918f30a7d55e8b7000983b24b1116179e27a
e6556c82129245c5a5bc1e71151588c3c8ef5e86abd41940ad61178f5374a652:6      120487026         PubKeyHash    20 415435a335bc5aa1417bcdd8dea10ce725ed7aaf
1714146977
Hero Member
*
Offline Offline

Posts: 1714146977

View Profile Personal Message (Offline)

Ignore
1714146977
Reply with quote  #2

1714146977
Report to moderator
1714146977
Hero Member
*
Offline Offline

Posts: 1714146977

View Profile Personal Message (Offline)

Ignore
1714146977
Reply with quote  #2

1714146977
Report to moderator
"You Asked For Change, We Gave You Coins" -- casascius
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
DeathAndTaxes (OP)
Donator
Legendary
*
Offline Offline

Activity: 1218
Merit: 1079


Gerald Davis


View Profile
June 13, 2014, 04:20:48 PM
 #22

Makes sense.  I agree wiki is probably the wrong place.  Maybe expanding the inline documentation in the source code.  I don't really think this kind of code is useful to most applications but there is a lot of interesting stats which can be pulled from the UXTO.  Distribution of output age, distribution of outputs by script type, distribution of output values.  One could build the UXTO from the raw blocks but since the chainstate has that data (albeit in an somewhat opaque format) it seems a smarter place to pull that out.
FWIW, the gettxoutsetinfo rpc iterates over the utxo set, in the past when I've wanted this data I've just added some instrumentation in that function to dump it out. Even if you're not very experienced with C++ it shouldn't be to hard to emulate the rest of the code and print it out... this might be easier (and also more reliable across versions) than trying to read the data.

That is a good option.  I would love a dumptxoutset RPC command.  Still if was an interesting project and I learned a couple things so that is always good.  I never considered that for uncompressed keys in the output set you don't need to record all 65 bytes.   could just record the x and recompute the y as it is done for compressed keys.  I new tx version could save 32 bytes per input (Pay2PubKeyHash) or 32 bytes in the output (Pay2PubKey) by recording the PubKey in compressed format while still supporting uncompressed PubKeys.
jgarzik
Legendary
*
qt
Offline Offline

Activity: 1596
Merit: 1091


View Profile
June 13, 2014, 06:05:06 PM
 #23

That is a good option.  I would love a dumptxoutset RPC command.  Still if was an interesting project and I learned a couple things so that is always good.  I never considered that for uncompressed keys in the output set you don't need to record all 65 bytes.   could just record the x and recompute the y as it is done for compressed keys.  I new tx version could save 32 bytes per input (Pay2PubKeyHash) or 32 bytes in the output (Pay2PubKey) by recording the PubKey in compressed format while still supporting uncompressed PubKeys.

There is gettxout, which could be expanded if it's missing some info.  I doubt you will see a dump1gigabytedataset RPC added, though.  Smiley


Jeff Garzik, Bloq CEO, former bitcoin core dev team; opinions are my own.
Visit bloq.com / metronome.io
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
DeathAndTaxes (OP)
Donator
Legendary
*
Offline Offline

Activity: 1218
Merit: 1079


Gerald Davis


View Profile
June 13, 2014, 06:13:42 PM
 #24

There is gettxout, which could be expanded if it's missing some info.  I doubt you will see a dump1gigabytedataset RPC added, though.  Smiley

I didn't think so I should have put a smiley after the statement.  gettxout is useful but is requires knowing the txid and more importantly the index.  One would need to parse the chainstate to that info.  The txid can be obtained easily by just iterating all keys in the chainstate but the index(es) require decoding the value for each key to get the code and output bitmap.
Pages: « 1 [2]  All
  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!