Author

Topic: address balances at specific block? (Read 1229 times)

hero member
Activity: 750
Merit: 500
March 16, 2016, 06: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.
legendary
Activity: 1176
Merit: 1134
March 16, 2016, 06: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
staff
Activity: 4284
Merit: 8808
March 16, 2016, 05:56:19 PM
#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.
legendary
Activity: 1176
Merit: 1134
March 16, 2016, 12: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
hero member
Activity: 602
Merit: 501
March 16, 2016, 08:58:30 AM
#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.
legendary
Activity: 1176
Merit: 1134
March 15, 2016, 10:03:50 PM
#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
full member
Activity: 203
Merit: 168
March 15, 2016, 09:55:40 PM
#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
legendary
Activity: 1176
Merit: 1134
March 15, 2016, 09:55:05 PM
#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
legendary
Activity: 1066
Merit: 1050
Khazad ai-menu!
March 15, 2016, 09:22:25 PM
#5
Walk the chain from block 0 and build your own database. 
legendary
Activity: 1176
Merit: 1134
March 15, 2016, 08:33:27 PM
#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
sr. member
Activity: 687
Merit: 269
March 15, 2016, 04: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
full member
Activity: 203
Merit: 168
March 15, 2016, 03: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). 



legendary
Activity: 1176
Merit: 1134
March 15, 2016, 07:13:36 AM
#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
Jump to: