I reply to all queries on the forums and via email, once per day, Monday to Friday (not weekends).

If you are new here, please see some information on how to ask for support. Thank you!

Invalid number of decimals in deposits

dashed-slug.net Forums TurtleCoin Adapter extension support Invalid number of decimals in deposits

Tagged: ,

Viewing 15 posts - 1 through 15 (of 33 total)
  • Author
    Posts
  • #8950
    d3vnu77
    Participant

    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.
    #8962
    alexg
    Keymaster

    Hello,

    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

    #8983
    d3vnu77
    Participant

    Hmm, not seeming to let me post here.

    #8986
    d3vnu77
    Participant

    Well, 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

    #8987
    d3vnu77
    Participant

    Ok, after the daemon was running I changed the max-height to 1, now it seems to have started to scan from the bottom.

    #8988
    d3vnu77
    Participant

    I 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.
    #8990
    d3vnu77
    Participant

    Completely re-scanned the blockchain, did not import any transactions…

    #8991
    alexg
    Keymaster

    OK 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

    #9015
    d3vnu77
    Participant

    Ok, 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.
    #9018
    d3vnu77
    Participant

    Yes, seems created_time is all zeros in the wp_wallets_txs table.

    Attachments:
    You must be logged in to view attached files.
    #9025
    alexg
    Keymaster

    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.

    #9027
    d3vnu77
    Participant

    I 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.

    #9031
    d3vnu77
    Participant

    this 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.
    #9034
    d3vnu77
    Participant

    The 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.

    #9035
    alexg
    Keymaster

    Hello,

    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 class Dashed_Slug_Wallets_Coin_Adapter_TurtleCoin is abstract. Its concrete implementations are being eval()‘ed. There is a get_decimals() function in file wallets-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 th

    If 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 in coins.csv to get the correct number.

    with regards

    with regards

Viewing 15 posts - 1 through 15 (of 33 total)
  • You must be logged in to reply to this topic.