Skip to content

feat(chain): add unified TxOutIndex<K> indexer#20

Open
evanlinjin wants to merge 2 commits into
masterfrom
claude/fervent-maxwell-V8RGw
Open

feat(chain): add unified TxOutIndex<K> indexer#20
evanlinjin wants to merge 2 commits into
masterfrom
claude/fervent-maxwell-V8RGw

Conversation

@evanlinjin

Copy link
Copy Markdown
Owner

TxOutIndex<K> collapses the wildcard/non-wildcard descriptor + raw-spk
split that previously required composing KeychainTxOutIndex<K> and
SpkTxOutIndex<W> (with a bridging Indexer impl per project) into a
single indexer keyed on K. The kind of script — wildcard descriptor,
non-wildcard descriptor, or raw spk registered via insert_spk — is
dispatched internally, so callers carry one keychain enum, one generic
parameter, and one ChangeSet type.

Overlap is rejected at insert time: a script pubkey can have exactly one
owning keychain, so index_of_spk always answers unambiguously and
applications carry multi-claim semantics as their own metadata.

This is additive; the existing KeychainTxOutIndex / SpkTxOutIndex
types are unchanged.

claude added 2 commits May 28, 2026 01:28
`TxOutIndex<K>` collapses the wildcard/non-wildcard descriptor + raw-spk
split that previously required composing `KeychainTxOutIndex<K>` and
`SpkTxOutIndex<W>` (with a bridging `Indexer` impl per project) into a
single indexer keyed on `K`. The kind of script — wildcard descriptor,
non-wildcard descriptor, or raw spk registered via `insert_spk` — is
dispatched internally, so callers carry one keychain enum, one generic
parameter, and one `ChangeSet` type.

Overlap is rejected at insert time: a script pubkey can have exactly one
owning keychain, so `index_of_spk` always answers unambiguously and
applications carry multi-claim semantics as their own metadata.

This is additive; the existing `KeychainTxOutIndex` / `SpkTxOutIndex`
types are unchanged.
Replace the duplicated state with two sub-indexers:

    pub struct TxOutIndex<K> {
        wildcard: KeychainTxOutIndex<K>,
        fixed:    SpkTxOutIndex<(K, u32)>,
    }

`KeychainTxOutIndex` already owns derivation, lookahead, and spk-cache
machinery for wildcard descriptors. Non-wildcard descriptors and raw
spks are operationally identical — one script per keychain at index 0,
no derivation — so they share storage on the fixed side. The descriptor
object for non-wildcards isn't retained because nothing in the indexer
needs it after the spk has been derived.

Methods are one-line delegations or chained iterators across the two
sides. Overlap detection runs against the lookahead window at insert
time. Net `-408` lines on the implementation.
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.

2 participants