Add fake p2wsh goggles

This commit is contained in:
Mononaut 2024-03-08 00:48:36 +00:00 committed by softsimon
parent bfde456ca8
commit 9a730b51d4
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7
5 changed files with 27 additions and 2 deletions

View File

@ -293,7 +293,6 @@ export class Common {
}
if (vout.value < (dustSize * DUST_RELAY_TX_FEE)) {
// under minimum output size
console.log(`NON-STANDARD | dust | ${vout.value} | ${dustSize} ${dustSize * DUST_RELAY_TX_FEE} `, tx.txid);
return true;
}
}
@ -456,6 +455,8 @@ export class Common {
flags |= TransactionFlags.no_rbf;
}
let hasFakePubkey = false;
let P2WSHCount = 0;
let olgaSize = 0;
for (const vout of tx.vout) {
switch (vout.scriptpubkey_type) {
case 'p2pk': {
@ -483,6 +484,20 @@ export class Common {
if (vout.scriptpubkey_address) {
reusedOutputAddresses[vout.scriptpubkey_address] = (reusedOutputAddresses[vout.scriptpubkey_address] || 0) + 1;
}
if (vout.scriptpubkey_type === 'v0_p2wsh') {
if (!P2WSHCount) {
olgaSize = parseInt(vout.scriptpubkey.slice(4, 8), 16);
}
P2WSHCount++;
if (P2WSHCount === Math.ceil((olgaSize + 2) / 32)) {
const nullBytes = (P2WSHCount * 32) - olgaSize - 2;
if (vout.scriptpubkey.endsWith(''.padEnd(nullBytes * 2, '0'))) {
flags |= TransactionFlags.fake_scripthash;
}
}
} else {
P2WSHCount = 0;
}
outValues[vout.value || Math.random()] = (outValues[vout.value || Math.random()] || 0) + 1;
}
if (hasFakePubkey) {

View File

@ -606,6 +606,12 @@ class DatabaseMigration {
await this.$executeQuery('ALTER TABLE `federation_txos` ADD emergencyKey TINYINT NOT NULL DEFAULT 0');
await this.updateToSchemaVersion(71);
}
if (databaseSchemaVersion < 72 && isBitcoin === true) {
// reindex Goggles flags for mined block templates above height 833000
await this.$executeQuery('UPDATE blocks_summaries SET version = 0 WHERE height >= 832000;');
await this.updateToSchemaVersion(72);
}
}
/**

View File

@ -107,6 +107,7 @@ class Mempool {
if (config.MEMPOOL.CACHE_ENABLED && config.REDIS.ENABLED) {
await redisCache.$addTransaction(this.mempoolCache[txid]);
}
this.mempoolCache[txid].flags = Common.getTransactionFlags(this.mempoolCache[txid]);
}
if (config.MEMPOOL.CACHE_ENABLED && config.REDIS.ENABLED) {
await redisCache.$flushTransactions();

View File

@ -226,6 +226,7 @@ export const TransactionFlags = {
op_return: 0b00000001_00000000_00000000_00000000n,
fake_pubkey: 0b00000010_00000000_00000000_00000000n,
inscription: 0b00000100_00000000_00000000_00000000n,
fake_scripthash: 0b00001000_00000000_00000000_00000000n,
// heuristics
coinjoin: 0b00000001_00000000_00000000_00000000_00000000n,
consolidation: 0b00000010_00000000_00000000_00000000_00000000n,

View File

@ -40,6 +40,7 @@ export const TransactionFlags = {
op_return: 0b00000001_00000000_00000000_00000000n,
fake_pubkey: 0b00000010_00000000_00000000_00000000n,
inscription: 0b00000100_00000000_00000000_00000000n,
fake_scripthash: 0b00001000_00000000_00000000_00000000n,
// heuristics
coinjoin: 0b00000001_00000000_00000000_00000000_00000000n,
consolidation: 0b00000010_00000000_00000000_00000000_00000000n,
@ -85,6 +86,7 @@ export const TransactionFilters: { [key: string]: Filter } = {
op_return: { key: 'op_return', label: 'OP_RETURN', flag: TransactionFlags.op_return, important: true },
fake_pubkey: { key: 'fake_pubkey', label: 'Fake pubkey', flag: TransactionFlags.fake_pubkey },
inscription: { key: 'inscription', label: 'Inscription', flag: TransactionFlags.inscription, important: true },
fake_scripthash: { key: 'fake_scripthash', label: 'Fake scripthash', flag: TransactionFlags.fake_scripthash },
/* heuristics */
coinjoin: { key: 'coinjoin', label: 'Coinjoin', flag: TransactionFlags.coinjoin, important: true },
consolidation: { key: 'consolidation', label: 'Consolidation', flag: TransactionFlags.consolidation },
@ -101,7 +103,7 @@ export const FilterGroups: { label: string, filters: Filter[]}[] = [
{ label: 'Features', filters: ['rbf', 'no_rbf', 'v1', 'v2', 'v3', 'nonstandard'] },
{ label: 'Address Types', filters: ['p2pk', 'p2ms', 'p2pkh', 'p2sh', 'p2wpkh', 'p2wsh', 'p2tr'] },
{ label: 'Behavior', filters: ['cpfp_parent', 'cpfp_child', 'replacement', 'acceleration'] },
{ label: 'Data', filters: ['op_return', 'fake_pubkey', 'inscription'] },
{ label: 'Data', filters: ['op_return', 'fake_pubkey', 'fake_scripthash', 'inscription'] },
{ label: 'Heuristics', filters: ['coinjoin', 'consolidation', 'batch_payout'] },
{ label: 'Sighash Flags', filters: ['sighash_all', 'sighash_none', 'sighash_single', 'sighash_default', 'sighash_acp'] },
].map(group => ({ label: group.label, filters: group.filters.map(filter => TransactionFilters[filter] || null).filter(f => f != null) }));