wallet coin selection: don’t mixup coins with absolute timelocks of different types #27526

issue darosior openend this issue on April 24, 2023
  1. darosior commented at 4:48 pm on April 24, 2023: member

    We now support spending from coins containing CHECKLOCKTIMEVERIFY instructions. CLTV is a check on the value of the nLockTime field of the spending transaction. There are two types of timelocks possible: by timestamp and by block. Both are incompatible, the nLockTime field cannot satisfy both a timestamp and a block timelock.

    The coin selection is at the moment completely unaware of timelocks. If we have two coins for two different descriptors, one with a timestamp absolute timelock and the other with a block count absolute timelock, the coin selection algorithm may select both of them in a single transaction.

    To be clear i don’t think this should be treated as a bug that needs resolving for 25.0. As mentioned in #24149 the wallet needs a lot more logic to correctly handle managing coins with more complex scripts. (For instance, the wallet doesn’t know what timelocked coins would be spendable at the next block, let alone set the nSequence, nLockTime according to the required value.)

    From a conversation with @sanket1729. Also cc @ishaanam.

  2. ishaanam commented at 4:30 am on November 12, 2023: contributor
    I have started working on fixing this issue and have a solution that seems like it works. I should have a draft PR open soon. The solution involves using TreeEval to determine the time locks of a given script, and making sure that coins with absolute timelocks of different types are not mixed using CoinEligibilityFilters.

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-03-14 15:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me