aboutsummaryrefslogtreecommitdiffstats
path: root/routes/bitcoin/receive.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2020-04-28 22:09:22 -0700
committerAdam Soltys <[email protected]>2020-04-28 22:33:02 -0700
commit63c18105e6c66b3b4698c398f356bef1b496816f (patch)
treee7ee85e7c3502ed81954448a76be028143990948 /routes/bitcoin/receive.js
parent994dd93f6c45c590ae59a699cbf425d96518da1e (diff)
downloadcoinos-server-63c18105e6c66b3b4698c398f356bef1b496816f.tar.gz
coinos-server-63c18105e6c66b3b4698c398f356bef1b496816f.zip
include account in emitted payments objects
Diffstat (limited to 'routes/bitcoin/receive.js')
-rw-r--r--routes/bitcoin/receive.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/routes/bitcoin/receive.js b/routes/bitcoin/receive.js
index acc80b09..deded625 100644
--- a/routes/bitcoin/receive.js
+++ b/routes/bitcoin/receive.js
@@ -70,12 +70,10 @@ zmqRawTx.on("message", async (topic, message, sequence) => {
user.address = await bc.getNewAddress("", "bech32");
await user.save();
- user = await getUser(user.username);
- emit(user.username, "user", user);
addresses[user.address] = user.username;
- const payment = await db.Payment.create({
+ let payment = await db.Payment.create({
account_id: account.id,
user_id: user.id,
hash,
@@ -88,9 +86,13 @@ zmqRawTx.on("message", async (topic, message, sequence) => {
address,
network: "BTC"
});
+ payment = payment.get({ plain: true });
+ payment.account = account.get({ plain: true });
- l.info("bitcoin detected", user.username, o.value);
+ user = await getUser(user.username);
emit(user.username, "payment", payment);
+ emit(user.username, "user", user);
+ l.info("bitcoin detected", user.username, o.value);
}
})
);
@@ -135,6 +137,7 @@ setInterval(async () => {
let user = await getUserById(p.user_id);
emit(user.username, "user", user);
+ emit(user.username, "payment", p);
l.info("bitcoin confirmed", user.username, p.amount, p.tip);
delete queue[hash];
} else {