Skip to content

Conversation

@cculianu
Copy link
Owner

@cculianu cculianu commented Oct 23, 2025

Implementation of protocol v1.6 as discussed here: spesmilo/electrum-protocol#6 .

Summary of protocol changes:

  • blockchain.estimatefee changes (added optional mode 2nd parameter)
  • Added mempool.get_info
  • blockchain.transaction.broadcast_package
  • server.version allow extra args, but ignore them
  • blockchain.block.headers changed to return a list, rather than a concatenated hex blob
  • Canonical mempool order for status hash (already was implemented in Fulcrum). Note the Electrum devs want to do something unexpected here so I will not be doing it their way in Fulcrum, but instead will be doing the obvious thing: protocol 1.6: minimal update to get broadcast_package out spesmilo/electrum-protocol#6 (comment)

Also did some internal changes:

  • Added mechanism to cache results from bitcoind RPC for a limited time
  • Redid some of the auto-detect logic as captured by struct BitcoinDInfo
  • Misc other nits and fixups that came to me along the way.

…oind responses

Added a new method, mempoool.get_info which is just the result of
`getmempoolinfo` on the bitcoind side.

We cache this response for 5 seconds. Added a generic mechanism to cache
bitcoind responses for calls that do not need to be super up-to-date and
which can be cached for a time.

The cache is owned by BitcoinDMgr and is cleared when re-connecting to
bticoind. It auto-cleans itself when entries get stale.
Optional second arg, is a string. Gets forwarded to bitcoind verbatim so
it's whatever bitcoind supports (e.g. "conservative" or "economical").

Also in this commit: Redid some of the auto-detection logic to determine
what RPCs the remote daemon supports.
@cculianu cculianu changed the title Implement Protocol v1.6 Draft: Implement Protocol v1.6 Oct 23, 2025
@cculianu cculianu added the enhancement New feature or request label Oct 23, 2025
Let's do what ElectrumX is doing and not return the full dictionary from
`getmempoolinfo` and instead restrict it to a subset of useful keys to
preserve privacy.
Having it be too large may confuse clients especially after a block is
confirmed. 250msec should be enough to rate-limit spam but also provide
reasonable responsiveness to wallets that care about this stat.
…coinDMgr

Also added detection for the new `submitpackages` RPC (bitcoin core >=
28.0.0). Not yet used but the flag is there.
Only change between Core 27 and Core 28 is that 28 has 2 new optional
args... otherwise nearly identical semantics.  Allow submitpackage as
early as on Core 27.
Apparently Core 27.0.0 has it but it's largely not useful. According to
ElectrumX devs. See: https://github.com/spesmilo/electrum-protocol/pull/6/files#r2459860616
BTC Core v28.0.0 or above only. As per Protocol v1.6 spec.
Only if the server supports it (currently only Bitcoin Core >= v28.0.0)
And does the unexpected thing if appending a list to a list.. :/
Paranoia just in case an exception is somehow thrown before we hand the
job off to the threadpool.
We validate args in an asynch thread since that is potentially costly
(we must hash the first txn, etc).

When that's done, we forward request to bitcoind.

This required us allowing generic_do_async to accept an optional
"completion" function. In order to make things cleaner and faster we
templatized ServerBase::generic_do_async, and redid its internals
slightly. Hopefully this is cleaner and also hopefully redundant copies
of e.g. std::function are avoided with this template implementation.

Also in this commit: Various nits and fixups in Util.h, added
ThrowInternalErrorIf() macro, and other misc. cleanup.
…submitpackage

Also in this commit:

- Updated README.md to talk about v1.6 protocol compatibility and need
  for v28.0.0 or above of Core/Knots
- Updated RPC error message saying Bitcoin Core or Bitcoin Knots (not
  just Bitcoin Core) >= v28.0.0 is ok for submitpackage.
@cculianu cculianu changed the title Draft: Implement Protocol v1.6 Implement Protocol v1.6 Nov 4, 2025
@cculianu cculianu merged commit 56380f1 into master Nov 5, 2025
@cculianu cculianu deleted the protocol_1_6 branch November 5, 2025 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants