HOWTO: Debug an incoming deposit (full node wallet)

You have configured the built-in Bitcoin core coin adapter, or a full-node coin adapter with the Bitcoin and Altcoin Wallets plugin. Deposits do not get credited to user balances. Here’s how to debug:

① Check that the adapter is correctly configured.

Go to WalletsAdapters and find your coin adapter entry. The “Status” column should indicate “Responding” for this adapter.

② Make sure that you are sending funds from an external wallet to a user deposit address.

Sending to the cold storage deposit address will not credit the deposit to any user.

③ Make sure that the user deposit address was generated by the wallet that you have currently connected.

If you have recently changed your wallet back-end, then go to WalletsAdapters and click on Renew deposit addresses. This will mark all existing deposit addresses as “old”. After this, when a user logins to your site, they will be assigned a new deposit address that was generated from the currently connected wallet.

④ Verify that the full node wallet knows about your transaction.

Use ssh to connect to the server where you run the wallet. First, check that the blockchain is fully synced. For Bitcoin core, to check the block height, issue the command:

bitcoin-cli getblockchaininfo

And take a note of the “blocks” number in the result. This should match the block height, as it is reported in any public block explorers for your coin’s chain. The command for your wallet might be different. You can also try getinfo if getblockchaininfo does not work.

To get a list of recent transactions:

bitcoin-cli listtransactions

To see information about a particular transaction, issue the following (and replace “TXID” with the actual transaction ID):

bitcoin-cli gettransaction TXID

To see which transactions have been received on which addresses that your wallet knows about:

bitcoin-cli listreceivedbyaddress

If the transaction is not shown in the wallet, then check your transaction ID.

⑤ Check to see if the JSON API notification URL works.

In order for the plugin to know that there is a new deposit, the wallet needs to notify the plugin about the TXID of each new transaction. To notify the plugin on website example.com that a transaction with ID “TXID” has been created or altered, visit the following link with your browser

https://example.com/wallets/api3/notify/BTC/wallet/TXID

replacing “BTC” with your coin symbol and “TXID” with your actual transaction ID (a long hex string).

You should get a JSON response from the API:

{"result":"success"}

If you get an error from your webserver, such as a “404: Not found”, this is an issue with your permalinks, or webserver redirects. Go to SettingsPermalinks and hit “Save Changes”. Also check your web server redirects. The default .htaccess for Apache is here and the default Nginx configuration is here. Backup your current settings, replace them with the defaults, restart your server and try again.

Finally, if for any reason you still cannot access the notification API, try the alternative notation that uses GET parameters instead of permalinks. The following URL:

https://www.example.com/wallets/api3/notify/BTC/wallet/TXID

is equivalent to:

https://www.example.com/?__wallets_apiversion=3&__wallets_action=notify&__wallets_symbol=BTC&__wallets_notify_type=wallet&__wallets_notify_message=TXID

(again, replace “www.example.com” with your site’s domain, replace “BTC” with the ticker symbol of your coin, and replace “TXID” with an actual deposit transaction ID)

If only the long form works, then you can setup your wallet’s config as follows:

walletnotify=curl -ks https://www.example.com/?__wallets_apiversion=3&__wallets_action=notify&__wallets_symbol=BTC&__wallets_notify_type=wallet&__wallets_notify_message=%s >/dev/null

again replacing the domain name with that of your site, and BTC with the symbol of your coin.

⑥ Check that the wallet actually performs the API call.

By now you should have seen the response {"result":"success"} by manually triggering the notification API. Calling this forces the plugin to check that transaction. If any of its outputs is a user deposit address, the plugin will create an entry of type “deposit” in the admin transactions list (WalletsTransactions admin screen). Subsequent API calls will force the plugin to re-check the transaction and update its confirmation count. Once the confirmation count reaches that specified in the coin adapter settings, the deposit status will become “confirmed”.

If you do not see the transaction row at all, check to see if the wallet performs the API call.

First, login to the server where the wallet runs and check to see if curl installed. If you type curl and you get something like curl: command not found then you should install curl using your distribution’s package manager. For debian-based distributions the command would be sudo apt-get install curl and for CentOS it would be sudo yum install curl.

You can check your web server’s access logs for this.

Another way to check is to modify the walletnotify argument of your wallet, so that it writes out a log file. For example:

walletnotify=curl -k --verbose https://www.example.com/?__wallets_apiversion=3&__wallets_action=notify&__wallets_symbol=BTC&__wallets_notify_type=wallet&__wallets_notify_message=%s >>~/walletnotify.log

Restart your wallet and this will write out verbose debug output from curl into a file walletnotify.log in your home directory. Check the file to see if there’s any errors.

Comments:0

Leave a Reply

Your email address will not be published. Required fields are marked *