aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/createExceptions.js
blob: bec6ebc602e9ab6547e947e556666aff056c885b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
BitcoinCore = require("bitcoin-core");
fs = require("fs");
config = require("./config");
bc = new BitcoinCore(config.bitcoin);
l = require("pino")();
require("./db");

console.log(db.Payment);

(async () => {
  payments = (
    await db.Payment.findAll({
      attributes: ["hash"],
    })
  ).map((p) => p.hash);
  const transactions = await bc.listTransactions("*", 1000);
  var stream = fs.createWriteStream("exceptions", {
    flags: "a",
    emitClose: true,
  });
  transactions.map((tx) => {
    if (!payments.includes(tx.txid)) {
      l.info("writing", tx.txid);
      stream.write(tx.txid + "\n");
    }
  });
  stream.end();
  stream.on("close", () => {
    l.info("done");
    process.exit();
  });
})();