Skip to content

Commit

Permalink
workaround for block 14,874,851
Browse files Browse the repository at this point in the history
  • Loading branch information
techcoderx committed Apr 12, 2022
1 parent d6abdf7 commit 0f41fa6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ const Transaction = require('./transactions')
const TransactionType = Transaction.Types
const max_mempool = process.env.MEMPOOL_SIZE || 200

// probably due to non standard utf8 characters that were not properly written to mongodb/bson file
// for now we skip them until such bug can be reproduced
const skiphash = {
'7dedc07cb42c96b5013710161bf487a2488fce789b80286e3df910075f98a4d1': '16de2c5c847962f3683aec852072e702fb8c4ffd81c3d23cf85b8d2da031bd8e' // tx in block 14,874,851
}

transaction = {
pool: [], // the pool holds temporary txs that havent been published on chain yet
eventConfirmation: new EventEmitter(),
Expand Down Expand Up @@ -114,7 +120,8 @@ transaction = {
let newTx = cloneDeep(tx)
delete newTx.signature
delete newTx.hash
if (CryptoJS.SHA256(JSON.stringify(newTx)).toString() !== tx.hash) {
let computedHash = CryptoJS.SHA256(JSON.stringify(newTx)).toString()
if (computedHash !== tx.hash && (skiphash[tx.hash] !== computedHash || (!p2p.recovering && chain.getLatestBlock()._id > chain.restoredBlocks))) {
cb(false, 'invalid tx hash does not match'); return
}
// checking transaction signature
Expand Down

0 comments on commit 0f41fa6

Please sign in to comment.