Author Topic: Question: How to get a historical wallet balance?  (Read 3169 times)

0 Members and 1 Guest are viewing this topic.

Offline Pheonike

A snapshot should be taken after each transaction. Could it be stored as some kind of Merkel tree?

Offline Gentso1

  • Hero Member
  • *****
  • Posts: 931
    • View Profile
  • BitShares: gentso
With Bitshares lobbying itself as a bank and exchange, I personally would like to see a nice little pie chart that shows each accounts holdings and how each asset has preformed over time as well as a overall % + or - change.

This way each time I log in I can see for example first account: gentso it displays 24hr and 7day change as well as total value on the main page. I can then click on that account and see a break down of each individual asset to see whats preforming vs what isn't and adjust my holdings according.

Offline pc

  • Hero Member
  • *****
  • Posts: 1530
    • View Profile
    • Bitcoin - Perspektive oder Risiko?
  • BitShares: cyrano
The latest client (0.6.2) contains the new CLI command:

Code: [Select]
test (unlocked) >>> help wallet_account_historic_balance
Usage:
wallet_account_historic_balance <time> [account_name]                                                 Lists wallet's balance at the given time
Lists wallet's balance at the given time

Parameters:
  time (timestamp, required): the date and time for which the balance will be computed
  account_name (string, optional, defaults to ""): the name of the account for which the historic balance will be returned, "" for all accounts

Returns:
  account_balance_summary_type
test (unlocked) >>> wallet_account_historic_balance "2015-02-26T23:20:00"
ACCOUNT                         BALANCE                     
============================================================
test                     95.09268 BTS
test (unlocked) >>>

The double quotes around the timestamp are mandatory. The timestamp must be given in GMT.
Please note that the balance calculation relies on the transaction history, which is known to be buggy - so double check the results for plausibility.
Bitcoin - Perspektive oder Risiko? ISBN 978-3-8442-6568-2 http://bitcoin.quisquis.de

Offline pc

  • Hero Member
  • *****
  • Posts: 1530
    • View Profile
    • Bitcoin - Perspektive oder Risiko?
  • BitShares: cyrano
Bitcoin - Perspektive oder Risiko? ISBN 978-3-8442-6568-2 http://bitcoin.quisquis.de

Offline arhag

  • Hero Member
  • *****
  • Posts: 1214
    • View Profile
    • My posts on Steem
  • BitShares: arhag
  • GitHub: arhag
It should be comparatively simple to reconstruct a wallet balance at a given point in time by adding up all the records in the wallet's transaction ledger. I could implement an API call for that which can be used either on the console or via RPC.

Oh, is that what Brent is asking for? Only balances owned by a particular wallet rather than the global state of the entire database?

Isn't that pretty much already implemented with the account's transaction history? If he wants it a little more user friendly (like printing out the balances that exist at a specified input time), it should be possible to just make a pretty straightforward script that processes the output of wallet_account_transaction_history. The user could even manually paste the output of that command into a file and run the script off that if they don't want to trust the script with access to the client.

Offline pc

  • Hero Member
  • *****
  • Posts: 1530
    • View Profile
    • Bitcoin - Perspektive oder Risiko?
  • BitShares: cyrano
Actually I've already started thinking about how to do this. :-)

It should be comparatively simple to reconstruct a wallet balance at a given point in time by adding up all the records in the wallet's transaction ledger. I could implement an API call for that which can be used either on the console or via RPC. The GUI part should be handled by someone else if you want that.

If the TX ledger idea works 200 USD is a fair price.
Bitcoin - Perspektive oder Risiko? ISBN 978-3-8442-6568-2 http://bitcoin.quisquis.de

Offline onceuponatime

Maybe you could try PMing 100% delegate candidate pc

He may be interested in contract work while he is waiting to be elected (and success in your request might help him get elected):

https://bitsharestalk.org/index.php?topic=13995.0

If he is interested, and he quotes you a price, you could then post to see if others are interested in contributing.

Offline Brent.Allsop

  • Sr. Member
  • ****
  • Posts: 242
    • View Profile
    • Canonizer.com

I'll offer $200 BitUSD to anyone that gets this implement in any wallet or system I"m willing to load my personal keys into for the wallet.


Anyone else care to contribute to such a bounty?

Or how could one get this on a prioritized the list of things to add to a wallet?



Offline arhag

  • Hero Member
  • *****
  • Posts: 1214
    • View Profile
    • My posts on Steem
  • BitShares: arhag
  • GitHub: arhag
Good question. I suppose one could create a tool to recover this by starting with the present-day balances database and then using all the transactions from the transactions database to work backwards to some point in past. Seems complicated though.

It would be really nice if there was a snapshot command that caused a snapshot of the relevant LevelDB databases at that time. Then another command that let the blockchan_* RPC operate in a mode where they were "stuck" at that snapshot (as well as the ability to switch to any other snapshot or to the present updating live state). There would of course need to be a command to delete old snapshots as well.

It would also be interesting if the config allowed the user to specify blocks to automatically snapshot on when manually forcing a replay of the blockchain, as well as a way to specify the number of blocks (or amount of time) that needs to pass since the last snapshot to automatically do another snapshot as it updates/indexes the blockchain live. This could bloat up the data directory considerably though.

Offline Brent.Allsop

  • Sr. Member
  • ****
  • Posts: 242
    • View Profile
    • Canonizer.com

How does one get a historical wallet balance for an arbitrary time in the past?

Can any wallet or web site easily do this yet?

Brent Allsop