aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--db.js7
-rw-r--r--ecosystem.config.js2
-rw-r--r--index.js14
-rw-r--r--migrations/20180206033508-create-transaction.js39
-rw-r--r--models/transaction.js17
5 files changed, 76 insertions, 3 deletions
diff --git a/db.js b/db.js
index 9dfe210e..62ec3972 100644
--- a/db.js
+++ b/db.js
@@ -22,7 +22,11 @@ const auto = new SequelizeAuto(
config.development.password,
config.auto
)
-const tables = { 'User': 'users' }
+
+const tables = {
+ User: 'users',
+ Transaction: 'transactions',
+}
const db = new Sequelize(
config.development.database,
@@ -36,6 +40,7 @@ const db = new Sequelize(
operatorsAliases: false,
},
)
+
const gqlfields = {}
const gqltypes = {}
diff --git a/ecosystem.config.js b/ecosystem.config.js
index a44c0de5..1093c494 100644
--- a/ecosystem.config.js
+++ b/ecosystem.config.js
@@ -5,7 +5,7 @@ module.exports = {
script: 'index.js',
exec_interpreter: './node_modules/.bin/babel-node',
exec_mode: 'fork',
- watch: ['*.js'],
+ watch: ['index.js'],
env: {
COMMON_VARIABLE: 'true'
},
diff --git a/index.js b/index.js
index 5b2561a1..ea93f627 100644
--- a/index.js
+++ b/index.js
@@ -30,7 +30,7 @@ const l = console.log
const restClient = ba.restfulClient(process.env.BITCOINAVERAGE_PUBLIC, process.env.BITCOINAVERAGE_SECRET)
const lnrpc = await require('lnrpc')({ server: 'localhost:10001' })
- const adminMacaroon = fs.readFileSync('/home/adam/.lnd/data/core_test/admin.macaroon');
+ const adminMacaroon = fs.readFileSync('/home/adam/.lnd.testa/admin.macaroon');
const meta = new grpc.Metadata();
meta.add('macaroon', adminMacaroon.toString('hex'));
@@ -38,6 +38,18 @@ const l = console.log
res.json(await lnrpc.walletBalance({witness_only: true}, meta))
})
+ app.post('/sendPayment', async (req, res) => {
+ let payments = lnrpc.sendPayment(meta, {})
+ payments.on('data', msg => l(msg))
+ payments.write({
+ payment_request: req.body.payreq
+ })
+ })
+
+ app.get('/addinvoice', async (req, res) => {
+ res.json(await lnrpc.walletBalance({witness_only: true}, meta))
+ })
+
let fetchRates
(fetchRates = () => {
restClient.tickerGlobalPerSymbol('BTCCAD', (data) => {
diff --git a/migrations/20180206033508-create-transaction.js b/migrations/20180206033508-create-transaction.js
new file mode 100644
index 00000000..06863a43
--- /dev/null
+++ b/migrations/20180206033508-create-transaction.js
@@ -0,0 +1,39 @@
+'use strict';
+module.exports = {
+ up: (queryInterface, Sequelize) => {
+ return queryInterface.createTable('transactions', {
+ id: {
+ allowNull: false,
+ autoIncrement: true,
+ primaryKey: true,
+ type: Sequelize.INTEGER
+ },
+ hash: {
+ type: Sequelize.STRING
+ },
+ address: {
+ type: Sequelize.STRING
+ },
+ date: {
+ type: Sequelize.DATE
+ },
+ amount: {
+ type: Sequelize.FLOAT
+ },
+ rate: {
+ type: Sequelize.FLOAT
+ },
+ createdAt: {
+ allowNull: false,
+ type: Sequelize.DATE
+ },
+ updatedAt: {
+ allowNull: false,
+ type: Sequelize.DATE
+ }
+ });
+ },
+ down: (queryInterface, Sequelize) => {
+ return queryInterface.dropTable('transactions');
+ }
+};
diff --git a/models/transaction.js b/models/transaction.js
new file mode 100644
index 00000000..f4b696a7
--- /dev/null
+++ b/models/transaction.js
@@ -0,0 +1,17 @@
+'use strict';
+module.exports = (sequelize, DataTypes) => {
+ var Transaction = sequelize.define('Transaction', {
+ hash: DataTypes.STRING,
+ address: DataTypes.STRING,
+ date: DataTypes.DATE,
+ amount: DataTypes.FLOAT,
+ rate: DataTypes.FLOAT
+ }, {
+ classMethods: {
+ associate: function(models) {
+ // associations can be defined here
+ }
+ }
+ });
+ return Transaction;
+}; \ No newline at end of file