Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: check recent confirmed utxos to void missing pending xudt #180

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/routes/rgbpp/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,12 @@ const addressRoutes: FastifyPluginCallback<Record<never, never>, Server, ZodType
};
});

const pendingUtxos = utxos.filter((utxo) => !utxo.status.confirmed);
const pendingUtxos = utxos.filter(
(utxo) =>
!utxo.status.confirmed ||
// include utxo that confirmed in 20 minutes to avoid missing pending xudt
(utxo.status.block_time && Date.now() / 1000 - utxo.status.block_time < 20 * 60),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to identify RGBPP UTXOs with the pending jobs in the queue?

Copy link
Collaborator Author

@ahonn ahonn Jun 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's another way to accomplish this, but the transaction queue may contain many pending jobs. We need to retrieve transaction details using the pending jobs' txid to determine if the transaction belongs to the current address.

Also, the number of pending jobs might exceed the number of transactions that have occurred within the last 20 minutes by the current address.

The issue here is that we cannot obtain the pending amount between the BTC transaction being confirmed and the CKB transaction being confirmed. Therefore, I believe it is sufficient to obtain the confirmed BTC transactions 20 minutes before the current time would work and have minimal modification.

);
const pendingUtxosGroup = groupBy(pendingUtxos, (utxo) => utxo.txid);
const pendingTxids = Object.keys(pendingUtxosGroup);

Expand Down
Loading