Skip to content

Commit

Permalink
added safety to getDfTxTransactions so that it only parse OP_DEFI_TX …
Browse files Browse the repository at this point in the history
…if 'OP_DEFI_TX' is found (#301)
  • Loading branch information
fuxingloh authored Aug 3, 2021
1 parent ca64afc commit 3a648ac
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions apps/whale/src/module.indexer/model/dftx.indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class MainDfTxIndexer extends Indexer {
}
}

function getDfTxTransactions (block: RawBlock): Array<DfTxTransaction<any>> {
export function getDfTxTransactions (block: RawBlock): Array<DfTxTransaction<any>> {
const transactions: Array<DfTxTransaction<any>> = []

for (const txn of block.tx) {
Expand All @@ -56,9 +56,10 @@ function getDfTxTransactions (block: RawBlock): Array<DfTxTransaction<any>> {
continue
}

const stack: OPCode[] = toOPCodes(
SmartBuffer.fromBuffer(Buffer.from(vout.scriptPubKey.hex, 'hex'))
)
const stack: OPCode[] = toOPCodes(SmartBuffer.fromBuffer(Buffer.from(vout.scriptPubKey.hex, 'hex')))
if (stack[1].type !== 'OP_DEFI_TX') {
continue
}
transactions.push({ txn: txn, dftx: (stack[1] as OP_DEFI_TX).tx })
}
}
Expand Down

0 comments on commit 3a648ac

Please sign in to comment.