mempool / electrs

An efficient re-implementation of Electrum Server in Rust
MIT License
60 stars 30 forks source link

Add testmempoolaccept endpoint #81

Closed mononaut closed 5 months ago

mononaut commented 5 months ago

This PR adds a new REST API endpoint POST /txs/test, which accepts a comma-separated list of transactions as raw hex strings, passes them to testmempoolaccept, and returns the results as JSON.

junderw commented 5 months ago

Q: Where do you plan to use this endpoint and how?

mononaut commented 5 months ago

Access to testmempoolaccept is a frequent feature request from some of our API users, but I'll probably also add an interface to the mempool frontend similar to the /tx/push page.

junderw commented 5 months ago

Yeah, if we're going to offer this publicly, we should definitely offer an optional maxfeerate parameter.

Might be worth it to check the request body to make sure it's only hex and commas... and maybe we should limit it somehow. (Might be a DoS vector)

mononaut commented 5 months ago

Added support for the optional maxfeerate parameter (via query string), and added some basic pre-checks to the POSTed raw transactions for valid hexadecimal-ness and string length.

mononaut commented 5 months ago
mononaut commented 5 months ago

Switched maxfeerate param from f32 to f64