From f556c229f29d02e36f6c65ef8aca66b4a88f1613 Mon Sep 17 00:00:00 2001 From: ahonn Date: Fri, 19 Apr 2024 12:44:08 +1000 Subject: [PATCH] feat: get ckb txhash from job returnvalue --- src/routes/rgbpp/transaction.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/routes/rgbpp/transaction.ts b/src/routes/rgbpp/transaction.ts index 7c587fd4..e71f8bff 100644 --- a/src/routes/rgbpp/transaction.ts +++ b/src/routes/rgbpp/transaction.ts @@ -62,6 +62,13 @@ const transactionRoute: FastifyPluginCallback, Server, ZodT async (request, reply) => { const { btc_txid } = request.params; const isMainnet = env.NETWORK === 'mainnet'; + + // get the transaction hash from the job if it exists + const job = await fastify.transactionManager.getTransactionRequest(btc_txid); + if (job?.returnvalue) { + return { txhash: job.returnvalue }; + } + const transaction = await fastify.electrs.getTransaction(btc_txid); // query CKB transaction hash by RGBPP_LOCK cells @@ -81,6 +88,7 @@ const transactionRoute: FastifyPluginCallback, Server, ZodT } } + // XXX: unstable, need to be improved: https://github.com/ckb-cell/btc-assets-api/issues/45 // query CKB transaction hash by BTC_TIME_LOCK cells const btcTimeLockScript = getBtcTimeLockScript(isMainnet); const txs = await fastify.ckbIndexer.getTransactions({