aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2020-03-19 22:57:04 -0700
committerAdam Soltys <[email protected]>2020-03-19 22:57:04 -0700
commit05ac54f58238b56534e3d2bd638af0613834a06d (patch)
treea6ae190f834e0278ed9057f22c590cbff01b880c
parent49065ec0b491c90887b51556a836993e719eb26f (diff)
downloadcoinos-server-05ac54f58238b56534e3d2bd638af0613834a06d.tar.gz
coinos-server-05ac54f58238b56534e3d2bd638af0613834a06d.zip
update readme
-rw-r--r--README.md34
-rw-r--r--db/schema.sql16
-rw-r--r--routes/users.js6
3 files changed, 31 insertions, 25 deletions
diff --git a/README.md b/README.md
index 7b2597a6..439417ef 100644
--- a/README.md
+++ b/README.md
@@ -1,28 +1,30 @@
-This is the backend API server for https://coinos.io/
+# coinos-server
-It's built on NodeJS and Express and uses Sequelize to communicate with a MariaDB database server. There are a couple GraphQL endpoints I was experimenting with but most of the communication is done with REST endpoints and persistent per-user websocket connections using socket.io.
+Coinos is a bitcoin wallet app that supports payments over the <a href="https://bitcoin.org">bitcoin</a>, <a href="https://blockstream.com/liquid/">liquid</a> and <a href="http://lightning.network/">lightning</a> networks. Try it out at <a href="https://coinos.io/">coinos.io</a>.
-The server expects you to be running a full bitcoind node and two separate lnd instances, referred to in the code as lna and lnb. The reason for running two nodes is so that they can invoice and pay each other in the case that one CoinOS user wants to pay another CoinOS user since lnd nodes cannot pay themselves (or at least that was the case when I started, that may have changed).
+This repository contains the code for the backend API server which is implemented as a NodeJS application. The code for the frontend UI is tracked separately <a href="https://github.com/asoltys/coinos.io">here</a>.
-lnb takes care of generating invoices and receiving payments and lna takes deposits and sends payments. As soon as lna sends a payment, it generates an invoice for lnb to pay it back right away so that they don't become unbalanced.
+## Requirements
-We use ZMQ to communicate with bitcoind in addition to the JSON RPC so make sure your bitcoind is compiled with ZMQ enabled. This should be done automatically if you have the prerequisite libzmq dependency installed at compile time.
+* <a href="https://github.com/bitcoin/bitcoin">bitcoind</a> with zmq support
+* <a href="https://github.com/ElementsProject/elements">elementsd</a> with zmq support
+* two instances of <a href="https://github.com/lightningnetwork/lnd">lnd</a> (<a href="https://github.com/elementsproject/lightning">c-lightning</a> coming soon)
+* a database that <a href="https://github.com/sequelize/sequelize">sequelize</a> can talk to
-There are also integrations with Facebook's API for single sign-in and contacts, Stripe for taking credit card payments, Mailgun for email notifications, Twilio for SMS notifications, and Authy for two-factor authentication. Pricing info is fetched from Kraken at the time of writing and only in CAD but that's soon to change.
+The bitcoind and elementsd nodes can be a pruned if you want to limit the amount of disk space used.
-## Configuration
+The reason for running two lightning nodes is so that one can create invoices while the other sends payments when two coinos users want to pay each other.
-You can configure the connection info and API keys for all the external services in config/index.js
-
-Check out the [sample config](https://github.com/asoltys/coinos-server/blob/master/config/index.sample.js)
-
-## Database
-
-For a while I was writing Sequelize migrations to keep the database schema in sync with the codebase but right now there are a handful of columns that aren't captured in any migration. There's a [sample schema](https://github.com/asoltys/coinos-server/blob/master/schema.sql) that you can use though.
-
-## Installation
+## Getting Started
git clone https://github.com/asoltys/coinos-server
+ cd coinos-server
+ cp config/index.js.sample config/index.js <-- edit with connection info for servers and keys for 3rd party API's
yarn
yarn start
+## Database Setup
+
+I've only tested with <a href="https://mariadb.org/">Maria</a>. Here's a [schema](https://github.com/asoltys/coinos-server/blob/master/db/schema.sql) to get you started.
+
+ cat db/schema.sql | mysql -u root -p
diff --git a/db/schema.sql b/db/schema.sql
index 7bdf7d3b..0146c139 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -16,6 +16,14 @@
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
+-- Current Database: `coinos`
+--
+
+CREATE DATABASE /*!32312 IF NOT EXISTS*/ `coinos` /*!40100 DEFAULT CHARACTER SET utf8mb4 */;
+
+USE `coinos`;
+
+--
-- Table structure for table `SequelizeMeta`
--
@@ -53,7 +61,7 @@ CREATE TABLE `payments` (
`fee` double DEFAULT NULL,
`asset` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=2782 DEFAULT CHARSET=latin1;
+) ENGINE=InnoDB AUTO_INCREMENT=3140 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -99,9 +107,9 @@ CREATE TABLE `users` (
`confidential` varchar(255) DEFAULT NULL,
`liquid` varchar(255) DEFAULT NULL,
`currencies` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
- `otp` varchar(255) DEFAULT NULL,
+ `otpsecret` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=420 DEFAULT CHARSET=latin1;
+) ENGINE=InnoDB AUTO_INCREMENT=463 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
@@ -113,4 +121,4 @@ CREATE TABLE `users` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2020-02-09 15:22:43
+-- Dump completed on 2020-03-19 22:56:40
diff --git a/routes/users.js b/routes/users.js
index d65c888f..368cca6c 100644
--- a/routes/users.js
+++ b/routes/users.js
@@ -83,7 +83,7 @@ app.post("/register", async (req, res) => {
GB: "GBP"
};
- if (ip.startsWith("127") || ip.startsWith("192")) user.currency = "CAD";
+ if (!config.ipstack || ip.startsWith("127") || ip.startsWith("192")) user.currency = "CAD";
else {
let info = await axios.get(
`http://api.ipstack.com/${ip}?access_key=${config.ipstack}`
@@ -262,10 +262,6 @@ app.post("/facebookLogin", async (req, res) => {
let friends = (await axios.get(
`${fb}/${userID}/friends?access_token=${accessToken}`
)).data.data;
- if (friends.find(f => f.id === config.facebook.specialFriend)) {
- user.friend = true;
- user.limit = 200;
- }
await user.save();
addresses[user.address] = user.username;
addresses[user.liquid] = user.username;