laravel-wallet icon indicating copy to clipboard operation
laravel-wallet copied to clipboard

Freezing Wallet Balance During Unconfirmed Transactions

Open hamedkhorasani opened this issue 1 year ago • 6 comments

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

hamedkhorasani avatar Apr 19 '24 14:04 hamedkhorasani

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.

rez1dent3 avatar Apr 19 '24 15:04 rez1dent3

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

hamedkhorasani avatar Apr 19 '24 22:04 hamedkhorasani

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 avatar Apr 20 '24 04:04 rez1dent3

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~

rez1dent3 avatar Apr 20 '24 04:04 rez1dent3

Thanks a lot

hamedkhorasani avatar Apr 23 '24 10:04 hamedkhorasani

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

rez1dent3 avatar Apr 23 '24 11:04 rez1dent3