ATMs that accept Dollars and Return CloudCoins

From CloudCoin Wiki
Jump to: navigation, search

ATM machines can receive Dollars and return CloudCoins. The customer will need to tell the ATM their Skyvault account.

Step 1: Create a Skyvault Account

NOTE:

CloudCoin Developers are happy to walk you through the process of integrating CloudCoin onto your exchange including spending weeks over Skype helping you set things up. We estimate that it should take no more than one developer two weeks to implement.

SkyVault is a virtual bank that allows you to store, send, receive and transfer CloudCoins. Each Skyvault account has an address. A sample address would be 'Sean.CloudCoin.global', 'Bill.Skyvault.cc' or 'Payments.BigExchange.com'. You and your customers will need SkyVault Accounts to use as wallets.

  1. Go to SkyVault.cc
  2. Click on "Get Skyvault"
  3. Enter a temporary wallet name for your account. If your exchange is called Foo, you would choose "Foo.Skyvault.cc" as your wallet name and Skyvault Address.
  4. Click the "GET SKYVAULT" button. You will then receive a virtual Skyvault debit card as a PNG. Click on the "DOWNLOAD YOUR SKYVAULT DEBIT CARD" button to download it. Keep this PNG safe. You will need to have it on your web server.
  5. Look at the IP address on the back of the Debit Card. This translates to the decimal serial number of your Skyvault Account. You will need this in the next step.
  6. Now you need to create another SkyVault account to act as the test customer. Logout of SkyVault and create another account called something like "testCustomer883.skyvault.cc". Again, download this PNG file and keep it in a safe place.

Step 2. Add Some DNS Records To Your DNS Zone

You will create DNS records so that people can figure out your Skyvault address and find your webhook. This allows them to send you payments and allows them to tell you in real time that their payment was sent.

Example:

cloudcoin.mydomain.com. IN	A	1.63.140.196
cloudcoin.mydomain.com. IN     TXT  "https://host.mydomain.com/verify_payment.php"

1. Create an 'A' record on your DNS server.

  • The type will be 'A',
  • The Name will be 'cloudcoin'
  • The IPv4 Address will be the number on the back of your Skyvault debit card.
  • The TTL with be 'Auto'.*
  • Make sure you do not proxy this 'A' record but use DNS only (only applicable if your DNS supports proxy. Most do not).


2. Test that your DNS records are working by going to a command prompt (Windows) and typing:

nslookup cloudcoin.youdomain.com

where you replace "yourdomain.com" with the name of your domain. You should receive the IP address that is on the back of your Skyvault Debit card.

Step 3. Install SkyVault Connect CLI on your Linux Server

1. Download the latest version of the skyvault_connect binary https://cloudcoinconsortium.com/zip/skyvault_connect.zip If you need a version that runs in Windows, let us know.

2. Install it to the bin directory and give it exec permissions

# cp skyvault_connect /usr/local/bin
# chmod +x /usr/local/bin/skyvault_connect

3. Impersonate a web-user on your server (e.g. apache, nginx, www, www-data) and define the home directory (e.g. /var/www).

# mkdir -p /var/www/cloudcoin_manager
# chown www-data:www-data /var/www/cloudcoin_manager
# su -m www-data

4. Run the program and make sure the output ends with a json string

$ /usr/local/bin/skyvault_connect -home /var/www -debug -cli

RESULTS: 
{"code":4189,"message":"Command is missing","details":null}

5. Put your Skyvault debit card png file in to the SkyWallets folder (You got this when you created the account) Note: This location assumes you are using it on a web server. You may place it somewhere else.

$ mkdir /var/www/cloudcoin_manager/SkyWallets/sw.skyvault.cc
$ cp sw.skyvault.cc.png /var/www/cloudcoin_manager/SkyWallets/sw.skyvault.cc/

6. Execute the SkyVault Connect's 'balance' command to make sure the program recognized the Debit Card Account.

$ /usr/local/bin/skyvault_connect -cli skybalance sw.skyvault.cc | jq '.balance'

RESPONSE: 
$ 0

