Repository navigation
fix: include input-only transactions in GetFullBlock (#58) - #60
Draft
setavenger wants to merge 1 commit into
Draft
setavenger wants to merge 1 commit into
setavenger wants to merge 1 commit into
Conversation
GetFullBlock built its response by iterating only over transactions that have indexed outputs. Outputs are only stored for transactions with a tweak, so a transaction that spends tracked taproot outputs but creates no indexed output (input-only, or taproot inputs without a tweak) never produced an item. Its spent outpoints were fetched from the txid-outpoints index and then discarded. Clients relying on GetFullBlock therefore never learned that a tracked output had been spent by such a transaction. The item list is now built from the union of the transactions with indexed outputs and the transactions in the txid-outpoints index, sorted as before, with each txid served exactly once. Items without a tweak carry an empty `tweak`, empty `utxos`, and their `inputs`. Transactions with a tweak are served unchanged. The same fix is applied to the gRPC service and the deprecated HTTP /full-block handler; over HTTP a tweakless item has "tweak": "" and "utxos": []. The txid-outpoints index has always been written for these transactions, so existing databases already contain the data and no reindex is needed. Client-visible: `tweak` can now be empty. Clients must length-check it before parsing it as a public key. Adds regression tests for both handlers on an in-memory pebble store, including a block whose only relevant transaction is input-only. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_7bc16a15-9753-4224-a636-52e12f4f6007) |
setavenger
marked this pull request as draft
September 20, 2026 08:51
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.
Fixes #58.
What was broken
Both
GetFullBlockimplementations (gRPCinternal/server/v2/service.go, and the deprecated HTTP/full-blockhandler ininternal/server/handler.go) built their item list by iterating only the transactions that have indexed outputs. Outputs are only stored for transactions with a tweak, so a transaction that spends tracked taproot outputs but creates no indexed output — input-only, or taproot inputs with no tweak — never produced an item. Its spent outpoints were fetched from the txid→outpoints index and then discarded.User-visible consequence: a client relying on
GetFullBlockfor exact outpoints never learned that a tracked output had been spent by such a transaction.GetSpentOutputsShort/StreamBlockScanDataShortare unaffected (they read a separate per-block blob that already includes these spends), but they only carry 8-byte pubkey prefixes, not outpoints.GRPC.mdalready documentsGetFullBlockas the call for "when the full input outpoint set is required", so this restores the documented contract.The fix
tweak(zero-length, not zero-filled), emptyutxos, and theirinputs. Over HTTP:"tweak": "","utxos": [].masterfor both gRPC (wire bytes) and HTTP (response body)..protochange, no other RPCs touched.dbpebble/store.go, outside the tweak gate), so existing databases already contain the data.FullTxItem.tweakcan now be empty. Clients must length-check it before parsing it as a public key; a client that parsestweakunconditionally will fail on the new items (the follow-up comment on #58 notes spdk's v2 backend does this). Documented inGRPC.mdandinternal/server/README.md.The Rust client in
blindbit-rsdoes not callGetFullBlockand is unaffected.Verification
New regression tests for both handlers on an in-memory pebble store, going through the production path (
ApplyBlock→FlushBatch→ handler):TestGetFullBlockIncludesInputOnlyTxs— block with a normal tx, an input-only tx and a tweakless tx; asserts each txid once, exactinputsbytes, empty tweak / no utxos on the new items, unchanged item for the tweak-carrying tx, stable ordering across calls.TestGetFullBlockOnlyInputOnlyTx— block whose only relevant transaction is input-only.Without the fix (master's
handler.go,v2/service.go,types.go):With the fix, from a clean worktree (
CGO_ENABLED=0 go build ./...,go vet ./...,gofmt -l internal/all clean):go test -race ./internal/server/...also passes. Additional throwaway edge-case checks (300-input tx with large vouts, same prev txid spent in two blocks, txid present in both maps, 20 repeated calls over 60 mixed txs, block replaced at the same height) all passed.Not verified: nothing was run against a real synced database or a live Bitcoin Core node — none is available on the machine this was developed on. In particular, the "~79% of recorded spends exposed" measurement from #58 (mainnet blocks 965060–965089) was not reproduced; only the mechanism is proven, by the tests above.
Out of scope, noticed along the way
GRPC.mddocuments theinputsvout as 4-byte little-endian, but the store writes it big-endian (dbpebble/store.go,be32) and the handlers serve it as stored. Pre-existing and unchanged here; the new tests pin current behaviour. Since input-only items makeinputsmore load-bearing, this probably deserves its own issue.GRPC.md's "len / 36= input count" counts taproot prevouts only, not all inputs. Pre-existing.internal/server/README.md's/full-blocksample JSON has trailing commas and lists aspent_outpointsfield the handler does not emit. Pre-existing.🤖 Generated with Claude Code
Note
Medium Risk
Client-visible
GetFullBlockshape change (empty tweaks) can break callers that assume 33-byte tweaks, but the fix restores missing spend outpoints for UTXO-index clients.Overview
Fixes #58:
GetFullBlock(gRPC and deprecated HTTP/full-block) no longer drops transactions that spend tracked taproot outputs but have no indexed outputs or BIP-352 tweak.The index is built from the union of transactions with indexed outputs and transactions present in the txid→outpoints map (sorted by txid as before). Input-only and tweakless items now appear with their
inputsintact, an emptytweak(not zero-padded), and emptyutxos([]over HTTP). Tweak-carrying transactions are unchanged.FullTxItem.tweakis now variable-length ([]byte/ protobuf bytes); clients must length-check before parsing as a pubkey. Docs inGRPC.mdandinternal/server/README.mdreflect this. Regression tests cover mixed blocks and input-only-only blocks for both handlers.Reviewed by Cursor Bugbot for commit 562e78f. Configure here.