Support » Plugin: Bitcoin and Altcoin Wallets » Shortcode / single coin value

  • Resolved Surrealer

    (@surrealer)



    Hello,
    ***** Starts for you and your great plugin 🙂
    is there an easy way to show the balance of a single coin of a specific user?
    I want to use it for a looped list generated by another plugin with other details.
    This list is part of the user profile and can be set to be public for friends, thats why I need a user_id filter.
    like:
    [wallets_balance template=”single” coin=”bitcoin” user_id=”1″]

    Can you help me to find a solution for this?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author dashed-slug.net

    (@dashedslug)

    Hello,

    Unfortunately the plugin architecture does not easily lend itself to this.

    The reason is that the data displayed is live data, made available through an API, that only exposes information relevant to the current user. The frontend UIs have no access to other people’s balances.

    There is nothing stopping you from calling the PHP API to get other user’s balances. Documentation is here: https://wallets-phpdoc.dashed-slug.net/classes/Dashed_Slug_Wallets_PHP_API.html#method_api_balance_filter

    You could then write some PHP code to loop over your users and write out any markup you like. Hope this helps!

    kind regards
    Alex

    Hello Alex,
    that was almost what I was looking for 🙂
    I only have one problem to work around:

    I have a list of coin symbols that I loop through, when it comes to “XRP” it throws me out:
    Fatal error: Uncaught Exception: Adapter for “XRP” is not online for getting a deposit address in /www/htdocs/w00da232/crypta.arnewerner.com/wp-content/plugins/wallets/includes/php-api.php:835

    Sure I understand that your plugin can’t find that coin because it’s not supported, but how can I prevent this?
    I tried something like:

    $coin_symbol = “XRP”

    try {
    $balance = apply_filters( ‘wallets_api_balance’, 0, array(
    ‘symbol’ => $coin_symbol,
    ‘user_id’ => 1,
    ‘confirmed’ => false,
    ) );
    echo $balance
    } catch(\Exception $e) {
    echo “0”
    }

    But I couldn’t get it to work.

    Can you tell me what I’m doing wrong or is there an easier way to check if a coin symbol is supported?

    Plugin Author dashed-slug.net

    (@dashedslug)

    Hi,

    Your filter call looks correct. Additionally, the XRP coin should be supported when you use the CoinPayments adapter, as long as you have enabled it both in your CoinPayments account and in the coin adapter settings.

    Additionally, are you certain that you get that error while calling the wallets_api_balance filter? The Exception you report is normally returned when you request a new deposit address from the adapter (wallets_deposit_address filter) while the wallet’s API is not contactable.

    If you could show me the entire stack trace for that exception, maybe we could figure out what is going on.

    Let me know please.

    kind regards

    oh thank you for the hint with XRP, this was on a different tab to activat on CoinPayments.

    My Code:

    $btc_balance = apply_filters( 'wallets_api_balance', 0, array(
    	'symbol' => $coin_symbol,
    	'user_id' => 1,
    	'confirmed' => false,
    ) );
    
    	$deposit_address = apply_filters( 'wallets_api_deposit_address', '', array(
    	'symbol' => $coin_symbol,
    	'user_id' => 1,
    	'check_capabilities' => true,
    	'force_new' => false,
    ) );

    here is the full error:
    Fatal error: Uncaught Exception: Adapter for "EOS" is not online for getting a deposit address in /wp-content/plugins/wallets/includes/php-api.php:835 Stack trace: #0 /wp-includes/class-wp-hook.php(286): Dashed_Slug_Wallets_PHP_API->api_deposit_address_filter('', Array) #1 /wp-includes/plugin.php(203): WP_Hook->apply_filters('', Array) #2 /wp-content/plugins/coin-market-cap/includes/cmc-shortcode.php(634): apply_filters('wallets_api_dep...', '', Array) #3 /wp-content/plugins/coin-market-cap/includes/cmc-shortcode.php(362): CMC_Shortcode->gernate_coin_html(Array, 'USD', '253', true, true, true, true, true, true, true, true, false, Array, 'http://crypta.a...', 'svg-charts') #4 /wp-includes/shortcodes.php(319): CMC_Shortcode->cmc_shortcode(Array, '', 'coin-market-cap') #5 [inte in /wp-content/plugins/wallets/includes/php-api.php on line 835

    I also have this error message only when Triggers (TRIG) Coin is activated:

    Fatal error: Uncaught Exception: The Triggers on CoinPayments adapter failed on get_new_address(): The API call returned error: Too many errors in the last two minutes from XX.XXX.XX.XX - please fix your code and try again... in /wp-content/plugins/wallets-cp/includes/coin-adapter-coinpayments.php:145 Stack trace: #0 /wp-content/plugins/wallets/includes/php-api.php(845): Dashed_Slug_Wallets_Coin_Adapter_CoinPayments->get_new_address() #1 /wp-includes/class-wp-hook.php(286): Dashed_Slug_Wallets_PHP_API->api_deposit_address_filter('', Array) #2 /wp-includes/plugin.php(203): WP_Hook->apply_filters('', Array) #3 /wp-content/plugins/coin-market-cap/includes/cmc-shortcode.php(618): apply_filters('wallets_api_dep...', '', Array) #4 /wp-content/plugins/coin-market-cap/includes/cmc- in /wp-content/plugins/wallets-cp/includes/coin-adapter-coinpayments.php on line 145

    What I need is just a simple way to proof if there is an adapter for a specific coin, I also have other coins listed that are not supported by your plugin so far like:
    (EOS)EOS
    (ADA)Cardano
    (XLM)Stellar
    (MIOTA)IOTA
    (TRX)TRON

    Thank you and kind regards
    Arne

    • This reply was modified 3 months, 3 weeks ago by  Surrealer.
    Plugin Author dashed-slug.net

    (@dashedslug)

    Hello Arne,

    1. The first error you get is to be expected. I do not see EOS in the current list of supported coins in CoinPayments. The supported coins are listed here https://www.coinpayments.net/supported-coins

    2. The “Too many errors… please fix your code” error is a generic error coming from the CoinPayments platform. They rate-limit invalid API calls to encourage people to write less buggy code. One instance where this error would show up would be if you have entered invalid credentials, but if the adapter already works for some coins, then it is probably something else. Another instance where I saw that error in the past was with the NVO (NVST) token, where the platform refused to give a deposit address, so I had to disable that coin. It is also possible that this error is caused because you are repeatedly requesting an EOS deposit address, and that impacts later API calls.

    Stop calling EOS, disable the plugin, leave it to rest for two minutes, then enable it again, and observe the first error you get in your logs. This will be a more meaningful error and we can have a look at why it occurs once we know what it is. If a particular coin is causing the problem, you should attempt to disable it and see if it fixes the problem.

    3. To answer the other point you addressed, I do have plans to create an IOTA adapter for the Trinity wallet in the future. This cannot be any time soon as I am way too busy. Currently I have no plans to support the other coins you listed, but that is not to say that another developer cannot provide coin adapters for them. All the necessary technical info is in the documentation.

    So please let me know if you find out what the error is.

    kind regards
    Alex

    P.S. If in the future you have any further questions about the CoinPayments adapter extension, please note that the support forum for it is at https://www.dashed-slug.net/forums/forum/coinpayments-net-coin-adapter-extension-support/ This forum is for the parent plugin that is hosted here on WordPress.org.

    Hello Alex,

    thanks for your fast reply, even when you are busy 🙂

    1. Yes you are right, I know that EOS is not supported, but how do I check your at your pugin if a coin is valid or not without spamming the coinpayments api or getting exceptions from your plugin?
    I solved it with a mix of case / ifelse, but that is horrible, I don’t want to change the code every time a coin is not working or when a new one is added by your plugin.
    I tried it with try/catch but couldn’t get it to work and there must be a better way to check it without catching exceptions, any ideas?

    2. I disabled the EOS(+other) request and only request coins that are supported.
    Disabled the plugin + coin adapter, waited 3 minutes, activated them again.
    All other coins work, when I have activated “Triggers (TRIG)” I still get the error, here the log:

    PHP Fatal error: Uncaught Exception: The Triggers on CoinPayments adapter failed on get_new_address(): The API call returned error: Could not get a deposit address, please try again in a few minutes... in /www/htdocs/XXX/XXX.com/wp-content/plugins/wallets-cp/includes/coin-adapter-coinpayments.php:145
    
    Stack trace:
    #0 /www/htdocs/XXX/XXX.com/wp-content/plugins/wallets/includes/php-api.php(845): Dashed_Slug_Wallets_Coin_Adapter_CoinPayments->get_new_address()
    #1 /www/htdocs/XXX/XXX.com/wp-includes/class-wp-hook.php(286): Dashed_Slug_Wallets_PHP_API->api_deposit_address_filter('', Array)
    #2 /www/htdocs/XXX/XXX.com/wp-includes/plugin.php(203): WP_Hook->apply_filters('', Array)
    #3 /www/htdocs/XXX/XXX.com/wp-content/plugins/coin-market-cap/includes/cmc-shortcode.php(617): apply_filters('wallets_api_dep...', '', Array)
    #4 /www/htdocs/XXX/XXX.com/wp-content/plugins/coin-market-cap/includes/cmc-shortcode.php(362): CMC_Shor in /www/htdocs/XXX/XXX.com/wp-content/plugins/wallets-cp/includes/coin-adapter-coinpayments.php on line 145

    You said you had a similar error before with another coin,
    wouldn’t it be better by the plugin to “test” the coin payment adapter before and see if it response and skip it if not? So you don’t need to update the plugin every time and if the api works correctly again you don’t need to make another update.

    I also noticed that when I activate debug mode and the coin adapter, I get the following popup warning on every site:
    Status: parsererror Fehler: SyntaxError: Unexpected token < in JSON at position 37758
    What to do about that? Can’t even debug my site anymore because the popup blocks all actions and will show up over and over again after some time or page reload.

    Is this point correct here or should I repost it to the other support forum?

    3. Oh cool Trinity support would be awesome!
    Is there any multi wallet api that you would recommend to create a coin adapter to support a bright range of other altcoins?
    My goal is to support as many coins / wallets + balances as possible and there are still some of the top 100 coins missing.

    Kind regards Arne

    P.S. is it possible for you to edit delete my old post? it contains my server path.
    I saw it to late and can’t edit it anymore

    • This reply was modified 3 months, 3 weeks ago by  Surrealer.
    • This reply was modified 3 months, 3 weeks ago by  Surrealer.
    • This reply was modified 3 months, 3 weeks ago by  Surrealer.
    • This reply was modified 3 months, 3 weeks ago by  Surrealer.
    Plugin Author dashed-slug.net

    (@dashedslug)

    Hello Arne,

    1. To iterate through all the adapters that are online you should use this filter: https://wallets-phpdoc.dashed-slug.net/classes/Dashed_Slug_Wallets_PHP_API.html#method_api_adapters_filter

    2. Indeed I had tested with all the coins but then CoinPayments added a bunch more coins and it’s hard for me to keep up with all the other things I do. If you notice that one coin does not work, simply disable it and let me know. Thanks!

    3. This is because there is some error in your code and the error message spills into your JSON API responses. Either set define( 'WP_DEBUG_DISPLAY', false ); or better yet resolve the error. I would recommend that you do both.

    3. There are multiple options but I have not yet had time to review them. Not any exchange can be used as a cloud wallet. You need an API where you can assign labels to addresses so that you can keep track of who deposits what.

    Hope this helps.

    P.S. I am not sure how you can remove your posts here, but you can edit them for some limited time. If you had used the forums on dashed-slug.net I could delete them for you 🙂 You might have to contact the admins of wordpress.org. You probably have the right to have your own posts deleted and they might be willing to help you.

    Surrealer

    (@surrealer)

    Thank you, I’ve could solve it

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.