mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 14:53:43 +01:00
76c092ff80wallet: warn against accidental unsafe older() import (Sjors Provoost)592157b759test: move SEQUENCE_LOCKTIME flags to script (Sjors Provoost) Pull request description: [BIP 379](https://github.com/bitcoin/bips/blob/master/bip-0379.md) ([Miniscript](https://bitcoin.sipa.be/miniscript/)) allows relative height and time locks that have no consensus meaning in [BIP 68](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki) (relative timelocks) / [BIP 112](https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki) (`CHECKSEQUENCEVERIFY`). This is (ab)used by some protocols, e.g. [by Lightning to encode extra data](https://delvingbitcoin.org/t/exploring-extended-relative-timelocks/1818/23), but is unsafe when used unintentionally: `older(65536)` is equivalent to `older(1)`. This PR emits a warning when `importdescriptors` contains such a descriptor. The first commit makes `SEQUENCE_LOCKTIME` flags reusable by other tests. The main commit adds the `ForEachNode` helper to `miniscript.h` which is then used in the `MiniscriptDescriptor` constructor to check for `Fragment::OLDER` with unsafe values. These are stored in `m_warnings`, which the RPC code then collects via `Warnings()`. It adds both a unit and functional test. --- A previous version of this PR prevented the import, unless the user opted in with an `unsafe` flag. It also used string parsing in the RPC code. --- Based on: - [x] https://github.com/bitcoin/bitcoin/pull/33914 ACKs for top commit: pythcoiner: reACK76c092ff80achow101: ACK76c092ff80rkrux: lgtm re-ACK76c092ff80brunoerg: reACK76c092ff80Tree-SHA512: 8e944e499bd4a43cc27eeb889f262b499b9b07aa07610f4a415ccb4e34a9110f9946646f446a54ac5bf17494d8d96a89e4a1fa278385db9b950468f27283e17a
32 KiB
32 KiB