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!

Integrating Custom Wallet Adapter Methods into UI Shortcode

dashed-slug.net Forums General discussion Integrating Custom Wallet Adapter Methods into UI Shortcode

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #13708
    ailtonbauque
    Participant

    Hello,

    I am currently in the process of developing a custom wallet adapter for bitcoin-altcoin-wallets-wordpress-plugin, specifically tailored to interface with a mobile wallet API for fiat currencies.

    I have successfully implemented the adapter along with its required methods. However, I am now seeking guidance on how to integrate these methods into the plugin’s UI shortcode functionality. From my observation, the plugin currently utilizes a REST API approach using JavaScript, Knockout.js.

    How can I call the methods from my custom wallet adapter within the UI shortcode? Specifically, implementing functionalities such as depositing funds via the shortcode interface.

    Any assistance or documentation you can provide regarding integrating this into the plugin’s frontend UI would be greatly appreciated.

    Thanks for your attention.
    Best regards,

    #13709
    alexg
    Keymaster

    Hello,

    It sounds like you are doing something wrong.

    If you have implemented the wallet adapter correctly, then you shouldn’t have to do anything else. You should be able to perform deposits and withdrawals via the plugin’s built-in UIs ([wallets_deposit] and [wallets_withdraw]). The WP-REST API is useful only if you want to add new UIs, such as functionality that doesn’t already exist in the plugin.

    Available materials

    The documentation and sample code for implementing a wallet adapter is here:

    https://github.com/dashed-slug/wallets/blob/6.3.1/docs/developer.md#developing-wallet-adapters-wallet-adapters

    You can also study the Monero Wallet adapter which is available for free download, or the build-in Bitcoin core adapter, which works for any forks of Bitcoin core with the same RPC API (Litecoin, Dogecoin, Bitcoin Cash, etc).

    I wouldrecommend that you start by following the instructions to setup the adapter and its settings. You may want to start from this template code: https://github.com/dashed-slug/my-wallet-adapter

    Withdrawals

    Implementing withdrawals is easy: just fill in the implementation for do_withdrawals(). Process the withdrawals and change their state on the withdrawal transactions afterwards. You can also set any TXID or timestamp or other data if you like. They will be saved by the plugin to the DB after the do_withdrawals() call.

    Here’s how the withdrawals are implemented for Bitcoin core:

    https://github.com/dashed-slug/wallets/blob/6.3.1/adapters/class-bitcoin-core-like-wallet-adapter.php#L429-L593

    Deposits

    Implementing deposits is a two step process:

    1. Implement the get_new_address() method which should return a new DSWallets\Address for the wallet. This is what the shortcode [wallets_deposit] displays.

    2. Implement deposit detection via polling: You would typically do this in the adapter’s cron() method which is called periodically. Once your cron code detects a new deposit, create a deposit DSWallets\Transaction object, and pass it to do_deposit() from the abstract superclass:

    https://github.com/dashed-slug/wallets/blob/6.3.1/adapters/abstract-wallet-adapter.php#L326

    The adapter’s cron() method gets called on cron runs, but not on every one. The plugin rotates between all active wallet adapters, and calls the cron() method of only one adapter each time. To see what cron tasks are run, you can enable verbose logging from the plugin’s settings.

    The withdrawals are executed by the DSWallets\Withdrawals_Task cron.

    The cron() method is executed by the DSWallets\Adapters_Task cron.

    If you end up publishing your adapter, let me know if you want me to add a link from this website to the adapter.

    Hope this helps. Please do contact me with any questions you may have about the plugin.

    with regards

    #13712
    ailtonbauque
    Participant

    Thanks, it helped.
    Definitely I was it approaching wrong. Went throughout the docs with your explanation and it’s starting to work.

    Yes, I will let you know when I publish it or have other issues.

    Thank you for your attention.
    Best regards,

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