diff options
| author | Adam Soltys <[email protected]> | 2026-02-07 13:22:56 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-02-07 13:22:56 -0800 |
| commit | 3cde20ead47bf2fc895ea37789b824098b984f7a (patch) | |
| tree | ea42d0d48ffddb084647233a78fa5d6f11353fd0 | |
| parent | ec5f47616f683a25fd729a94aec16103b1aa5e8d (diff) | |
| download | coinos-server-3cde20ead47bf2fc895ea37789b824098b984f7a.tar.gz coinos-server-3cde20ead47bf2fc895ea37789b824098b984f7a.zip | |
skip decoding outputs without addresses
| -rw-r--r-- | lib/zmq.ts | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -81,16 +81,21 @@ const decodeTx = (raw: Uint8Array, confirmed: boolean) => { const vout = []; for (let i = 0; i < tx.outputsLength; i++) { const { amount } = tx.getOutput(i); - vout.push({ - scriptpubkey_address: tx.getOutputAddress(i, btcNetwork), - value: Number(amount), - }); + let scriptpubkey_address: string | undefined; + try { + scriptpubkey_address = tx.getOutputAddress(i, btcNetwork); + } catch {} + if (scriptpubkey_address) { + vout.push({ scriptpubkey_address, value: Number(amount) }); + } } return { txid: tx.id, vout, status: { confirmed } }; }; const handleRawTx = async (raw: Uint8Array) => { - await processWatchedTx(decodeTx(raw, false)); + try { + await processWatchedTx(decodeTx(raw, false)); + } catch {} }; const handleRawBlock = async (raw: Uint8Array) => { |
