The Bitcoin and Altcoin Wallets WordPress plugin exposes two Wallets JSON APIs:

  1. The transaction API enables logged in users to perform and view transactions from the frontend.
  2. The notification API lets the wallet daemons notify the system of incoming transactions. (For bitcoind, this maps to -walletnotify and -blocknotify).

Transaction JSON API

Get users info

Retrieves usernames and user IDs of all users on the site.

Used by the [wallets_move] shortcode UI to display a drop-down selection of users to send coins to.

URI path: /wallets/get_users_info

Parameters: none

Example response:

{
"users":[
{
"id":2,
"name":"luser"
}
],
"result":"success"
}

 

Get coins info

Retrieves information relevant to all the coins enabled on the site.

Used by all shortcode front-ends to display a drop-down selection of available coins.

URI path: /wallets/get_coins_info

Parameters: none

Example response:

{
"coins":{
"LTC":{
"name":"Litecoin",
"symbol":"LTC",
"icon_url":"http:\/\/www.turbox.lan:81\/wp-content\/plugins\/wallets-litecoin\/assets\/sprites\/litecoin-logo.png",
"balance":0.00659988,
"balance_string":"\u01410.00659988",
"unconfirmed_balance":0.00659988,
"unconfirmed_balance_string":"\u01410.00659988",
"deposit_address":"LPsj8nDiuBjbvRFR8CDoYhSbd4nDekbBQV"
},
"BTC":{
"name":"Bitcoin",
"symbol":"BTC",
"icon_url":"http:\/\/www.turbox.lan:81\/wp-content\/plugins\/wallets\/includes\/..\/assets\/sprites\/bitcoin-logo.png",
"balance":0.00091565,
"balance_string":"\u0e3f0.00091565",
"unconfirmed_balance":0.00091565,
"unconfirmed_balance_string":"\u0e3f0.00091565",
"deposit_address":"mrXEs8Kbj7mcMU1ZAq84Kdm85Vdd2Xg2b2"
}
},
"result":"success"
}

 

Get transactions

Retrieve past transaction info (deposits, withdrawals and transfers to other users) of the currently logged in user.

Used by the [wallets_transactions] shortcode UI to display a paginated table of transactions.

URI path: /wallets/get_transactions/SYMBOL/COUNT/FROM

Parameters:

  • SYMBOL: The coin’s symbol, e.g. BTC, LTC, etc. Only transactions regarding this coin will be retrieved.
  • COUNT: Retrieve this many transactions
  • FROM: Start retrieving transactions from this offset (for pagination)

Example response:

{
"transactions":[
{
"category":"deposit",
"account":"1",
"other_account":null,
"address":"1rXEs8Kbj7mcMU1ZAq84Kdm85Vdd2Xg2b2",
"txid":"c9c30612ea6ec2509c4505463b6f965ac25e8e2cff6451e480aa3b307377df97",
"symbol":"BTC",
"amount":"0.0000100000",
"fee":"0.0000000000",
"comment":null,
"created_time":"2016-12-17 15:22:14",
"updated_time":"2016-12-30 11:33:14",
"confirmations":"3249",
"other_account_name":null,
"amount_string":"\u0e3f0.00001000",
"fee_string":"\u0e3f0.00000000"
},
{
"category":"move",
"account":"1",
"other_account":"2",
"address":"",
"txid":"move-58629b173cb8f0.44669543-send",
"symbol":"BTC",
"amount":"-0.0000133400",
"fee":"0.0000010000",
"comment":"comment test",
"created_time":"2016-12-27 16:47:19",
"updated_time":"2016-12-27 16:47:19",
"confirmations":"0",
"other_account_name":"luser",
"amount_string":"\u0e3f-0.00001334",
"fee_string":"\u0e3f0.00000100"
},
{
"category":"withdraw",
"account":"1",
"other_account":null,
"address":"1i1B4pkLQ2VmLZwhuEGto3NAJdeh4xJr1W",
"txid":"fed08f9a90c526f2bb791059a8718d422b8fdcb55f719bd36b6e3d9717e815e0",
"symbol":"BTC",
"amount":"-0.0000600000",
"fee":"0.0000500000",
"comment":"withdrawing bitcoins",
"created_time":"2016-12-30 11:44:37",
"updated_time":"2016-12-30 12:46:41",
"confirmations":"12",
"other_account_name":null,
"amount_string":"\u0e3f-0.00006000",
"fee_string":"\u0e3f0.00005000"
}
],
"result":"success"
}

All times are GMT.

 

Move funds to another user

Transfers funds to another user. The transfer fee that the administrator has set in the coin adapter is charged to the sender.

URI path: /?__wallets_action=do_move&__wallets_symbol=SYMBOL&__wallets_move_toaccount=TOACCOUNT&__wallets_move_amount=AMOUNT&__wallets_move_comment=COMMENT

Parameters:

  • SYMBOL: The symbol of the coins to move, e.g. BTC, LTC, etc.
  • TOACCOUNT: User ID of the recipient. The IDs are accessible via get_user_info.
  • AMOUNT: The amount of coins to transfer, excluding any transaction fees. This is the amount that the recipient is to receive.
  • COMMENT: A descriptive string that the sender attaches to the transaction.

Example response:

{  
"result":"success"
}
 
 

Withdraw funds to an external address

Transfers funds to another address on the coin’s network. The withdrawal fee that the administrator has set in the coin adapter is charged to the sender.

URI path: /?__wallets_action=do_withdraw&__wallets_symbol=SYMBOL&__wallets_withdraw_address=ADDRESS&__wallets_withdraw_amount=AMOUNT&__wallets_withdraw_comment=COMMENT&__wallets_withdraw_comment_to=COMMENT_TO

Parameters:

  • SYMBOL: The symbol of the coins to move, e.g. BTC, LTC, etc.
  • ADDRESS: The external address to send coins to.
  • AMOUNT: The amount of coins to transfer, excluding any transaction fees. This is the amount that the recipient address is to receive.
  • COMMENT: A descriptive string that the sender attaches to the withdrawal.
  • COMMENT_TO: A descriptive string that the sender attaches to the address.

Example response:

{  
"result":"success"
}
 
 

 

Notification JSON API

Notify

Notifies the wallets plugin that an event has occurred. The plugin then fires a WordPress action of the form wallets_notify_TYPE_SYMBOL with a single MESSAGE argument, and adapters can decide how to handle this. The notification API does not require login.

In practice this mechanism is useful for receiving deposits and for updating the confirmation counts of transactions.

For the bitcoin daemon, the -walletnotify parameter must be made to call /wallets/notify/BTC/wallet/TXID where TXID is a transaction ID, and -blocknotify must be made to call /wallets/notify/BTC/block/BLOCKHASH where BLOCKHASH is the hash of the latest block announced on the blockchain.

In general it is the responsibility of coin adapters to inform you of how to set up notification.

URI path: /wallets/notify/SYMBOL/TYPE/MESSAGE

Parameters:

  • SYMBOL: The symbol of the coin that this notification is about, e.g. BTC, LTC, etc.
  • TYPE: The notification type, such as wallet, block, alert, etc.
  • MESSAGE: A string that is the payload of the notification.

Example response:

{  
"result":"success"
}

 

Wallets JSON API

Updated on 2017-01-05T16:23:07+00:00, by alexg.