Merge branch 'natsee/liquid-federation-audit' into natsee/liquid-audit-dashboard
This commit is contained in:
commit
b7feb0d43d
@ -561,8 +561,8 @@ class DatabaseMigration {
|
|||||||
|
|
||||||
if (databaseSchemaVersion < 67 && config.MEMPOOL.NETWORK === "liquid") {
|
if (databaseSchemaVersion < 67 && config.MEMPOOL.NETWORK === "liquid") {
|
||||||
// Drop and re-create the elements_pegs table
|
// Drop and re-create the elements_pegs table
|
||||||
await this.$executeQuery('DROP table IF EXISTS elements_pegs;');
|
await this.$executeQuery('TRUNCATE TABLE elements_pegs');
|
||||||
await this.$executeQuery(this.getCreateElementsTableQuery(), await this.$checkIfTableExists('elements_pegs'));
|
await this.$executeQuery('ALTER TABLE elements_pegs ADD PRIMARY KEY (txid, txindex);');
|
||||||
await this.$executeQuery(`UPDATE state SET number = 0 WHERE name = 'last_elements_block';`);
|
await this.$executeQuery(`UPDATE state SET number = 0 WHERE name = 'last_elements_block';`);
|
||||||
// Create the federation_addresses table and add the two Liquid Federation change addresses in
|
// Create the federation_addresses table and add the two Liquid Federation change addresses in
|
||||||
await this.$executeQuery(this.getCreateFederationAddressesTableQuery(), await this.$checkIfTableExists('federation_addresses'));
|
await this.$executeQuery(this.getCreateFederationAddressesTableQuery(), await this.$checkIfTableExists('federation_addresses'));
|
||||||
@ -816,8 +816,7 @@ class DatabaseMigration {
|
|||||||
bitcoinaddress varchar(100) NOT NULL,
|
bitcoinaddress varchar(100) NOT NULL,
|
||||||
bitcointxid varchar(65) NOT NULL,
|
bitcointxid varchar(65) NOT NULL,
|
||||||
bitcoinindex int(11) NOT NULL,
|
bitcoinindex int(11) NOT NULL,
|
||||||
final_tx int(11) NOT NULL,
|
final_tx int(11) NOT NULL
|
||||||
PRIMARY KEY (txid, txindex)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;`;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,27 +356,30 @@ class ElementsParser {
|
|||||||
// Get all of the federation addresses one month ago, most balances first
|
// Get all of the federation addresses one month ago, most balances first
|
||||||
public async $getFederationAddressesOneMonthAgo(): Promise<any> {
|
public async $getFederationAddressesOneMonthAgo(): Promise<any> {
|
||||||
const query = `
|
const query = `
|
||||||
SELECT bitcoinaddress, SUM(amount) AS balance FROM federation_txos
|
SELECT COUNT(*) AS addresses_count_one_month FROM (
|
||||||
|
SELECT bitcoinaddress, SUM(amount) AS balance
|
||||||
|
FROM federation_txos
|
||||||
WHERE
|
WHERE
|
||||||
(blocktime < UNIX_TIMESTAMP(TIMESTAMPADD(DAY, -30, CURRENT_TIMESTAMP())))
|
(blocktime < UNIX_TIMESTAMP(TIMESTAMPADD(DAY, -30, CURRENT_TIMESTAMP())))
|
||||||
AND
|
AND
|
||||||
((unspent = 1) OR (unspent = 0 AND lasttimeupdate > UNIX_TIMESTAMP(TIMESTAMPADD(DAY, -30, CURRENT_TIMESTAMP()))))
|
((unspent = 1) OR (unspent = 0 AND lasttimeupdate > UNIX_TIMESTAMP(TIMESTAMPADD(DAY, -30, CURRENT_TIMESTAMP()))))
|
||||||
GROUP BY bitcoinaddress ORDER BY balance DESC;`;
|
GROUP BY bitcoinaddress
|
||||||
|
) AS result;`;
|
||||||
const [rows] = await DB.query(query);
|
const [rows] = await DB.query(query);
|
||||||
return rows;
|
return rows[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all of the UTXOs held by the federation one month ago, most recent first
|
// Get all of the UTXOs held by the federation one month ago, most recent first
|
||||||
public async $getFederationUtxosOneMonthAgo(): Promise<any> {
|
public async $getFederationUtxosOneMonthAgo(): Promise<any> {
|
||||||
const query = `
|
const query = `
|
||||||
SELECT txid, txindex, bitcoinaddress, amount, blocknumber, blocktime, pegtxid, pegindex FROM federation_txos
|
SELECT COUNT(*) AS utxos_count_one_month FROM federation_txos
|
||||||
WHERE
|
WHERE
|
||||||
(blocktime < UNIX_TIMESTAMP(TIMESTAMPADD(DAY, -30, CURRENT_TIMESTAMP())))
|
(blocktime < UNIX_TIMESTAMP(TIMESTAMPADD(DAY, -30, CURRENT_TIMESTAMP())))
|
||||||
AND
|
AND
|
||||||
((unspent = 1) OR (unspent = 0 AND lasttimeupdate > UNIX_TIMESTAMP(TIMESTAMPADD(DAY, -30, CURRENT_TIMESTAMP()))))
|
((unspent = 1) OR (unspent = 0 AND lasttimeupdate > UNIX_TIMESTAMP(TIMESTAMPADD(DAY, -30, CURRENT_TIMESTAMP()))))
|
||||||
ORDER BY blocktime DESC;`;
|
ORDER BY blocktime DESC;`;
|
||||||
const [rows] = await DB.query(query);
|
const [rows] = await DB.query(query);
|
||||||
return rows;
|
return rows[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user