Issue Details

Number
31808
Title
nSequence is not set when spending from satisfiable descriptor with relative timelock
Description
### Is there an existing issue for this? - [x] I have searched the existing issues ### Current behaviour While experimenting with miniscript expressions on regtest (on commit [a43f08c4ae](https://github.com/bitcoin/bitcoin/commits/a43f08c4ae3235f2fa460dd17a7f5f9f9842efd9/)) with the cli, I imported a descriptor with the `older` fragment: `wsh(and_v(v:older(2),pk(tprv8ZgxMBicQKsPe5EVQ3cw3S1GdWyKxTeVvgVujejwFgJYGPucrUyPhsR2Zd4ngq3QSfB4HehpXqSPtwdoV7b8JYunU2kPai1AWUUxvb5gkrf/84h/1h/0h/1/*)))#tcaf9v8u` After sending money to an address made from this descriptor using `sendtoaddress` with an amount, I received the error message: ``` error code: -6 error message: Signing transaction failed ``` After stepping through the code in debug mode I found it was failing on [the following line within `CheckSequence`](https://github.com/bitcoin/bitcoin/blob/a43f08c4ae3235f2fa460dd17a7f5f9f9842efd9/src/script/interpreter.cpp#L1742): `const int64_t txToSequence = (int64_t)txTo->vin[nIn].nSequence;` This is because the nSequence on the input isn't being set according to the value specified in `older`. The easy workaround to this is to use `createrawtransaction` and manually set nSequence ### Expected behaviour The expected behavior is a transaction is made with the descriptor-locked input. I'm split between labeling this as a bug or feature request, but chose to file as a bug because the wallet has everything it needs to spend the input. Please reclassify this as a feature request if you do find it fits better with that label. ### Steps to reproduce - Create a new wallet - Import the descriptor and derive an address: ``` export desc="wsh(and_v(v:older(2),pk(tprv8ZgxMBicQKsPe5EVQ3cw3S1GdWyKxTeVvgVujejwFgJYGPucrUyPhsR2Zd4ngq3QSfB4HehpXqSPtwdoV7b8JYunU2kPai1AWUUxvb5gkrf/84h/1h/0h/1/*)))#tcaf9v8u" export descriptors="[{\"desc\":\"$desc\",\"timestamp\":\"now\"}]" b importdescriptors $descriptors b deriveaddresses $desc "[1,1]" ``` - Send money to the generated address from another wallet - Generate 3 blocks - Switch back to the wallet with the above descriptor and try to send funds out ### Relevant log output _No response_ ### How did you obtain Bitcoin Core Compiled from source ### What version of Bitcoin Core are you using? master@a43f08c4ae ### Operating system and version Ubuntu ### Machine specifications _No response_
URL
https://github.com/bitcoin/bitcoin/issue/31808
Closed by
Back to List