From c3ed4317d37f1c760392d9a89610d07ccd3a7d03 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 29 Jan 2020 14:33:51 -0800 Subject: set payment currency --- bitcoinPayments.js | 2 +- lightningPayments.js | 1 + liquidPayments.js | 2 +- models/users.js | 9 +++++++++ users.js | 5 +++++ whitelist.js | 1 + 6 files changed, 18 insertions(+), 2 deletions(-) diff --git a/bitcoinPayments.js b/bitcoinPayments.js index 95fbcc5b..d3f2f1c4 100644 --- a/bitcoinPayments.js +++ b/bitcoinPayments.js @@ -80,7 +80,7 @@ module.exports = (app, bc, db, addresses, payments, emit) => { user_id: user.id, hash, amount: o.value, - currency: "CAD", + currency: user.currency, rate: app.get("ask"), received: true, tip, diff --git a/lightningPayments.js b/lightningPayments.js index e7d84868..278d7f02 100644 --- a/lightningPayments.js +++ b/lightningPayments.js @@ -17,6 +17,7 @@ module.exports = (app, db, lna, lnb, emit, payments) => { user.balance += parseInt(msg.value); payment.rate = app.get("rates")[user.currency]; payment.confirmed = true; + payment.currency = user.currency; await payment.save(); await user.save(); diff --git a/liquidPayments.js b/liquidPayments.js index 0b259761..afa33466 100644 --- a/liquidPayments.js +++ b/liquidPayments.js @@ -76,7 +76,7 @@ module.exports = (app, db, addresses, payments, emit) => { user_id: user.id, hash: blinded.txid, amount: value, - currency: "CAD", + currency: liquid.currency, rate: app.get("ask"), received: true, tip, diff --git a/models/users.js b/models/users.js index 40eb00f5..c6a88f04 100644 --- a/models/users.js +++ b/models/users.js @@ -94,6 +94,15 @@ module.exports = sequelize => { comment: null, field: "currency" }, + currencies: { + type: DataTypes.JSON, + allowNull: false, + defaultValue: ["USD"], + primaryKey: false, + autoIncrement: false, + comment: null, + field: "currencies" + }, commission: { type: DataTypes.STRING(255), allowNull: true, diff --git a/users.js b/users.js index d797b2f8..b1e2063c 100644 --- a/users.js +++ b/users.js @@ -44,6 +44,7 @@ module.exports = (addresses, auth, app, bc, db, emit) => { user.password = await bcrypt.hash(user.password, 1); user.name = user.username; user.currency = "USD"; + user.currencies = ["USD"]; addresses[user.address] = user.username; addresses[user.liquid] = user.username; @@ -106,6 +107,7 @@ module.exports = (addresses, auth, app, bc, db, emit) => { let { username, currency, + currencies, email, phone, twofa, @@ -139,11 +141,14 @@ module.exports = (addresses, auth, app, bc, db, emit) => { } user.currency = currency; + user.currencies = currencies; user.email = email; user.phone = phone; user.twofa = twofa; user.pin = pin; + console.log(user.currencies); + if (password && password === passconfirm) { user.password = await bcrypt.hash(password, 1); } diff --git a/whitelist.js b/whitelist.js index d4db43f0..668a46a1 100644 --- a/whitelist.js +++ b/whitelist.js @@ -7,6 +7,7 @@ module.exports = [ 'unit', 'symbol', 'currency', +'currencies', 'commission', 'title', 'balance', -- cgit v1.2.3