dashed-slug.net › Forums › TurtleCoin Adapter extension support › Invalid number of decimals in deposits
- This topic has 32 replies, 3 voices, and was last updated 4 years, 4 months ago by alexg.
-
AuthorPosts
-
July 24, 2020 at 2:53 pm #8950d3vnu77Participant
It seems like after the scanning of the blockchain the user balances are correct now, however new deposits that are coming in from mining seems like they are off by 6 decimal places….
The screen shot gives a good representation about what is going on.
The 107400.0000000000 deposit for instance should be 0.10740000
Not sure what is going on here.
Also the hot wallet is still showing way more than there are even coins in existence.
Attachments:
You must be logged in to view attached files.July 27, 2020 at 9:23 am #8962alexgKeymasterHello,
I have moved this into a new thread as it is unrelated to the previous issue that got resolved.
Every fork of TurtleCoin has a number of decimals associated with it. ARMS has 4 decimals (I double checked). This means that any integer value reported by the
wallet-api
must be divided by 10^4.Please do all of the following:
1. What is the content of
wp-content/plugins/wallets-turtlecoin/assets/coins.csv
?2. You mentioned earlier that you were expecting to see 8 decimals, rather than 4. I had given you some sample code of how to use the
wallets_turtle_coins
filter to modify the number of decimals.2.1 Remove this code altogether if you still have it.
2.2 Also, delete all DB data with the following SQL query:
DELETE FROM wp_wallets_txs WHERE symbol='ARMS'; DELETE FROM wp_wallets_adds WHERE symbol='ARMS';
2.3 Also delete the following transient with the following wp-cli shell command, so that the scan restarts:
wp transient delete trtl-ARMS-settings-max-height
2.4 Let the adapter start to resync.
What do you see now? Are the decimals correct?
with regards
July 29, 2020 at 10:23 pm #8983d3vnu77ParticipantHmm, not seeming to let me post here.
July 29, 2020 at 10:35 pm #8986d3vnu77ParticipantWell, it is not letting me post my full answer. Anyhow, it wouldn’t let me delete my transient with wp-cli…
However I found it in the database _transient_trtl-ARMS-settings-max-height : 692781
I deleted that transient and I also ran “rm -rf wp-content/cache/*”
I restarted the RPC daemon
However the same transient keeps getting generated soon after: _transient_trtl-ARMS-settings-max-height : 692781
July 29, 2020 at 10:50 pm #8987d3vnu77ParticipantOk, after the daemon was running I changed the max-height to 1, now it seems to have started to scan from the bottom.
July 30, 2020 at 12:17 am #8988d3vnu77ParticipantI set up an autohotkey script to auto refresh the cron job webpage by pressing F5 every 5 seconds.
After it got to the correct block height that it should have been at > 500000, there is still no transactions entered into the wp_wallets_txs table…
Attachments:
You must be logged in to view attached files.July 30, 2020 at 12:41 am #8990d3vnu77ParticipantCompletely re-scanned the blockchain, did not import any transactions…
July 30, 2020 at 6:33 am #8991alexgKeymasterOK again, this is an unrelated issue to the decimals issue.
1. What do you mean by
wp-cli
not letting you delete the transient? What was the error?2. Have you disabled the object cache you were using (memcached)?
3. If after scanning the transactions, none were imported, could this be because you have deleted the deposit addresses table? The scan will only insert transactions if the deposit addresses are associated with users. The plugin will not simply import any transactions it sees, because it doesn’t know if they belong to a user or not, unless there’s a mapping in the
wp_wallets_adds
table (i.e. only deposits to user deposit addresses will be found).In any case, here’s a summary of what I think:
You’re trying out too many things at once. It’s impossible to know what’s wrong. Start out with a fresh wp installation, with a standard theme and no other plugins and no object cache, and with a fresh 2acoin/ARMS wallet, and see if that works. I have tested the adapter with TurtleCoin deposits and withdrawals and it works fine, so it should work fine for you too.
with regards
August 4, 2020 at 1:01 am #9015d3vnu77ParticipantOk, so it is on a new wallet, all old transactions are gone. I sent a single 2ACoin (1.0000 ARMS) to the new address and it is still off by 6 decimals. Says I received 1,000,000 ARMS. Going to re-read you solutions before to see if we cant fix this.
I think I am going to not try to import the old wallet and just stick with the new wallet to reduce problems in the future. So now I just have to fix the 6 decimal out of place thing…
Also point out an invalid date showing up on the transaction list.
Attachments:
You must be logged in to view attached files.August 4, 2020 at 1:04 am #9018d3vnu77ParticipantYes, seems created_time is all zeros in the wp_wallets_txs table.
Attachments:
You must be logged in to view attached files.August 4, 2020 at 5:02 am #9025alexgKeymasterHello,
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 by10**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 filewp-content/plugins/wallets-turtlecoin/assets/coins.csv
. On theARMS
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 withDELETE FROM wp_wallets_txs WHERE symbol='ARMS';
4. Deletemax-height
again as before and let the wallet sync again. (You don’t need to resync the blockchain orwallets-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.
August 4, 2020 at 12:33 pm #9027d3vnu77ParticipantI changed the coin.csv deciaml place from 4 to 10 on ARMS.
Deleted transactions, re-imported and am still getting amounts that are off by 6 decimals… searching through any code I might have added that might have don’t something like this but I don’t think there is.
August 4, 2020 at 12:54 pm #9031d3vnu77Participantthis is what I get if I dump the tx… basically this is suppose to be 1 ARMS, so the decimal is only being taken down by 2… check my screenshots, am I inheriting the turtlecoin decimals when I should be at 8 decimals?
The amount of 100000000.
Should be 1.00000000 (moved 8 decimals over)Digging deeper into the code to figure this out… sorry I’ve been in and out, been busy with my other business.
Attachments:
You must be logged in to view attached files.August 4, 2020 at 1:00 pm #9034d3vnu77ParticipantThe problem seem to be that when $this->get_decimal_places() is called, it returns 2 instead of 8.
This is because 2 is hard-coded into the get_decimal_places method of the coin-adapter-turtlecoin.php
If I change the hardcoded value to 8, it fixes everything.
August 4, 2020 at 1:08 pm #9035alexgKeymasterHello,
Unfortunately right now you do not know what was wrong and what you have fixed.
The hard coded value is actually being overridden. Check the code in
wallets_declare_adapters()
to see why. The classDashed_Slug_Wallets_Coin_Adapter_TurtleCoin
is abstract. Its concrete implementations are beingeval()
‘ed. There is aget_decimals()
function in filewallets-turtlecoin.php
, line number 133.To fix the decimals issue, first ensure that you are using the code as released. Starting from that, see what you can do to change the coin data, NOT the code. This is why I suggested that you try editing the file
coins.csv
and edit the number of decimals. Because thIf you leave this fix in, then you will again have problems when I release a new version of the adapter.
So first ensure that you have a clean copy of
0.1.2-beta
, then see how you can modify the decimals column incoins.csv
to get the correct number.with regards
with regards
-
AuthorPosts
- You must be logged in to reply to this topic.