Jump to content
McKay Development

The balance is showing as a negative number.


Recommended Posts

country is ID

The actual balance is 22,517,929.24

After logging in, a wallet event was triggered, and it's showing an incorrect balance of -20431743.72

 

Could anyone help me understand what might be going wrong and guide me on how to fix it?

Edited by miaomiaomiao
add content
Link to comment
Share on other sites

  • 2 weeks later...
Received wallet info update: {
  has_wallet: true,
  balance: -2132471336,
  currency: 15,
  balance_delayed: 0,
  balance64: '2162495960',
  balance64_delayed: '0',
  realm: 1
}
this is a wallet event  balance64 is Correct 

 

// source code

this.emit('wallet', body.has_wallet, body.currency, body.balance / 100);
this.wallet = {
    hasWallet: body.has_wallet,
    currency: body.currency,
    balance: body.balance / 100
};

body.balance  use body.balance64 is ok

doctor can update this?

Link to comment
Share on other sites

  • 2 months later...
On 6/20/2024 at 3:44 AM, miaomiaomiao said:
Received wallet info update: {
  has_wallet: true,
  balance: -2132471336,
  currency: 15,
  balance_delayed: 0,
  balance64: '2162495960',
  balance64_delayed: '0',
  realm: 1
}
this is a wallet event  balance64 is Correct 

 

// source code

this.emit('wallet', body.has_wallet, body.currency, body.balance / 100);
this.wallet = {
    hasWallet: body.has_wallet,
    currency: body.currency,
    balance: body.balance / 100
};

body.balance  use body.balance64 is ok

doctor can update this?

The reason this is happening is because balance is a 32 bit integer. Ur balance goes above the 32 bit integer limit so what it is doing is when it overflows over the INT_MAX (2147483647) it "resets" to INT_MIN (-2147483647) and adds the remainder of Balance - INT_MAX which is (15012313) back to INT_MIN which makes it -2132471336.

 

Just use balance64 and you should be good but if you NEED to use balance you can just do

balance + 2 + 2 * INT_MAX
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...