|
28 | 28 | import crypto from 'crypto'; |
29 | 29 | import { getNostrPubkey, pubkeyToDidNostr } from '../auth/nostr.js'; |
30 | 30 | import { readLedger, writeLedger, getBalance, credit, debit } from '../webledger.js'; |
31 | | -import { verifyMrc20Deposit, verifyMrc20Anchor, jcs, sha256Hex, btAddress } from '../mrc20.js'; |
| 31 | +import { verifyMrc20Deposit, verifyMrc20Anchor, jcs, btAddress } from '../mrc20.js'; |
32 | 32 | import { loadTrail, transferToken, buildTransaction, broadcastTx, p2trScript } from '../token.js'; |
33 | 33 | import { secp256k1 } from '@noble/curves/secp256k1'; |
34 | 34 | import { bytesToHex, hexToBytes } from '@noble/hashes/utils'; |
@@ -440,11 +440,16 @@ export function createPayHandler(options = {}) { |
440 | 440 | const podAddress = btAddress(kp.pubkey, [], network); |
441 | 441 |
|
442 | 442 | // Fetch transaction from mempool |
443 | | - const txResp = await fetch(`${chain.explorer}/tx/${deposit.txid}`); |
444 | | - if (!txResp.ok) { |
445 | | - return reply.code(400).send({ error: 'Transaction not found' }); |
| 443 | + let txData; |
| 444 | + try { |
| 445 | + const txResp = await fetch(`${chain.explorer}/tx/${deposit.txid}`); |
| 446 | + if (!txResp.ok) { |
| 447 | + return reply.code(400).send({ error: 'Transaction not found' }); |
| 448 | + } |
| 449 | + txData = await txResp.json(); |
| 450 | + } catch (err) { |
| 451 | + return reply.code(502).send({ error: `Failed to verify transaction: ${err.message}` }); |
446 | 452 | } |
447 | | - const txData = await txResp.json(); |
448 | 453 | const output = txData.vout?.[deposit.vout]; |
449 | 454 | if (!output) { |
450 | 455 | return reply.code(400).send({ error: `Output ${deposit.vout} not found` }); |
|
0 commit comments