Bitcoin Forum
May 05, 2024, 12:24:06 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: address balances at specific block?  (Read 1208 times)
jl777 (OP)
Legendary
*
Offline Offline

Activity: 1176
Merit: 1132


View Profile WWW
March 15, 2016, 12:13:36 PM
Merited by ABCbits (2)
 #1

Does anybody know how to query balances for all addresses as of a specific block?

I would think some sort of query layer on top of insight block explorer?

My use case is that I want to do a brute force verification of all addresses that I have generated with the iguana parallel sync. Now that I have this data, I cant find any easy way to verify it...

James

http://www.digitalcatallaxy.com/report2015.html
100+ page annual report for SuperNET
1714868646
Hero Member
*
Offline Offline

Posts: 1714868646

View Profile Personal Message (Offline)

Ignore
1714868646
Reply with quote  #2

1714868646
Report to moderator
1714868646
Hero Member
*
Offline Offline

Posts: 1714868646

View Profile Personal Message (Offline)

Ignore
1714868646
Reply with quote  #2

1714868646
Report to moderator
1714868646
Hero Member
*
Offline Offline

Posts: 1714868646

View Profile Personal Message (Offline)

Ignore
1714868646
Reply with quote  #2

1714868646
Report to moderator
"If you don't want people to know you're a scumbag then don't be a scumbag." -- margaritahuyan
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714868646
Hero Member
*
Offline Offline

Posts: 1714868646

View Profile Personal Message (Offline)

Ignore
1714868646
Reply with quote  #2

1714868646
Report to moderator
1714868646
Hero Member
*
Offline Offline

Posts: 1714868646

View Profile Personal Message (Offline)

Ignore
1714868646
Reply with quote  #2

1714868646
Report to moderator
danda
Full Member
***
Offline Offline

Activity: 201
Merit: 157


View Profile WWW
March 15, 2016, 08:54:44 PM
 #2

I'm not aware of any way to do this ( balance of an address at specific time/block in the past ).  It's an interesting question.

"balance of an address" is a tricky thing to begin with.  So at best I think you can achieve "best guess balance" anyway, unless you have the private keys for all addresses in question.

Block explorers such as toshi and insight store do store balance information, but I'm not sure if they do it per address per block or only per address (all time best chain). 




mybitprices.info - wallet auditing   |  hd-wallet-derive - derive keys locally |  hd-wallet-addrs - find used addrs
lightning-nodes - list of LN nodes  |  coinparams - params for 300+ alts  |  jsonrpc-cli - cli jsonrpc client
subaddress-derive-xmr - monero offline wallet tool
watashi-kokoto
Sr. Member
****
Offline Offline

Activity: 682
Merit: 268



View Profile
March 15, 2016, 09:35:38 PM
 #3

just look up all transactions (debit credit) affecting certain address,


 and filter out tx with less than n confirmations,

then sum debit credit of the rest

ideal way to do this would be sql.

most addresses have 1 tx, so the balance before top-up is 0BTC and after the value of the utxoBTC

so i would start the test with the non-reused addresses
jl777 (OP)
Legendary
*
Offline Offline

Activity: 1176
Merit: 1132


View Profile WWW
March 16, 2016, 01:33:27 AM
 #4

just look up all transactions (debit credit) affecting certain address,


 and filter out tx with less than n confirmations,

then sum debit credit of the rest

ideal way to do this would be sql.

most addresses have 1 tx, so the balance before top-up is 0BTC and after the value of the utxoBTC

so i would start the test with the non-reused addresses
I figured out how to get iguana to generate the balance for ANY address as of ANY block, with about 2 milliseconds compute time using a 1.3Ghz i5 CPU. With faster CPU and 8 cores, this would be able to be sped up to 100 microseconds. As I have written extensively, I dont use any DB, I use readonly parallel datasets.

Also generating a full dataset would be much faster as I can batch process all addresses in the same pass.

My issue is how do I verify that I have the right data? So, assume I have a file with (address, balance) as of the start of block 400,000, how can I verify that it is 100% correct

http://www.digitalcatallaxy.com/report2015.html
100+ page annual report for SuperNET
funkenstein
Legendary
*
Offline Offline

Activity: 1066
Merit: 1050


Khazad ai-menu!


View Profile WWW
March 16, 2016, 02:22:25 AM
Merited by ABCbits (1)
 #5

Walk the chain from block 0 and build your own database. 

"Give me control over a coin's checkpoints and I care not who mines its blocks."
http://vtscc.org  http://woodcoin.info
jl777 (OP)
Legendary
*
Offline Offline

Activity: 1176
Merit: 1132


View Profile WWW
March 16, 2016, 02:55:05 AM
 #6

Walk the chain from block 0 and build your own database. 
I already did that.
How do I verify independently from a known accurate source

James

P.S. my "database" is not actually a database, but for this purpose you can consider it a database

