Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include the descriptor in keychain::Changeset #1203

Merged
merged 13 commits into from
May 9, 2024

Commits on May 8, 2024

  1. ref(chain): move keychain::ChangeSet into txout_index.rs

    We plan to record `Descriptor` additions into persistence. Hence, we
    need to add `Descriptor`s to the changeset. This depends on
    `miniscript`. Moving this into `txout_index.rs` makes sense as this is
    consistent with all the other files. The only reason why this wasn't
    this way before, is because the changeset didn't need miniscript.
    
    Co-Authored-By: Daniela Brozzoni <danielabrozzoni@protonmail.com>
    evanlinjin and danielabrozzoni committed May 8, 2024
    Configuration menu
    Copy the full SHA
    b990293 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    8ff99f2 View commit details
    Browse the repository at this point in the history
  3. keychain::ChangeSet includes the descriptor

    - The KeychainTxOutIndex's internal SpkIterator now uses DescriptorId
      instead of K. The DescriptorId -> K translation is made at the
      KeychainTxOutIndex level.
    - The keychain::Changeset is now a struct, which includes a map for last
      revealed indexes, and one for newly added keychains and their
      descriptor.
    
    API changes in bdk:
    - Wallet::keychains returns a `impl Iterator` instead of `BTreeMap`
    - Wallet::load doesn't take descriptors anymore, since they're stored in
      the db
    - Wallet::new_or_load checks if the loaded descriptor from db is the
      same as the provided one
    
    API changes in bdk_chain:
    - `ChangeSet` is now a struct, which includes a map for last revealed
      indexes, and one for keychains and descriptors.
    - `KeychainTxOutIndex::inner` returns a `SpkIterator<(DescriptorId, u32)>`
    - `KeychainTxOutIndex::outpoints` returns a `impl Iterator` instead of `&BTreeSet`
    - `KeychainTxOutIndex::keychains` returns a `impl Iterator` instead of
      `&BTreeMap`
    - `KeychainTxOutIndex::txouts` doesn't return a ExactSizeIterator
      anymore
    - `KeychainTxOutIndex::unbounded_spk_iter` returns an `Option`
    - `KeychainTxOutIndex::next_index` returns an `Option`
    - `KeychainTxOutIndex::last_revealed_indices` returns a `BTreeMap`
      instead of `&BTreeMap`
    - `KeychainTxOutIndex::reveal_to_target` returns an `Option`
    - `KeychainTxOutIndex::reveal_next_spk` returns an `Option`
    - `KeychainTxOutIndex::next_unused_spk` returns an `Option`
    - `KeychainTxOutIndex::add_keychain` has been renamed to
      `KeychainTxOutIndex::insert_descriptor`, and now it returns a
      ChangeSet
    danielabrozzoni committed May 8, 2024
    Configuration menu
    Copy the full SHA
    4f05441 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    76afccc View commit details
    Browse the repository at this point in the history
  5. doc(bdk): Add instructions for manually inserting...

    ...secret keys in the wallet in Wallet::load
    danielabrozzoni committed May 8, 2024
    Configuration menu
    Copy the full SHA
    0e3e136 View commit details
    Browse the repository at this point in the history
  6. fix: Run tests only if the miniscript feature is..

    ..enabled, enable it by default
    danielabrozzoni committed May 8, 2024
    Configuration menu
    Copy the full SHA
    1d294b7 View commit details
    Browse the repository at this point in the history
  7. fix(chain): simplify Append::append impl for keychain::ChangeSet

    We only need to loop though entries of `other`. The logic before was
    wasteful because we were also looping though all entries of `self` even
    if we do not need to modify the `self` entry.
    evanlinjin authored and danielabrozzoni committed May 8, 2024
    Configuration menu
    Copy the full SHA
    6a3fb84 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    ed117de View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    537aa03 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    6c87481 View commit details
    Browse the repository at this point in the history
  11. 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.
    evanlinjin authored and danielabrozzoni committed May 8, 2024
    Configuration menu
    Copy the full SHA
    9d8023b View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    de53d72 View commit details
    Browse the repository at this point in the history

Commits on May 9, 2024

  1. Configuration menu
    Copy the full SHA
    86711d4 View commit details
    Browse the repository at this point in the history