Step 4. Ask for you customer's Skyvault address

Skyvault addresses are very easy for people to write and type into machines. They look like fully qualified domain names: "customer.skyvault.cc". However, customers also have the ability to show this information as a QR code so that the ATM machine can read this.

To get the customers SkyVault address you may provide them a text box or allow them to show you a QR code from their phone.

The only catch is that the QR code contains the URL of the website that another user use to give the person CloudCoins. But the ATM only needs the last part which is the customer's SkyVault address.

The QR code contains this:

https://skyvault.cc/transfer/customer.skyvault.cc
(Where "customer" is the customer's unique account name.

However, you only want:

customer.skyvault.cc

So you must remove the:

https://skyvault.cc/transfer/

If you can delete the path from the QR code, then you will be left with the customer's address. This is the customer's address that you can send CloudCoins to. Below you can see how the customer can show their QR code from their SKyVault.cc software.

Showing the SkyVault Address from SkyValt.cc

Step 5. Program Your Server to Send Coins to Customers when Cashing Out

1. In order to transfer coins from your SkyVault account to a customer's SkyVault account you will want to execute a 'skytransfer' command


/usr/local/bin/skyvault_connect -cli skytransfer <Your Account Name> <Customer Account Name> <amount to send> <memo>


Example:


$ /usr/local/bin/skyvault_connect -cli skytransfer sw.skyvault.cc user120.skyvault.cc 10 "Payment from Bitmart"

RESPONSE: 
{"TotalCoins":1,"TotalAuthentic":0,"TotalFracked":1,"TotalCounterfeit":0,"TotalLimbo":0,"Details":[],"Coins":[{"sn":230035,"pownstring":"fppppppppppppppppppfpppup","result":"Fracked"}]}

You need to check "TotalAuthentic" and "TotalFracked" number. Upon successful operation the sum of these values must be equal to the amount sent.

There is a log file can be found in the home folder:

/var/www/cloudcoin_manager/main.log 

Step 6. Test The Whole Process

  1. Use the Skyvault.cc to create a second Skyvault account.
  2. Using your new ATM to enter your this test account and see if it receives the funds.
  3. Check the balance of your main Skyvault to see if the withdrawal was registered in statements.

Step 7. Setup a Maintenance Chronjob

With CloudCoin, it is up to the user to synchronize its wallet on all the clouds. This cron-job will synchronize once a day.

0 1 * * * /usr/local/bin/skyvault_connect -cli maintenance sw.skyvault.cc

The line above will launch at 1am at night

(!) The cron job must be launched as the same user as the one that calls 'skyvault_connect skytransfer' Check the main.log and make sure the cronjob is working after the setup.


This is an example of the page

<?php


// Your skyvault address
define('SKYVAULT_ADDRESS', 'atm-exchange.skyvault.cc');

// Path to skyvault_connect
$skyvault_connect = "/usr/local/bin/skyvault_connect";

if (!file_exists($skyvault_connect))
  die("skyvault_connect not found");

if (!is_executable($skyvault_connect))
  die("skyvault_connect doesn't have exec permissions");


// Authorize the request
// By IP Address, By Auth Token or Authorization header on your choice

// Customer SkyVault address
$to = $_GET['to'];

// Amount to send
$amount = intval($_GET['amount']);

// Any reference 
$memo = $_GET['memo'];


if (!filter_var(gethostbyname($to), FILTER_VALIDATE_IP)) 
  die("Invalid Customer Skyvault");

if ($amount <= 0)
	die("Invalid Amount");

$cmd =  "$skyvault_connect -cli skytransfer " . SKYVAULT_ADDRESS . " $to $amount $memo";

// Exec the binary
$json = exec($cmd, $outarray, $error_code);
if ($error_code != 0) 
  die("Invalid response from skyvault_connect: $error_code, Output $json");

$arr = json_decode($json, true);
if (!$arr) 
  die("Failed to decode json: $json");

if ($arr['code'] != 0) 
	die("Failed to send coins: $json");

echo "Coins sent";

?>