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

Add a POST /txs bulk query-by-txid endpoint #33

Merged
merged 4 commits into from
Nov 12, 2023
Merged

Conversation

mononaut
Copy link
Contributor

@mononaut mononaut commented Aug 5, 2023

(builds on #38)

Similar to #31, this PR adds a new /txs POST endpoint which accepts an array of txids and returns a list of matching transactions from both the mempool and the chain.

Used by mempool/mempool#4101

src/rest.rs Outdated Show resolved Hide resolved
src/rest.rs Outdated
@@ -1005,6 +1005,32 @@ fn handle_request(

json_response(tx.remove(0), ttl)
}
(&Method::POST, Some(&"txs"), None, None, None, None) => {
Copy link
Member

Choose a reason for hiding this comment

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

Is this only going to be exposed to the backend?

If so, we should have the first path be the same for all internal endpoints...

Copy link
Member

Choose a reason for hiding this comment

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

/mempool is fine, then we can just whitelist the backend to access /mempool/*

Whatever it is, endpoints we don't want to expose need to be protected somehow.

protected or internal might be better (but require changes on the backend as well)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we use /mempool/recent in the frontend, so we can't block /mempool/* completely.

But a common prefix for all of the non-public endpoints seems like a good idea.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, let's grow the scope of this PR (and the corresponding backend PR) to unify all the endpoints we want to block publicly under one root.

internal seems fine.

Maybe we should feature gate them, and update the production deployment instructions etc. to use that feature flag... that way if someone wants to use ONLY electrs, they don't default to exposing the internal endpoints.

junderw
junderw previously requested changes Aug 6, 2023
Copy link
Member

@junderw junderw left a comment

Choose a reason for hiding this comment

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

We should do something about the path naming convention and implement whitelisting in nginx conf

@junderw junderw mentioned this pull request Aug 15, 2023
@mononaut mononaut force-pushed the mononaut/bulk-txs-post-api branch from e303bf7 to 6f898d6 Compare August 16, 2023 09:06
@mononaut
Copy link
Contributor Author

Rebased on PR #38, and added the new internal-api prefix to this endpoint

src/rest.rs Outdated Show resolved Hide resolved
@mononaut mononaut force-pushed the mononaut/bulk-txs-post-api branch from 6f898d6 to d3509c4 Compare August 28, 2023 07:47
@mononaut mononaut force-pushed the mononaut/bulk-txs-post-api branch from d3509c4 to 59be248 Compare November 12, 2023 05:31
@mononaut
Copy link
Contributor Author

re-rebased on #38

Copy link
Member

@wiz wiz left a comment

Choose a reason for hiding this comment

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

Tested ACK @ mempool-electrs 3.0.0-dev-9ee9a5d

@wiz wiz dismissed junderw’s stale review November 12, 2023 10:11

internal API naming convention has been addressed

@wiz wiz merged commit 157dbf2 into mempool Nov 12, 2023
7 checks passed
@wiz wiz deleted the mononaut/bulk-txs-post-api branch November 12, 2023 10:11
SatoKentaNayoro pushed a commit to boolnetwork/mempool-electrs that referenced this pull request Nov 29, 2024
Add a POST /txs bulk query-by-txid endpoint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants