Processing payments (3rd party integration)
Daemon & Wallet as RPC
If you want your website or service to work with CryptoNote currencies you will have to tweak a few things in the daemon and wallet.
First of all you should start both daemon and simplewallet in RPC mode. For the daemon to work as RPC you don’t have to do much; simply start it as usual.
To start the wallet JSON RPC API server you should specify the port to which the server binds (additionally to standard wallet's arguments). You may choose any free port. Execute the following command from the command line:
simplewallet --wallet-file=example_wallet.bin --pass=12345 --rpc-bind-port=8082
Note: if you'd like your daemon to accept incoming connections from the outside of your local machine, you should start the daemon with the following arguments: --rpc-bind-ip=0.0.0.0 --rpc-bind-port=arg. You should also specify an IP address of the daemon when starting simplewallet. There are a few ways to do that:
simplewallet connects to the daemon instance at host:port
simplewallet cinnects to the daemon instance at host arg instead of localhost
simplewallet connects to the localhost daemon instance at port arg instead of 8081
To sum it up, you should start simplewallet as follows:
simplewallet --wallet-file=example_wallet.bin --pass=12345 --daemon-address=220.127.116.11:8082
simplewallet --wallet-file=example_wallet.bin --pass=12345 --daemon-host=18.104.22.168
simplewallet --wallet-file=example_wallet.bin --pass=12345 --daemon-port=8082
1. For simplewallet operating in RPC mode the "refresh" command is not working. The balance is automatically refreshed every 20 seconds.
2. You should not launch more than 1 instance of the same wallet in RPC mode.
Services accepting deposits in the CryptoNote currency should run only 1 instance of the simplewallet for each of the currencies. Due to the CryptoNote’s high cryptographic security and anonymity the process of reaching out to the multiple addresses would require a lot of resources. In order to solve this problem a new feature called payment_id was introduced. Payment_id allows the service to run only 1 wallet for all the incoming payments of all its users. The unique payment_id argument of the transfer should be generated for each of the website's users in order to identify deposits.
To create a payment_id you should generate random 32 bytes of data and then convert it to HEX. All you have to do is assign payment_id to each of your users. Users will be sending you the funds using “transfer mixin_count address amount payment_id” command. We suggest you help your users by providing them with the complete transfer command including the payment_id.
To check for user’s payments you should use get_payments method. This method returns all the payments with the corresponding payment_ids that were deposited to the wallet.
Note: please, avoid crediting user balances until they deposits are confirmed and unlocked in your wallet. The number of blocks for the funds to get unlocked may vary across CryptoNote currencies.
Cold and hot storage
The whole cold/hot wallet concept is based on the fact that it’s easier to hack the wallet that is connected to the internet.
Thus, we strongly recommend you to create a new wallet, synchronize it with a network, transfer the majority of your funds to it, disconnect it from the network, and upload this wallet to an encrypted flash drive or any other secure offline device.
For everyday transfers we recommend you to create a different wallet that will contain amount of funds that are required for your normal operations.
Transfer payments through the wallet RPC
Transfer method looks as follows:
Please note, payment_id is an optional argument and may be left out.