bavix / laravel-wallet

It's easy to work with a virtual wallet
https://bavix.github.io/laravel-wallet/
MIT License
1.11k stars 222 forks source link

Freezing Wallet Balance During Unconfirmed Transactions #939

Closed hamedkhorasani closed 4 months ago

hamedkhorasani commented 4 months ago

Dear @rez1dent3, I'm interested in freezing the wallet balance during unconfirmed transactions. Could you guide me on achieving this functionality?

rez1dent3 commented 4 months ago

Hello. If you need a solution out of the box, then you can use the credits functionality for this. https://bavix.github.io/laravel-wallet/#/credit-limits

Place a lock on your wallet through the AtomicServiceInterface, create an unconfirmed transaction and reduce the credit limit (default is zero).

When you confirm or cancel a transaction, you return the credit limit back.

hamedkhorasani commented 4 months ago

How can I apply credits during deposit, withdrawal, or transfer?

rez1dent3 commented 4 months ago

Demo: https://github.com/bavix/laravel-wallet/pull/940

It will work similarly with all operations. Essentially, a negative credit limit will prevent operations from working (without the force flag).

IMPORTANT! Here you monitor the update of meta and race condition yourself, and not the package, as is the case with the balance.

rez1dent3 commented 4 months ago

unconfirmed transactions.

~I realized that I didn't pay attention to the word "unconfirmed".~

~Then the answer is similar to this: https://github.com/bavix/laravel-wallet/discussions/937~

hamedkhorasani commented 4 months ago

Thanks a lot

rez1dent3 commented 4 months ago

Were you able to solve your problem? Can the issue be closed?