Skip to content

Implement notifyreceived and notifyspent at confirmed-only fidelity - #935

Merged
evoskuil merged 10 commits into
libbitcoin:masterfrom
eynhaender:feature/notifyreceived
Sep 14, 2026
Merged

evoskuil merged 10 commits into
libbitcoin:masterfrom
eynhaender:feature/notifyreceived

Conversation

@eynhaender

Copy link
Copy Markdown
Contributor

Summary

btcd's legacy notifyreceived/notifyspent/stopnotifyreceived/ stopnotifyspent were previously stubbed not_implemented. lnd's btcwallet dependency calls these directly against a btcd backend — NewAddress/NewChangeAddress for receive-address watching, and the ChainNotifier's RegisterSpendNtfn for channel breach/force-close detection — so without them, lncli newaddress hard-fails and channel spend detection can't arm.

Implemented at confirmed-only fidelity (no mempool in v4), reusing loadtxfilter's cursor-based address/outpoint history matching wholesale. notifyreceived's address watch is permanent, like loadtxfilter's; each match auto-arms a one-shot spent-watch (also reachable via an explicit notifyspent) that fires once and is removed, per real btcd's own behavior. Kept in separate maps from loadtxfilter's permanent ones so the one-shot lifecycle can't corrupt loadtxfilter semantics for a client using both.

Test plan

  • New Boost.Test coverage: registration/validation, and delivery tests for recvtx (without notifyblocks) and redeemingtx
  • Full C++ suite green
  • Python acceptance suite updated (ack/reject tests replacing the old blanket not-implemented regression list)
  • Verified against a real lnd 0.21.1 node: lncli newaddress (p2wkh/np2wkh/p2tr) now succeeds instead of -1: misc_error

Reuses loadtxfilter's cursor-based address/outpoint history matching.
notifyreceived's address watch is permanent (like loadtxfilter's); each
match auto-arms a one-shot spent-watch (also reachable via an explicit
notifyspent), fired once and removed, kept in separate maps
(receive_watches_/spent_watches_) so the one-shot lifecycle can't corrupt
loadtxfilter's permanent semantics for a client using both.

recvtx/redeemingtx fire individually ([txHex, blockDetails], real btcd's
wire shape), independent of the notifyblocks subscription -- unlike
blockconnected/filteredblockconnected. This required extending
handle_chase's post-do_connected gate (previously subscribed_blocks_
only) with a second flag, watching_legacy_, since a client using only
notifyreceived never subscribes to notifyblocks.

No mempool in v4, so notifynewtransactions remains unimplemented; the
matched output's vout for auto-arming is found by walking the already
serialized transaction's own outputs by script hash, no new query needed.
Replaces the four not_implemented regression tests with real coverage:
input validation, register/unregister acks, a recvtx delivery test
(notifyreceived without notifyblocks, proving the two subscriptions are
independent), and a redeemingtx delivery test against mock_block10's
known spend of block1's coinbase. Updates btcd_methods::names and the
served/unserved static_asserts in test/interfaces/btcd.cpp now that
these four methods are no longer tagged unimplemented.
Removes the DEPRECATED_STUBS blanket "always not_implemented" table and
its regression test, now that these methods are real. Adds ack/reject
tests for notifyreceived/stopnotifyreceived/notifyspent/stopnotifyspent
mirroring the existing loadtxfilter test pattern. No live recvtx/
redeemingtx delivery test here -- would need real mainnet funds arriving
on cue; the C++ mock-store tests already cover the wire behavior
deterministically.
@evoskuil

Copy link
Copy Markdown
Member

were previously stubbed not_implemented.

These are deprecated by btcd, but if they are still in use we can keep them. Unfortunately neither btcd nor bitcoind which it sits on are versioned. Also btcd's implementation of bitcoind is ancient and includes drift, so there could be more issues for applications that reply on those breaks.

@johnconstant99-dev johnconstant99-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Update

@evoskuil

Copy link
Copy Markdown
Member

Update

Please explain or be blocked for spam.

@evoskuil
evoskuil merged commit c892fc5 into libbitcoin:master Sep 14, 2026
0 of 14 checks passed
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