Reserve one wallet output during a coin-selection experiment
When testing two transaction builders on regtest, exclude a particular output from automatic selection in the same wallet while the first builder is working.
Lock an exact outpoint
Set TXID and VOUT to an unspent output in the loaded lab wallet. Build the JSON array with jq so the index is sent as a number. The default lock lasts only for the running wallet session.
out=$(jq -cn --arg t "$TXID" --argjson n "$VOUT" '[{txid:$t,vout:$n}]')
bitcoin-cli -regtest -rpcwallet=lab lockunspent false "$out"
bitcoin-cli -regtest -rpcwallet=lab listlockunspent
Release only your reservation
Check that the pair appears in the lock list. After the experiment run lockunspent true with the same array. Omitting that array when unlocking clears all locks in the wallet. The reservation controls local automatic coin selection and does not prevent another wallet with the keys from spending the output.
bitcoincore.org lockunspent · bitcoincore.org listlockunspent