Skip to content

Add ability to search unconfirmed transactions#303

Merged
ChrisSchinnerl merged 5 commits intomasterfrom
christopher/search-unconfirmed
Feb 4, 2026
Merged

Add ability to search unconfirmed transactions#303
ChrisSchinnerl merged 5 commits intomasterfrom
christopher/search-unconfirmed

Conversation

@chris124567
Copy link
Member

Copilot AI review requested due to automatic review settings February 2, 2026 17:11
@github-project-automation github-project-automation bot moved this to In Progress in Sia Feb 2, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds the ability to search for unconfirmed transactions by ID, implementing step 1 of Issue #291. The implementation extends the existing Search functionality to check the transaction pool when a transaction is not found in the confirmed blockchain data.

Changes:

  • Modified the Search function to fall back to checking unconfirmed transaction pools (both V1 and V2) when the database search returns no results
  • Added a test case to verify searching for unconfirmed V1 transactions works correctly

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
explorer/explorer.go Extended Search function to query unconfirmed V1 and V2 transaction pools after database search fails
api/api_test.go Added test case for searching unconfirmed V1 transactions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chris124567 chris124567 force-pushed the christopher/search-unconfirmed branch from 611a790 to 88df3f6 Compare February 3, 2026 00:53

// check unconfirmed transaction pool
var txnID types.TransactionID
if err := txnID.UnmarshalText([]byte(id)); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

I think this is incorrect. The current error might be ErrNoSearchResults for an identifier that's not a transaction id. So if we fail to unmarshal it here we might be return a different, unwanted, error. We also don't take into account the txid prefix.

We should probably get rid of SearchTypeInvalid all together and in case search comes up short, optimistically parse the id as a txn id and check the pool, only in the success case we null the error and return the result, but in all other cases we return ErrNoSearchResults

Copy link
Member Author

@chris124567 chris124567 Feb 3, 2026

Choose a reason for hiding this comment

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

We removed the prefixes from all the types in core. I changed it to not error if it fails to unmarshal. I'd rather not change the API here but I don't feel strongly either way.

@ChrisSchinnerl ChrisSchinnerl merged commit 2184fbd into master Feb 4, 2026
10 checks passed
@ChrisSchinnerl ChrisSchinnerl deleted the christopher/search-unconfirmed branch February 4, 2026 15:29
@github-project-automation github-project-automation bot moved this from In Progress to Done in Sia Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants