Skip to content

fix: include input-only transactions in GetFullBlock (#58) - #60

Draft
setavenger wants to merge 1 commit into
masterfrom
fix/full-block-input-only-txs
Draft

setavenger wants to merge 1 commit into
masterfrom
fix/full-block-input-only-txs

Conversation

@setavenger

@setavenger setavenger commented Sep 19, 2026 •

Copy link
Copy Markdown
Owner

Fixes #58.

What was broken

Both GetFullBlock implementations (gRPC internal/server/v2/service.go, and the deprecated HTTP /full-block handler in internal/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 GetFullBlock for exact outpoints never learned that a tracked output had been spent by such a transaction. GetSpentOutputsShort / StreamBlockScanDataShort are unaffected (they read a separate per-block blob that already includes these spends), but they only carry 8-byte pubkey prefixes, not outpoints.

GRPC.md already documents GetFullBlock as the call for "when the full input outpoint set is required", so this restores the documented contract.

The fix

  • The item list is built from the union of transactions with indexed outputs and transactions in the txid→outpoints index, sorted as before; each txid is served exactly once.
  • Items without a tweak carry an empty tweak (zero-length, not zero-filled), empty utxos, and their inputs. Over HTTP: "tweak": "", "utxos": [].
  • Transactions with a tweak are served unchanged — verified byte-identical against master for both gRPC (wire bytes) and HTTP (response body).
  • Same change applied to gRPC and to the existing deprecated HTTP handler. No routes added or changed, no .proto change, no other RPCs touched.
  • No reindex needed: the txid→outpoints rows have always been written for these transactions (dbpebble/store.go, outside the tweak gate), so existing databases already contain the data.

⚠️ Client-visible change

FullTxItem.tweak can now be empty. Clients must length-check it before parsing it as a public key; a client that parses tweak unconditionally will fail on the new items (the follow-up comment on #58 notes spdk's v2 backend does this). Documented in GRPC.md and internal/server/README.md.

The Rust client in blindbit-rs does not call GetFullBlock and 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, exact inputs bytes, 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):

--- FAIL: TestGetFullBlockIncludesInputOnlyTxs (0.00s)
    service_test.go:110: want 3 items, got 1
    service_test.go:132: tx B (input-only) missing
    service_test.go:148: tx C (tweakless) missing
--- FAIL: TestGetFullBlockOnlyInputOnlyTx (0.00s)
    service_test.go:219: want exactly 1 item, got 0
FAIL	github.com/setavenger/blindbit-oracle/internal/server/v2
--- FAIL: TestGetFullBlockOnlyInputOnlyTx (0.00s)
    handler_test.go:263: want exactly 1 item, got 0
FAIL	github.com/setavenger/blindbit-oracle/internal/server

With the fix, from a clean worktree (CGO_ENABLED=0 go build ./..., go vet ./..., gofmt -l internal/ all clean):

$ go test -count=1 ./...
ok  	github.com/setavenger/blindbit-oracle/internal/indexer	0.005s
ok  	github.com/setavenger/blindbit-oracle/internal/server	0.012s
ok  	github.com/setavenger/blindbit-oracle/internal/server/v2	0.011s
ok  	github.com/setavenger/blindbit-oracle/internal/types	0.002s

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.md documents the inputs vout 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 make inputs more 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-block sample JSON has trailing commas and lists a spent_outpoints field the handler does not emit. Pre-existing.

🤖 Generated with Claude Code


Note

Medium Risk
Client-visible GetFullBlock shape 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 inputs intact, an empty tweak (not zero-padded), and empty utxos ([] over HTTP). Tweak-carrying transactions are unchanged.

FullTxItem.tweak is now variable-length ([]byte / protobuf bytes); clients must length-check before parsing as a pubkey. Docs in GRPC.md and internal/server/README.md reflect this. Regression tests cover mixed blocks and input-only-only blocks for both handlers.

Reviewed by Cursor Bugbot for commit 562e78f. Configure here.

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>
@cursor

cursor Bot commented Sep 19, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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
setavenger marked this pull request as draft September 20, 2026 08:51
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.

GetFullBlock drops the outpoints it just fetched for input-only transactions

1 participant