Commit 8a844e93 authored by Freeman's avatar Freeman

Updated readme

parent fe23d2f5
STRAKS GATE
\ No newline at end of file
# STRAKS Gate - STRAKS Payment Gateway
```
Licence: GNU General Public License
Origin Author: acidsploit (https://github.com/acidsploit/pyxpub)
Port Maintainer: STRAKS Developers
Language: Python/React JS
Homepage: https://straks.tech/
```
STRAKS Gate is an app that generates unique payment requests for STRAKS. It exposes the needed features of a receive-only wallet through a JSON API to enable quick development of Point-of-Sale systems. This without the developer having to worry to much about the sensitive bits. STRAKS Gate makes it easy to follow crypto best practices and future-proofs your application in order to scale towards future needs.
STRAKS Gate also includes a Point-of-Sale app by default.
Check out the live demo at [straks.center](http://straks.center)
## Introduction
As per crypto best practices it is preferred to use a new receiving address for each payment. This for security and privacy implications for both you and your customers or donators. Also, we do not want any private keys on the server generating the receiving address, nor would we want them on any PoS system. This can easily be achieved by using an hd-wallet as described in [BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki).
### STRAKS Gate
STRAKS Gate exposes the needed features of that wallet through an easy to use JSON API, this to enable quick Point-of-Sale developement, without having to worry about the sensitive bits. STRAKS Gate handles the generation of new unique addresses for payment requests and keeps track of those, monitor payments requests for incoming transactions, and keeps a sales ledger. All you need to do is call the right api endpoints to get it all in your app.
All generated STRAKS addresses are derived from a pre-defined xpub key. Address re-use is prevented by keeping track of used addresses.
### xpub (Electrum STAK)
First, when you create a new wallet with Electrum STAK, it is very important to properly backup and safely store your mnemonic seed. This Electrum wallet is your full (send & receive) wallet, make sure it is password protected and also stored safely. You will use it later to retrieve payments. The webapp will use the xpub key to generate receive only addresses on the server, corresponding to the addresses from your Electrum wallet. This way we don't need private keys on the server. You can find your wallet's master public key or xpub key through the 'Wallet -> Information' menu.
## Installation (built-in server)
__clone repo__
git clone https://github.com/acidsploit/pyxpub.git pyxpub
__setup environment__
cd pyxpub/
bash setup.sh
__set xpub key__
Copy your xpub key from an Electron Cash wallet and paste it in the key.list file.
echo 'xpub...' > key.list
__run__
cd pyxpub/
bash pyxpub.sh
__access locally__
Browse to http://localhost:8080
## Installation Linux (uWSGI + NGINX)
__install nginx, uwsgi and uwsgi python plugin__
Follow your distribution's directions to install these packages.
__insall pyxpub in appropriate location__
cd /srv/http/
git clone https://github.com/acidsploit/pyxpub.git pyxpub
mkdir /srv/http/public_html/
mv pyxpub/react/ public_html/
cd pyxpub/
bash setup.sh
echo 'xpub...' > key.list
sudo chown http:http -R /srv/http/pyxpub
__uWSGI config__
Create: /etc/uwsgi/pyxpub.ini
[uwsgi]
socket = /run/uwsgi/%n.sock
processes = 4
chdir = /srv/http/pyxpub/
master = true
plugins = python
file = xpub.py
uid = http
gid = http
virtualenv = /srv/http/pyxpub/env/
__uWSGI start & enable at startup__
sudo systemctl start [email protected]
sudo systemctl enable [email protected]
__setup nginx vhost to reverse proxy uWSGI__
Set up a vhost (preferably with ssl) with following locations and uwsgi_pass:
upstream _pyxpub {
server unix:/run/uwsgi/pyxpub.sock;
}
server {
server_name yourserver.com;
listen 80;
root /srv/http/pyxpub/public_html;
rewrite ^/$ /react permanent;
location /react {
index index.html;
}
location /qr {
try_files $uri @uwsgi;
}
location /api {
try_files $uri @uwsgi;
}
location /embed {
return 403;
}
location @uwsgi {
include uwsgi_params;
uwsgi_pass _pyxpub;
}
}
__NGINX start & enable at startup__
sudo systemctl start nginx.service
sudo systemctl enable nginx.service
## Usage
### Direct browser access
http://localhost:8080
This will open the React Point-of-Sale app.
### JSON
__payment request /api/payment__
Generate new payment request.
Options:
* amount
* label
curl 'http://localhost:8080/api/payment?amount=0.0023&label=SHOP:1Wed2B44'
{
"payment": {
"amount": "0.1",
"addr": "SgEySkxh6wmvpEJsBob9TxtBTG9gs1Nxdp",
"label": false,
"qr_img": "\/qr?addr=SgEySkxh6wmvpEJsBob9TxtBTG9gs1Nxdp&amount=0.1",
"payment_uri": "SgEySkxh6wmvpEJsBob9TxtBTG9gs1Nxdp?amount=0.1&editable=false"
}
}
__payment verification request /api/verify__
Verify payment of payment request
Options:
* addr
* amount
or
* label
curl 'http://localhost:8080/api/verify?addr=SgEySkxh6wmvpEJsBob9TxtBTG9gs1Nxdp&amount=0.0023'
{"received": 0}
or
{"received": 1}
__sales ledger request /api/ledger__
Fetch sales ledger.
curl 'http://localhost:8080/api/ledger'
{
"1": {
"id": 1,
"timestamp": 1533416134.2067,
"addr": "SdQxNYKkpvYSQ2Jcq7o2X7e4caq2UNGdce",
"amount": "0.16666667",
"label": "STRAKS:62bfc324ac5",
"received": 1,
"confirmations": 0,
"txid": "37cfd7156fc207e580eac9aaaa2713d874352ea543474d857dc74d26815942d5",
"order": 0
},
"2": {
"id": 2,
"timestamp": 1533416456.5743,
"addr": "SSSdXi42an4HzNrNHg29q7ju2xfSn5EfZD",
"amount": "0.16166667",
"label": "STRAKS:7a5cd912e3f",
"received": 1,
"confirmations": 0,
"txid": "79b9232a5706079564b6e2424847cde5f2129eab8eedd95fa9cb2aee1cab5c38",
"order": 1
},
"3": {
"id": 3,
"timestamp": 1534460702.4491,
"addr": "SgEySkxh6wmvpEJsBob9TxtBTG9gs1Nxdp",
"amount": "0.1",
"label": "0",
"received": 0,
"confirmations": 0,
"txid": "NoTX",
"order": 0
}
}
__exchange rate request /api/rate__
Fetch exchange rate or list supported currencies for specified source.
Options:
* source (cryptocompate, kraken, coinbase)
* currency
=> Returns exchange rate for requested source and currency
or
* source (cryptocompate, kraken, coinbase)
=> Returns array of supported currencies for specified source
curl 'http://localhost:8080/api/rate?source=coinmarketcap'
{
"currencies": ["EUR",
"USD",
"GBP",
"AUD",
"BRL",
"CAD",
"CHF",
"CLP",
"CNY",
"CZK",
"DKK",
"HKD",
"HUF",
"IDR",
"ILS",
"INR",
"JPY",
"KRW",
"MXN",
"MYR",
"NOK",
"NZD",
"PHP",
"PKR",
"PLN",
"RUB",
"SEK",
"SGD",
"THB",
"TRY",
"TWD",
"ZAR"]
}
curl 'http://localhost:8080/api/rate?source=kraken&currency=EUR'
{
"currency": "EUR",
"price": ".06"
}
### QR image only
http://localhost:8080/qr?addr=SSSdXi42an4HzNrNHg29q7ju2xfSn5EfZD&amount=0.0023&label=SHOP:PAYM123
xpub661MyMwAqRbcEtg7aa98AtHVouK2CmXSwijVe3kyQiBKhexxMpGwXwmk79xE7SEkpknC84Q1cpv1t9L6nB4H6r8GngonTsPHQ2shvcxMi1N
\ No newline at end of file
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment