Is there an existing issue for this?
- I have searched the existing issues
Current behaviour
I did the following against a wallet:
fundrawtransactionwith"lockUnspents": truelockunspent false [those inputs] persistent=trueto make the same locks survive a restart.- Signed and broadcast the funded transaction, then mined a block.
After step 3 listlockunspent is empty, since the wallet released the locks when it saw the inputs get spent. But after restarting bitcoind and loading the wallet, listlockunspent lists those inputs again, even though they are spent and gettxout returns nothing for them.
Expected behaviour
A lock that the wallet already released when the output was spent should not come back after a restart.
Steps to reproduce
an LLM wrote this script but it follows the steps I did against the wallet that surfaced the issue
bitcoin-cli -regtest createwallet w
ADDR=$(bitcoin-cli -regtest -rpcwallet=w getnewaddress)
bitcoin-cli -regtest -rpcwallet=w generatetoaddress 101 $ADDR
# 1. fund a transaction with lockUnspents
RAW=$(bitcoin-cli -regtest -rpcwallet=w createrawtransaction '[]' "{\"$(bitcoin-cli -regtest -rpcwallet=w getnewaddress)\":1}")
FUNDED=$(bitcoin-cli -regtest -rpcwallet=w fundrawtransaction $RAW '{"lockUnspents":true,"minconf":1}' | jq -r .hex)
LOCKED=$(bitcoin-cli -regtest -rpcwallet=w listlockunspent | jq -c .)
echo $LOCKED # one outpoint
# 2. re-lock that outpoint with persistent=true
bitcoin-cli -regtest -rpcwallet=w lockunspent false "$LOCKED" true
# 3. spend the locked output and confirm it
SIGNED=$(bitcoin-cli -regtest -rpcwallet=w signrawtransactionwithwallet $FUNDED | jq -r .hex)
bitcoin-cli -regtest sendrawtransaction $SIGNED
bitcoin-cli -regtest -rpcwallet=w listlockunspent # [] as expected
bitcoin-cli -regtest -rpcwallet=w generatetoaddress 1 $ADDR
# 4. reload the wallet (a bitcoind restart behaves the same)
bitcoin-cli -regtest unloadwallet w
bitcoin-cli -regtest loadwallet w
bitcoin-cli -regtest -rpcwallet=w listlockunspent # the spent outpoint is back
bitcoin-cli -regtest gettxout <txid> <vout> # empty
Relevant log output
No response
How did you obtain Bitcoin Core
Compiled from source
What version of Bitcoin Core are you using?
v30.2
Operating system and version
Ubuntu 24.04 LTS
Machine specifications
No response