Skip to content

Commit

Permalink
feat: add ckb txhash from job returnvalue
Browse files Browse the repository at this point in the history
  • Loading branch information
ahonn committed Apr 19, 2024
1 parent 7ff82c6 commit fab26bb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/routes/rgbpp/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ const transactionRoute: FastifyPluginCallback<Record<never, never>, 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
Expand All @@ -81,6 +88,7 @@ const transactionRoute: FastifyPluginCallback<Record<never, never>, 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({
Expand Down

0 comments on commit fab26bb

Please sign in to comment.