dashed-slug.net › Forums › TurtleCoin Adapter extension support › Invalid number of decimals in deposits › Reply To: Invalid number of decimals in deposits
Hello,
It’s very wise to first start off with a new wallet.
First, some background:
This issue with decimals occurs because the wallets always report the amounts as integers (so as not to lose precision with float values). Then, the wallet or plugin knows how many decimals to shift decimals by before displaying the amounts.
The wallets plugin however stores amounts as decimals always, so the numbers need to be converted. This is why when defining the coin, you need to specify how many decimals it has. The adapter extension comes with the following pre-installed coin data:
symbol,name,wd fee,move fee,qr pattern,amount pattern,explorer tx uri,icon url,decimals
TRTL,TurtleCoin,100,0.00001,turtle:%s,%01.2f,https://explorer.turtlecoin.lol/transaction.html?hash=%s,,2
ARMS,2ACoin,100,0.00001,arms:%s,%01.4f,https://explorer.2acoin.org/?hash=%s#blockchain_transaction,,4
Note that 2Acoin has 4 decimals. This means that the deposited amount of 1 ARMS would be reported as 10000 ARMS by wallet-api
. The coin adapter would then divide that number by 10**4
, and would then store the result, 1
, to the DB. This is how things are supposed to work.
You can use the wallets_turtle_coins
filter to modify this value. Are you using this filter currently anywhere on your site? Normally you should not be using it. The issue is that I do not see how you could be getting the result that you describe, with the unmodified plugin.
What you can do:
Try the following as a test, without resyncing anything and without modifying anything else.
1. Ensure that you are not currently hooking into wallets_turtle_coins
filter from any of your own code.
2. Edit the file wp-content/plugins/wallets-turtlecoin/assets/coins.csv
. On the ARMS
line, edit the “decimals” value of 4 and change it to 10. This will make the adapter shift amounts by 6 more decimals.
3. Delete your ARMS deposits from the DB with DELETE FROM wp_wallets_txs WHERE symbol='ARMS';
4. Delete max-height
again as before and let the wallet sync again. (You don’t need to resync the blockchain or wallets-api
only the coin adapter.)
5. Check that your deposit is now shown correctly as 1 ARMS.
6. If the deposit is shown correctly now, then also check withdrawals just to make sure everything is fine.
with regards
P.S. Please open a new thread about the dates to track this issue.