Closed RiskingTime closed 6 years ago
I will confirm further but I believe that the balances being shown here are the confirmed balances, not the available ones. Both of the values from the screenshot above match a confirmed balance for each account at a previous point in time and the current admin interface appears to reflect this as well.
What may be occurring, however, is that the account value may not be refreshed to its most current confirmed balance and it may not be a good idea to force a refresh on all of the accounts listed (we could probably do individual ones, however).
I'll investigate and if I discover that I'm not correct I will provide an estimate on fixing this display value.
We need to approach the balances shown on the admin page differently from the numbers in our database. I would like the numbers to be shown on the admin page table to be derived from the current balances of those addresses ON THE BLOCKCHAIN. this way, we can compare the amounts we actually have to the numbers we have in our database. I think also the cash register account should be shown in the admin page table
the admin page will serve as one way we can "audit" the system balances by comparing the amounts in our database to the amounts we have on the blockchain
I've confirmed that the value being shown on the admin page is the btc_balance_verified
field from the accounts table. This field represents the on-blockchain (confirmed/verified) balance for the account but, as I mentioned, we don't always keep this information synchronized in order to minimize BlockCypher API usage. We will need to discuss a solution in further detail.
here is some additional illustration that hopefully shows what I'm trying to describe
the cold storage and cash register addresses in this list will be provided by me. This table should be useful like a bank balance sheet, as the bitcoins in our control are our assets, but our liabilities are the amounts our database says are available to users as their in-game and investment balances.
Thanks for clearing up this issue for me earlier. To recap our phone conversation, the values shown here should come from blockchain API calls that are initiated by the browser, as opposed to using our server as an intermediary. However, we also want to include information from our database to see how much the on-blockchain values and our database values diverge -- this could be an indicator of how many users deposited Bitcoin without ever using any functionality that requires its confirmation (investments or withdrawals).
We will want to display these differences beneath the table -- do we also want to include both the live blockchain balance and our database balance as separate columns?
We may be able to send multiple requests to the API in a single go but for the time being I think we should assume that we'll need some sort of progress reporting on the client (browser), to indicate how many accounts have been checked on the blockchain. We will also need some sort of error reporting since some of this functionality will be handled exclusively on the client side.
I would estimate that this update would take about 4 hours to implement based on this description.
ok, let's discuss this further before proceeding, focus on dividend payments first
I'm not sure we are on the same "page", I'll further describe what my admin page objectives are...
need to be able to compare the money we actually have (bitcoins on addresses that we control), with the money we tell users they have (numbers in our database). And in order to confirm this, we need to get the info from different places. Our database knows all the bitcoin deposit addresses we've generated for users, so we then need to see which of these addresses has money on it, but in order to do this, we don't ask our database, we need to ask the blockchain, then we list all the addresses and their associated balances (according to the blockchain). We can use blockcypher to do this, or we can also use any blockchain explorer. It might even make sense to not use blockcypher in this case because we want the data to be generated independently from our database. We will use the data from the blockchain to compare to what is in our database, then we can see whether we have enough bitcoins in our control in order to satisfy our depositors.
I would like three tables to be displayed on the admin page. 2 of those tables will be lists of transactions, and 1 of those tables will be a "balance sheet".
the first table should be a list of rake transactions with the following columns (date, description, amount, balance). The date column should show the date & time, the description column should list where the transaction came from (i.e. the investment e.g. "bankroll" dividend), the amount column should show the transaction amount (i.e. the amount credited to the rake account due to this transaction), and the balance column should show the current balance of the rake account (which should also equal the sum of all transactions).
so if the bankroll gained 1 btc during the period, and we are raking 5% of this amount, then the "amount" column in the rake transaction table should show 0.05 btc. If this was the first distribution, then the "balance" column should also show 0.05. Say the next day goes by and the bankroll makes 0.50 then we rake 5% and so the "amount" column for this transaction should show 0.025 and the "balance" column should now show 0.075 (which is the total now in the rake account). These amounts need to be logged somewhere in our database, so we can audit the data.
the second table should show a list of bankroll distribution transactions with associated details. the table should have the following columns (date, description, gross dividend, rake amount, net dividend, balance). The "description" column should show which investment the transaction is from (i.e. "bankroll" dividend), the "gross dividend" is the total amount that the investment made during the period (i.e. the amount before rake is removed), the "rake amount" should show the amount that was raked from the gross dividend, and the net dividend should show the net amount attributable to bankroll investors (gross - rake = net). The "balance" column should show the balance of the investment at the time the transaction occurred.
it should also be noted, that for each period, the rake amount listed in the "rake transactions" table should equal the number for rake listed in the "bankroll distributions" table. it should also be noted that if no games were played since the bankroll distribution was made, the amount in the "balance" column of the "bankroll distributions" table should equal the number displayed as the current value of the bankroll on the stats page.
more description on the "balance sheet", if the first user to the site opens an account and makes a deposit of 1 btc, then we will have a user account with an available balance of 1 and a bitcoin address in our control with 1 bitcoin on it. this bitcoin address should be listed in the "balance sheet" table and show a balance of 1. On our stats page, we should be displaying "in game balances" of 1 and total of 1. So we are in balance.
now let's say a second user comes to the site, deposits 1 btc and then invests this in the bankroll investment. the first user plays the game and loses 0.5 btc.
the stats page should show "in game balances" of 0.5 btc, the "bankroll" investment should have a "book value" of 1 btc and a "current value" of 1.5 btc. back on the admin page, our "balance sheet" should show 2 addresses with 1 bitcoin each on them since we haven't moved the bitcoins anywhere (and since two users each deposited 1 bitcoin each). The "total current value" on the stats page should read 2 btc (since 0.5 was lost by one user and is now part of the bankroll investment)
if time goes by and bankroll dividends are paid, rake is collected, affiliates are paid out, no matter what happens, we always need to have more bitcoins in our possession then we owe our users. i.e. the total current value listed on the stats page must always be equal to or less than the amount of bitcoins we have on all user addresses plus our cash register address and the amounts we have in cold storage.
balances showing as "confirmed balance" on the admin page look like "available balances", this page should show all the addresses that have bitcoins on them