SatSale

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 504017c3b8255bbd8db30dc682182f98d538c517
parent 0803dae39f62b3fb39251b23d3ade394c1954baf
Author: NicholasFarrow <nicholas.w.farrow@gmail.com>
Date:   Sat, 26 Dec 2020 20:51:40 +1100

Updated readme, config.

Diffstat:
MREADME.md | 69+++++++++++++++++++--------------------------------------------------
Aconfig.py | 20++++++++++++++++++++
Minvoice/payment_invoice.py | 2++
Astatic/qr_codes/.gitignore | 4++++
Mstatic/server_connection.js | 16++++++++++++----
Mtemplates/index.html | 2+-
6 files changed, 58 insertions(+), 55 deletions(-)

diff --git a/README.md b/README.md @@ -1,61 +1,30 @@ -# BTCPYSERVER -BTCPayserver is incredibly bloated. The goal of BTCpyserver is to act as a lightweight bitcoin payment system for your website. +Widely used non-custodial Bitcoin payment processors are bloated and difficult for the average person to install. BtcPyment strives to exist as an easily deployable, highly customisable, lightweight Bitcoin payment processor that keeps your coins belonging to your keys. Almost purely written in Python and Javascript, BtcPyment makes donation buttons simple for your website; via a simple embedded iframe that talks to your own Bitcoin node via Flask websockets. # Installation This should be easy to install. -# Architecture -btcpysever --site/ ---website.php --invoice/ ---main.py ---database.py ---price_feed.py --btc_pay/ ---bitcoind.py ---clightning.py --success/ ---success.py --failure ---failure.py --main.py +# Feature +* Lightweight, python and javascript talk to your own bitcoin node via websockets and ssh. +* Direct peer-to-peer payments without any middleman. No KYC, and greater privacy than donation systems with reused Bitcoin addresses. +* Natively supports all bitcoind node features through RPC. +* QR codes, customisable payment confirmations and payment expiry duration. +* No shitcoin bloat. +# Developers +## You only need a little python! +The main code can be found in `server.py`. invoice and bitcoind handling in `invoice/`, donation button javascript logic in `static/`, button appearance in `template/`. Please have ago at implementing some of the things below! -# Minimum requirements for proof of concept -Requires end-to-end payment, handling both success and failure -- PHP invoice page, could everything be php...? -- Not PHP, need something that can dynamically show the progress! -- Feedback: timeleft, confirmations, etc. -- integrate with bitcoind, monitor transactions -- +# Coming soon: +* Payment API to process payments from any desired point of sale or web shop (woocommerce, shopify) +* Lightning support +* More readily customisable donation button (text/color/QR code) +* Database integration for payment invoices +* Multiple choice of price feeds +# Disclaimer +BtcPyment is in early development, as such we are not responsible for any loss of funds or vulnerabilities. - -# On php post, -* Call btcpy with invoice commands -* Invoice is in USD (default) and converts automatically to BTC -* conversion_to_usd.py -* Call bitcoind to create a new address -* Save invoice with address to database - - Pandas - - SQL? - - Other? -* read address form database back: -* Pass address back to website -* Wait for user send... - -# btc_pay -* Check bitcoind mempool every 5 seconds for incoming transactions, -* wait for x confirmations (x also determines invoice_timeout) -* After x confirmations, return as paid to website and unlock/call any other function. This could even be a custom script like sale_success_command.sh (link to digital good, call other APIs) -* Need to integrate with at least 1 shop, woocommerce, as a proof of concept. - -# lighting_pay -* Same but integrate c_lightning.py for proof of concept. - - -# success/ +# success/ Payment success Display on website as successfuly paid, write to database to confirm payment. Navigate elsewhere by calling script from `sales/*.py` diff --git a/config.py b/config.py @@ -0,0 +1,20 @@ +# Bitcoin node connection settings +host = "127.0.0.1" +rpcport = "8332" +username = "bitcoinrpc" +password = "RPAPASSWORD" + +# SSH tunnel to node (raspberry pi!) +tunnel_host = "HOST@IP" + +# Check for payment every xx seconds +pollrate = 15 + +# Payment expires after xx seconds +payment_timeout = 60*20 + +# Required confirmations for a payment +required_confirmations = 3 + +# Global connection attempts +connection_attempts = 3 diff --git a/invoice/payment_invoice.py b/invoice/payment_invoice.py @@ -23,3 +23,5 @@ class invoice: img = qrcode.make(self.address) img.save('static/qr_codes/{}.png'.format(self.uuid)) return + + diff --git a/static/qr_codes/.gitignore b/static/qr_codes/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/static/server_connection.js b/static/server_connection.js @@ -1,9 +1,10 @@ +// Websocket logic, talks to server.py pay $(document).ready(function() { namespace = '/pay'; var socket = io(namespace); socket.on('connect', function() { - socket.emit('initialise', {'data': 'initialising payment...'}); + socket.emit('initialise', {'data': 'Initialising payment.'}); }); socket.on('payresponse', function(msg, cb) { @@ -26,11 +27,16 @@ $(document).ready(function() { }); }); +// Additional steps to take when giving a response to the webpage +// Update qr code, and hide timer function conditionalPageLogic(msg) { if (msg.address != null) { document.getElementById('logo').classList.add("qr"); - document.getElementById('logo').src = "static/qr_codes/" + msg.uuid + ".png"; - document.getElementById('qrClick').href = "/static/qr_codes/" + msg.uuid + ".png" + // document.getElementById('logo').src = "static/qr_codes/" + msg.uuid + ".png"; + document.getElementById('logo').style.display = "none"; + document.getElementById('qrImage').style.display = "block"; + document.getElementById('qrClick').href = "/static/qr_codes/" + msg.uuid + ".png"; + document.getElementById('qrImage').src = "/static/qr_codes/" + msg.uuid + ".png"; } if (msg.time_left == 0) { @@ -38,6 +44,7 @@ function conditionalPageLogic(msg) { } } +// Hide payment form and show payment details when payment is initiated function hideAmountShowPayment() { if (document.getElementById('pay_data').value > 0) { document.getElementById('paymentDetails').style.display = "block"; @@ -45,6 +52,7 @@ function hideAmountShowPayment() { } } +// Copy text functions function copyText(text) { navigator.clipboard.writeText(text); } @@ -56,7 +64,7 @@ function copyTextFromElement(elementID) { alert("Copied address:" + elementText) } - +// Payment timer, can't go below zero, update every second intervalTimer = setInterval(function () { var currentTime = document.getElementById('timer').innerHTML; if (currentTime <= 0) { diff --git a/templates/index.html b/templates/index.html @@ -106,7 +106,7 @@ </div> <div id="information" style="text-align: right; padding: 0;"> - <p><a id="about" href="https://github.com/nickfarrow/BTCPythonServer" target="_blank">About</a></p> + <p><a id="about" href="https://github.com/nickfarrow/BTCPyment" target="_blank">About</a></p> </div> <div id="paybutton"></div>