bitforge-me / beryllium

1 stars 9 forks source link

Balance update table #67

Closed djpnewton closed 2 years ago

djpnewton commented 2 years ago

The idea of this PR is basically to remove the tables FiatWithdrawal, FiatDeposit, CryptoWithdrawal, CryptoDeposit and replace them with a single table called BalanceUpdate.

The point of this is to hopefully simplify models.py and then simplify the other modules (like depwith.py, api_endpoint.py, admin.py that currently need to do 4 similar things instead of just having one generic interface

I am still not 100% sure this is a good idea but I think it probably is.

Migrating the actually data would be difficult and I think that maybe if we land this before launching we could just delete the limited deposit/withdraw history on be.bitforge.me

djpnewton commented 2 years ago

making the assumption that i need to run the migrations/582a80fd3fda_balance_update_table.py script. But when i do im getting the error:

ModuleNotFoundError: No module named 'alembic'

no it runs the script when you do ./flask-cli.sh db upgrade but be aware that this will eliminate all your deposit/withdrawal history if you do it because I have not written a data migrator

djpnewton commented 2 years ago

I am wondering if I should add a 'fee' column to the balance_update table.

When we create a withdrawal we create a withdrawal record (balance_update) with an amount but we actually deduct amount + fee from the account. if a withdrawal is cancelled (confirmation times out or user cancels) then we refund the amount back to the users balance but we forget that the fee that we deducted also!

If there is a fee colum to the balance_update table then it is easy to refund the amount + fee when cancelling a withdrawal but also we can show the users the historical fees they paid too which will make their balance make more sense

djpnewton commented 2 years ago

Ok I added the fee column and fixed the withdrawal cancel/refund amount

eoliveros commented 2 years ago

getting the following when trying to do the balance withdrawal according to admin: image

so its including fee for 5 sats? but the actual status is still "CREATED" it never completes. Using HTLC.me, its not receiving what I'm withdrawing. confirmed one of them and it looks like that changes to "completed"

waiitng for the other one to timeout.

djpnewton commented 2 years ago

getting the following when trying to do the balance withdrawal according to admin: image

so its including fee for 5 sats? but the actual status is still "CREATED" it never completes. Using HTLC.me, its not receiving what I'm withdrawing. confirmed one of them and it looks like that changes to "completed"

waiitng for the other one to timeout.

Are you using the link emailed to confirm it?

eoliveros commented 2 years ago

Balance Before: image

Sending 995 sats and waiting for the 30 minute time out and see if the balance goes back to 1000995 sats or only returns 995 sats.

image

new balance: after sending(without confirming) image

so when it gets cancelled, it should still be 1000995 sats.

eoliveros commented 2 years ago

looks like its returned the sats (including the fees) when its cancelled: image