Add new test mempool accept method#1212
Open
arminsabouri wants to merge 1 commit intoromanz:masterfrom
Open
Conversation
This commits adds a new rpc method (`blockchain.transaction.testmempoolaccept`) which proxies to Bitcoind's [testmempoolaccept](https://developer.bitcoin.org/reference/rpc/testmempoolaccept.html)
9 tasks
kwsantiago
suggested changes
Oct 27, 2025
kwsantiago
left a comment
There was a problem hiding this comment.
Concept ACK.
Main issue is missing tests for this new RPC method. There should be basic test coverage for valid/invalid transaction scenarios at the minimum.
| .context("failed to broadcast transaction") | ||
| } | ||
|
|
||
| pub(crate) fn test_mempool_accept(&self, tx: &Transaction) -> Result<bool> { |
There was a problem hiding this comment.
Consider returning the full test result instead of just the allowed bool.
| let tx_bytes = Vec::from_hex(tx_hex).context("non-hex transaction")?; | ||
| let tx = deserialize(&tx_bytes).context("invalid transaction")?; | ||
| let accepted = self.daemon.test_mempool_accept(&tx)?; | ||
| Ok(json!(accepted)) |
There was a problem hiding this comment.
May want to add something like:
Ok(json!({"allowed": accepted, "reject_reason": ...}))
Currently clients will get no diagnostic info when a tx is rejected.
| "blockchain.scripthash.subscribe" => Params::ScriptHashSubscribe(convert(params)?), | ||
| "blockchain.scripthash.unsubscribe" => Params::ScriptHashUnsubscribe(convert(params)?), | ||
| "blockchain.transaction.broadcast" => Params::TransactionBroadcast(convert(params)?), | ||
| "blockchain.transaction.testmempoolaccept" => { |
There was a problem hiding this comment.
Does this method name match Electrum protocol spec, or is this a custom extension? May want to document if the latter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commits adds a new rpc method
(
blockchain.transaction.testmempoolaccept) which proxies to Bitcoin'd testmempoolacceptSeeking a concept Ack/Nack here. My motivation for this PR comes from wanting to use Payjoin on wallets that use electrum as their primary block source. More info here.
Usage example