]> Untitled Git - bdk/commit
fix(chain): introduce keychain-variant-ranking to `KeychainTxOutIndex`
author志宇 <hello@evanlinjin.me>
Mon, 6 May 2024 11:21:13 +0000 (19:21 +0800)
committerDaniela Brozzoni <danielabrozzoni@protonmail.com>
Wed, 8 May 2024 13:49:50 +0000 (15:49 +0200)
commit9d8023bf56a693f1cb2ba340ed024c654307c069
tree2e67849fd2ea44f8fb03549bbe5528fd4f210f38
parent6c8748124fd40e0fee37f78ca30457441b13fbcb
fix(chain): introduce keychain-variant-ranking to `KeychainTxOutIndex`

This fixes the bug with changesets not being monotone. Previously, the
result of applying changesets individually v.s. applying the aggregate
of changesets may result in different `KeychainTxOutIndex` states.

The nature of the changeset allows different keychain types to share the
same descriptor. However, the previous design did not take this into
account. To do this properly, we should keep track of all keychains
currently associated with a given descriptor. However, the API only
allows returning one keychain per spk/txout/outpoint (which is a good
API).

Therefore, we rank keychain variants by `Ord`. Earlier keychain variants
have a higher rank, and the first keychain will be returned.
crates/chain/src/keychain/txout_index.rs