diff options
| author | Adam Soltys <[email protected]> | 2020-01-29 14:33:51 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-01-29 14:33:51 -0800 |
| commit | c3ed4317d37f1c760392d9a89610d07ccd3a7d03 (patch) | |
| tree | 3c73ea9e8ee04c0585a3dce4eb5de5a8f2634100 | |
| parent | e34f41697eb4b96508dc27197b91ef06bd47a641 (diff) | |
| download | coinos-server-c3ed4317d37f1c760392d9a89610d07ccd3a7d03.tar.gz coinos-server-c3ed4317d37f1c760392d9a89610d07ccd3a7d03.zip | |
set payment currency
| -rw-r--r-- | bitcoinPayments.js | 2 | ||||
| -rw-r--r-- | lightningPayments.js | 1 | ||||
| -rw-r--r-- | liquidPayments.js | 2 | ||||
| -rw-r--r-- | models/users.js | 9 | ||||
| -rw-r--r-- | users.js | 5 | ||||
| -rw-r--r-- | 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, @@ -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', |