http://www.digitalcatallaxy.com/report2015.html
100+ page annual report for SuperNET
danda
Full Member
***
Offline Offline

Activity: 201
Merit: 157


View Profile WWW
March 16, 2016, 02:55:40 AM
 #7

100% correct?    I'm not sure you can be.

What if an output can be unlocked by, say, 1 of a set of 3 keys? Do you credit the balances of all three keys, or none?

more on this here:
http://bitcoin.stackexchange.com/a/37186/31594

mybitprices.info - wallet auditing   |  hd-wallet-derive - derive keys locally |  hd-wallet-addrs - find used addrs
lightning-nodes - list of LN nodes  |  coinparams - params for 300+ alts  |  jsonrpc-cli - cli jsonrpc client
subaddress-derive-xmr - monero offline wallet tool
jl777 (OP)
Legendary
*
Offline Offline

Activity: 1176
Merit: 1132


View Profile WWW
March 16, 2016, 03:03:50 AM
 #8

100% correct?    I'm not sure you can be.

What if an output can be unlocked by, say, 1 of a set of 3 keys? Do you credit the balances of all three keys, or none?

more on this here:
http://bitcoin.stackexchange.com/a/37186/31594
I update balances based on the multisig (or p2sh ) address in that case. So the address that is credited is the multisig address and not the pubkeys that compose the multisig

this is a practicaly way of doing things and is what blockchain.info does

I think what is needed is a way to select out data from insight database, but I never used insight and not sure how best to do that

http://www.digitalcatallaxy.com/report2015.html
100+ page annual report for SuperNET
bitcreditscc
Hero Member
*****
Offline Offline

Activity: 602
Merit: 501



View Profile
March 16, 2016, 01:58:30 PM
 #9

There is nothing better than building your own database, i also built my own but adding some code to core, updated every new block.

jl777 (OP)
Legendary
*
Offline Offline

Activity: 1176
Merit: 1132


View Profile WWW
March 16, 2016, 05:17:24 PM
 #10

There is nothing better than building your own database, i also built my own but adding some code to core, updated every new block.
I would feel much better for independent validation. Otherwise it is me verifying my own data with another dataset that I generate.

It seems that such would require that others trust that I didnt make any errors.

could you generate a dataset for balances before block 400,000, ie 0 to 399,999 processed? I can pay a reasonable bounty for it. How do you deal with multisig address balances and non-standard outputs?

James

http://www.digitalcatallaxy.com/report2015.html
100+ page annual report for SuperNET
gmaxwell
Moderator
Legendary
*
expert
Offline Offline

Activity: 4158
Merit: 8382



View Profile WWW
March 16, 2016, 10:56:19 PM
Merited by ABCbits (2)
 #11

Since nothing in the Bitcoin consensus algorithm works with balances, using them for comparison would be potentially unwise-- it's perfectly possible to have an incorrect 'balance' that is actually a latently corrupted state.  Bitcoin Core gettxoutsetinfo will give you a hash of the serialized utxo set for this kind of diagnostic purpose, though there is no text specification for the particular serialization it uses, you'd have to extract that from the implementation.
jl777 (OP)
Legendary
*
Offline Offline

Activity: 1176
Merit: 1132


View Profile WWW
March 16, 2016, 11:13:16 PM
 #12

Since nothing in the Bitcoin consensus algorithm works with balances, using them for comparison would be potentially unwise-- it's perfectly possible to have an incorrect 'balance' that is actually a latently corrupted state.  Bitcoin Core gettxoutsetinfo will give you a hash of the serialized utxo set for this kind of diagnostic purpose, though there is no text specification for the particular serialization it uses, you'd have to extract that from the implementation.
when does the (sum of vouts) - (sum of vins) for an address not match what it should be?

For things that use scripts with multisig, if statements, CLTV, etc. I just treat the p2sh hash as the "address" and not deal with the probabilistic value allocations to the potential redeemers. I think even for the strange anyone can spend outputs, it is either spent or not spent, so the difference of sums would work

I have commissioned an independently tabulated balances that I will cross check against. The plan would be to analyze any that are not matching, which will hopefully be not many. the gettxoutsetinfo should be quite useful for that, i forgot about that one. thanks

After all, block explorers are displaying a balance (potentially inaccurate it might be). I always assume my data is wrong, until I get it verified. Granted if the independently generated balances match iguana's output, it is possible for something to slip through, but at least for an initial test it seems like a good place to start and since the independent balances will be generated from bitcoin core, I know it is 100% correct

James

http://www.digitalcatallaxy.com/report2015.html
100+ page annual report for SuperNET
esotericizm
Hero Member
*****
Offline Offline

Activity: 750
Merit: 500



View Profile
March 16, 2016, 11:41:50 PM
 #13

I havent reviewed the latest insight-api code but it stands to reason you could run a local copy changing the code that grabs the current blockindex and setting that to the blockhash of your chosen height.
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!