Merge branch 'master' into address-lookups-faq
This commit is contained in:
		
						commit
						2b9d9f985b
					
				
							
								
								
									
										50
									
								
								backend/package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										50
									
								
								backend/package-lock.json
									
									
									
										generated
									
									
									
								
							@ -18,7 +18,7 @@
 | 
			
		||||
        "node-worker-threads-pool": "^1.5.1",
 | 
			
		||||
        "socks-proxy-agent": "^6.2.0",
 | 
			
		||||
        "typescript": "~4.6.3",
 | 
			
		||||
        "ws": "~8.3.0"
 | 
			
		||||
        "ws": "~8.6.0"
 | 
			
		||||
      },
 | 
			
		||||
      "devDependencies": {
 | 
			
		||||
        "@types/compression": "^1.7.2",
 | 
			
		||||
@ -469,9 +469,9 @@
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/crypto-js": {
 | 
			
		||||
      "version": "4.0.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.0.0.tgz",
 | 
			
		||||
      "integrity": "sha512-bzHZN8Pn+gS7DQA6n+iUmBfl0hO5DJq++QP3U6uTucDtk/0iGpXd/Gg7CGR0p8tJhofJyaKoWBuJI4eAO00BBg=="
 | 
			
		||||
      "version": "4.1.1",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.1.1.tgz",
 | 
			
		||||
      "integrity": "sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw=="
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/debug": {
 | 
			
		||||
      "version": "2.6.9",
 | 
			
		||||
@ -572,9 +572,9 @@
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/express": {
 | 
			
		||||
      "version": "4.18.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/express/-/express-4.18.0.tgz",
 | 
			
		||||
      "integrity": "sha512-EJEXxiTQJS3lIPrU1AE2vRuT7X7E+0KBbpm5GSoK524yl0K8X+er8zS2P14E64eqsVNoWbMCT7MpmQ+ErAhgRg==",
 | 
			
		||||
      "version": "4.18.1",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/express/-/express-4.18.1.tgz",
 | 
			
		||||
      "integrity": "sha512-zZBcOX9TfehHQhtupq57OF8lFZ3UZi08Y97dwFCkD8p9d/d2Y3M+ykKcwaMDEL+4qyUolgBDX6AblpR3fL212Q==",
 | 
			
		||||
      "dependencies": {
 | 
			
		||||
        "accepts": "~1.3.8",
 | 
			
		||||
        "array-flatten": "1.1.1",
 | 
			
		||||
@ -1469,9 +1469,9 @@
 | 
			
		||||
      "integrity": "sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g=="
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/typescript": {
 | 
			
		||||
      "version": "4.6.3",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.3.tgz",
 | 
			
		||||
      "integrity": "sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==",
 | 
			
		||||
      "version": "4.6.4",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz",
 | 
			
		||||
      "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==",
 | 
			
		||||
      "bin": {
 | 
			
		||||
        "tsc": "bin/tsc",
 | 
			
		||||
        "tsserver": "bin/tsserver"
 | 
			
		||||
@ -1532,9 +1532,9 @@
 | 
			
		||||
      "dev": true
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/ws": {
 | 
			
		||||
      "version": "8.3.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/ws/-/ws-8.3.0.tgz",
 | 
			
		||||
      "integrity": "sha512-Gs5EZtpqZzLvmIM59w4igITU57lrtYVFneaa434VROv4thzJyV6UjIL3D42lslWlI+D4KzLYnxSwtfuiO79sNw==",
 | 
			
		||||
      "version": "8.6.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/ws/-/ws-8.6.0.tgz",
 | 
			
		||||
      "integrity": "sha512-AzmM3aH3gk0aX7/rZLYvjdvZooofDu3fFOzGqcSnQ1tOcTWwhM/o+q++E8mAyVVIyUdajrkzWUGftaVSDLn1bw==",
 | 
			
		||||
      "engines": {
 | 
			
		||||
        "node": ">=10.0.0"
 | 
			
		||||
      },
 | 
			
		||||
@ -1948,9 +1948,9 @@
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "crypto-js": {
 | 
			
		||||
      "version": "4.0.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.0.0.tgz",
 | 
			
		||||
      "integrity": "sha512-bzHZN8Pn+gS7DQA6n+iUmBfl0hO5DJq++QP3U6uTucDtk/0iGpXd/Gg7CGR0p8tJhofJyaKoWBuJI4eAO00BBg=="
 | 
			
		||||
      "version": "4.1.1",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.1.1.tgz",
 | 
			
		||||
      "integrity": "sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw=="
 | 
			
		||||
    },
 | 
			
		||||
    "debug": {
 | 
			
		||||
      "version": "2.6.9",
 | 
			
		||||
@ -2019,9 +2019,9 @@
 | 
			
		||||
      "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
 | 
			
		||||
    },
 | 
			
		||||
    "express": {
 | 
			
		||||
      "version": "4.18.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/express/-/express-4.18.0.tgz",
 | 
			
		||||
      "integrity": "sha512-EJEXxiTQJS3lIPrU1AE2vRuT7X7E+0KBbpm5GSoK524yl0K8X+er8zS2P14E64eqsVNoWbMCT7MpmQ+ErAhgRg==",
 | 
			
		||||
      "version": "4.18.1",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/express/-/express-4.18.1.tgz",
 | 
			
		||||
      "integrity": "sha512-zZBcOX9TfehHQhtupq57OF8lFZ3UZi08Y97dwFCkD8p9d/d2Y3M+ykKcwaMDEL+4qyUolgBDX6AblpR3fL212Q==",
 | 
			
		||||
      "requires": {
 | 
			
		||||
        "accepts": "~1.3.8",
 | 
			
		||||
        "array-flatten": "1.1.1",
 | 
			
		||||
@ -2708,9 +2708,9 @@
 | 
			
		||||
      "integrity": "sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g=="
 | 
			
		||||
    },
 | 
			
		||||
    "typescript": {
 | 
			
		||||
      "version": "4.6.3",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.3.tgz",
 | 
			
		||||
      "integrity": "sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw=="
 | 
			
		||||
      "version": "4.6.4",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz",
 | 
			
		||||
      "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg=="
 | 
			
		||||
    },
 | 
			
		||||
    "unpipe": {
 | 
			
		||||
      "version": "1.0.0",
 | 
			
		||||
@ -2755,9 +2755,9 @@
 | 
			
		||||
      "dev": true
 | 
			
		||||
    },
 | 
			
		||||
    "ws": {
 | 
			
		||||
      "version": "8.3.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/ws/-/ws-8.3.0.tgz",
 | 
			
		||||
      "integrity": "sha512-Gs5EZtpqZzLvmIM59w4igITU57lrtYVFneaa434VROv4thzJyV6UjIL3D42lslWlI+D4KzLYnxSwtfuiO79sNw==",
 | 
			
		||||
      "version": "8.6.0",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/ws/-/ws-8.6.0.tgz",
 | 
			
		||||
      "integrity": "sha512-AzmM3aH3gk0aX7/rZLYvjdvZooofDu3fFOzGqcSnQ1tOcTWwhM/o+q++E8mAyVVIyUdajrkzWUGftaVSDLn1bw==",
 | 
			
		||||
      "requires": {}
 | 
			
		||||
    },
 | 
			
		||||
    "yallist": {
 | 
			
		||||
 | 
			
		||||
@ -37,7 +37,7 @@
 | 
			
		||||
    "node-worker-threads-pool": "^1.5.1",
 | 
			
		||||
    "socks-proxy-agent": "^6.2.0",
 | 
			
		||||
    "typescript": "~4.6.3",
 | 
			
		||||
    "ws": "~8.3.0"
 | 
			
		||||
    "ws": "~8.6.0"
 | 
			
		||||
  },
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "@types/compression": "^1.7.2",
 | 
			
		||||
 | 
			
		||||
@ -139,10 +139,13 @@ class Mining {
 | 
			
		||||
 | 
			
		||||
    try {
 | 
			
		||||
      this.weeklyHashrateIndexingStarted = true;
 | 
			
		||||
      const lastestRunDate = await HashratesRepository.$getLatestRun('last_weekly_hashrates_indexing');
 | 
			
		||||
 | 
			
		||||
      // We only run this once a week
 | 
			
		||||
      const latestTimestamp = await HashratesRepository.$getLatestRunTimestamp('last_weekly_hashrates_indexing') * 1000;
 | 
			
		||||
      if (now.getTime() - latestTimestamp < 604800000) {
 | 
			
		||||
      // Run only if:
 | 
			
		||||
      // * lastestRunDate is set to 0 (node backend restart, reorg)
 | 
			
		||||
      // * we started a new week (around Monday midnight)
 | 
			
		||||
      const runIndexing = lastestRunDate === 0 || now.getUTCDay() === 1 && lastestRunDate !== now.getUTCDate();
 | 
			
		||||
      if (!runIndexing) {
 | 
			
		||||
        this.weeklyHashrateIndexingStarted = false;
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
@ -226,7 +229,7 @@ class Mining {
 | 
			
		||||
        ++totalIndexed;
 | 
			
		||||
      }
 | 
			
		||||
      this.weeklyHashrateIndexingStarted = false;
 | 
			
		||||
      await HashratesRepository.$setLatestRunTimestamp('last_weekly_hashrates_indexing');
 | 
			
		||||
      await HashratesRepository.$setLatestRun('last_weekly_hashrates_indexing', new Date().getUTCDate());
 | 
			
		||||
      if (newlyIndexed > 0) {
 | 
			
		||||
        logger.info(`Indexed ${newlyIndexed} pools weekly hashrate`);
 | 
			
		||||
      }
 | 
			
		||||
@ -244,14 +247,13 @@ class Mining {
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const now = new Date().getTime();
 | 
			
		||||
 | 
			
		||||
    try {
 | 
			
		||||
      this.hashrateIndexingStarted = true;
 | 
			
		||||
 | 
			
		||||
      // We only run this once a day
 | 
			
		||||
      const latestTimestamp = await HashratesRepository.$getLatestRunTimestamp('last_hashrates_indexing') * 1000;
 | 
			
		||||
      if (now - latestTimestamp < 86400000) {
 | 
			
		||||
      // We only run this once a day around midnight
 | 
			
		||||
      const latestRunDate = await HashratesRepository.$getLatestRun('last_hashrates_indexing');
 | 
			
		||||
      const now = new Date().getUTCDate();
 | 
			
		||||
      if (now === latestRunDate) {
 | 
			
		||||
        this.hashrateIndexingStarted = false;
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
@ -339,7 +341,7 @@ class Mining {
 | 
			
		||||
      newlyIndexed += hashrates.length;
 | 
			
		||||
      await HashratesRepository.$saveHashrates(hashrates);
 | 
			
		||||
 | 
			
		||||
      await HashratesRepository.$setLatestRunTimestamp('last_hashrates_indexing');
 | 
			
		||||
      await HashratesRepository.$setLatestRun('last_hashrates_indexing', new Date().getUTCDate());
 | 
			
		||||
      this.hashrateIndexingStarted = false;
 | 
			
		||||
      if (newlyIndexed > 0) {
 | 
			
		||||
        logger.info(`Indexed ${newlyIndexed} day of network hashrate`);
 | 
			
		||||
 | 
			
		||||
@ -175,8 +175,8 @@ class Server {
 | 
			
		||||
 | 
			
		||||
  async $resetHashratesIndexingState() {
 | 
			
		||||
    try {
 | 
			
		||||
      await HashratesRepository.$setLatestRunTimestamp('last_hashrates_indexing', 0);
 | 
			
		||||
      await HashratesRepository.$setLatestRunTimestamp('last_weekly_hashrates_indexing', 0);
 | 
			
		||||
      await HashratesRepository.$setLatestRun('last_hashrates_indexing', 0);
 | 
			
		||||
      await HashratesRepository.$setLatestRun('last_weekly_hashrates_indexing', 0);
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
      logger.err(`Cannot reset hashrate indexing timestamps. Reason: ` + (e instanceof Error ? e.message : e));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -147,13 +147,13 @@ class HashratesRepository {
 | 
			
		||||
  /**
 | 
			
		||||
   * Set latest run timestamp
 | 
			
		||||
   */
 | 
			
		||||
  public async $setLatestRunTimestamp(key: string, val: any = null) {
 | 
			
		||||
  public async $setLatestRun(key: string, val: number) {
 | 
			
		||||
    const query = `UPDATE state SET number = ? WHERE name = ?`;
 | 
			
		||||
 | 
			
		||||
    try {
 | 
			
		||||
      await DB.query(query, (val === null) ? [Math.round(new Date().getTime() / 1000), key] : [val, key]);
 | 
			
		||||
      await DB.query(query, [val, key]);
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
      logger.err(`Cannot set last indexing timestamp for ${key}. Reason: ` + (e instanceof Error ? e.message : e));
 | 
			
		||||
      logger.err(`Cannot set last indexing run for ${key}. Reason: ` + (e instanceof Error ? e.message : e));
 | 
			
		||||
      throw e;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
@ -161,7 +161,7 @@ class HashratesRepository {
 | 
			
		||||
  /**
 | 
			
		||||
   * Get latest run timestamp
 | 
			
		||||
   */
 | 
			
		||||
  public async $getLatestRunTimestamp(key: string): Promise<number> {
 | 
			
		||||
  public async $getLatestRun(key: string): Promise<number> {
 | 
			
		||||
    const query = `SELECT number FROM state WHERE name = ?`;
 | 
			
		||||
 | 
			
		||||
    try {
 | 
			
		||||
@ -172,7 +172,7 @@ class HashratesRepository {
 | 
			
		||||
      }
 | 
			
		||||
      return rows[0]['number'];
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
      logger.err(`Cannot retreive last indexing timestamp for ${key}. Reason: ` + (e instanceof Error ? e.message : e));
 | 
			
		||||
      logger.err(`Cannot retrieve last indexing run for ${key}. Reason: ` + (e instanceof Error ? e.message : e));
 | 
			
		||||
      throw e;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
@ -189,8 +189,8 @@ class HashratesRepository {
 | 
			
		||||
        await DB.query(`DELETE FROM hashrates WHERE hashrate_timestamp = ?`, [row.timestamp]);
 | 
			
		||||
      }
 | 
			
		||||
      // Re-run the hashrate indexing to fill up missing data
 | 
			
		||||
      await this.$setLatestRunTimestamp('last_hashrates_indexing', 0);
 | 
			
		||||
      await this.$setLatestRunTimestamp('last_weekly_hashrates_indexing', 0);
 | 
			
		||||
      await this.$setLatestRun('last_hashrates_indexing', 0);
 | 
			
		||||
      await this.$setLatestRun('last_weekly_hashrates_indexing', 0);
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
      logger.err('Cannot delete latest hashrates data points. Reason: ' + (e instanceof Error ? e.message : e));
 | 
			
		||||
    }
 | 
			
		||||
@ -205,8 +205,8 @@ class HashratesRepository {
 | 
			
		||||
    try {
 | 
			
		||||
      await DB.query(`DELETE FROM hashrates WHERE hashrate_timestamp >= FROM_UNIXTIME(?)`, [timestamp]);
 | 
			
		||||
      // Re-run the hashrate indexing to fill up missing data
 | 
			
		||||
      await this.$setLatestRunTimestamp('last_hashrates_indexing', 0);
 | 
			
		||||
      await this.$setLatestRunTimestamp('last_weekly_hashrates_indexing', 0);
 | 
			
		||||
      await this.$setLatestRun('last_hashrates_indexing', 0);
 | 
			
		||||
      await this.$setLatestRun('last_weekly_hashrates_indexing', 0);
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
      logger.err('Cannot delete latest hashrates data points. Reason: ' + (e instanceof Error ? e.message : e));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -42,7 +42,7 @@ export class AddressLabelsComponent implements OnInit {
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      const topElement = this.vin.witness[this.vin.witness.length - 2];
 | 
			
		||||
      if (/^OP_IF OP_PUSHBYTES_33 \w{66} OP_ELSE OP_PUSHBYTES_(1 \w{2}|2 \w{4}) OP_CSV OP_DROP OP_PUSHBYTES_33 \w{66} OP_ENDIF OP_CHECKSIG$/.test(this.vin.inner_witnessscript_asm)) {
 | 
			
		||||
      if (/^OP_IF OP_PUSHBYTES_33 \w{66} OP_ELSE OP_PUSH(NUM_\d+|BYTES_(1 \w{2}|2 \w{4})) OP_CSV OP_DROP OP_PUSHBYTES_33 \w{66} OP_ENDIF OP_CHECKSIG$/.test(this.vin.inner_witnessscript_asm)) {
 | 
			
		||||
        // https://github.com/lightning/bolts/blob/master/03-transactions.md#commitment-transaction-outputs
 | 
			
		||||
        if (topElement === '01') {
 | 
			
		||||
          // top element is '01' to get in the revocation path
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user