mirror of
https://github.com/bitcoin-core/gui-qml.git
synced 2026-12-02 07:54:42 +00:00
wallet: RPC coin locking leaves coin status and available balance stale #995
Labels
No labels
Android
Bug
Build system
Design suggestion
Doc
Needs design review
Needs rebase
Stage
UX
Up for grabs
Upstream
Wallet
duplicate
enhancement
good first issue
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin-core/gui-qml#995
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Locking a coin through RPC leaves the GUI showing its previous lock state and available balance. I reproduced both on
qt6: Core reports the only spendable coin as locked, but the open coin row still shows it unlocked and Send still shows 50 BTC available.These are two views of the same refresh gap, so I'm tracking them together.
Environment
qt6ata91f4b4774f25de061fe1a7c132a91ddde117fca.qt6is09c6de77d7f36bf7fa07c354ebeea51105c447a3; the relevant wallet and coin model code is unchanged.Setup
Start the GUI with a fresh regtest datadir and RPC enabled. Below,
climeansbitcoin-cli -regtest -datadir=/absolute/path/to/test-datadir, plus any RPC options for that node.Create a wallet with exactly one mature 50 BTC output. Mine the following 100 blocks to an address outside this wallet so they do not create more wallet transactions:
Select
rpc_lockin the GUI. Copy the sole output'stxidandvoutfromlistunspentfor the commands below.Reproduce the stale coin row
Open Settings → Wallet settings → View coins while the output is unlocked.
Leave the view open and lock that output from a terminal:
Core lists the locked output, but the existing GUI row retains its unlocked state.
Reproduce the stale available balance
Unlock the same output through RPC:
Open Send with no manually selected inputs and confirm that available balance is 50 BTC.
Run the same
lockunspent falsecommand again while Send remains open. Checklistlockunspentandlistunspentwithout generating an address, changing a label, or sending another transaction.The recorded results were:
The Send check still showed the old value after a two-second wait.
getbalances.mine.trustedis not the comparison for this check: locking a coin does not remove it from the wallet's trusted balance.Expected result
RPC lock/unlock changes should refresh both the coin list and the available balance without requiring another wallet event or reopening the wallet.
This gives users conflicting information about which coins are available. The reproduction establishes stale GUI state; it does not establish an unintended spend.
The coin model refreshes on transaction, address-book and balance signals, but external coin-lock changes do not produce the wallet notifications it relies on. Refreshing only after a GUI lock command won't cover this path.
Related to #974. This behavior already exists on
qt6; it is not introduced by #990. A regression test should keep each view open, lock and unlock through RPC without another wallet notification, and compare both displayed states with Core.One consequence of the stale available balance, at
eed1f426fcb6: with Use maximum, the "Use all available funds?" prompt quotes one amount and the review then prepares another.Regtest wallet with a 2 BTC coin and a 0.4 BTC coin, Automatic coin selection, 1 sat/vB.
After an outside unlock
lockunspent true, frombitcoin-clior from the app's own RPC console.The prompt reads "You're preparing to send all available funds (1.99999890 BTC) from this wallet." After Use maximum, the review shows 2.39999823 BTC to the recipient, a total of 2.40000000 BTC and 2 inputs, with Ready to send and Send transaction enabled. That is 0.4 BTC more than the amount on the form and in the prompt just accepted.
After an outside lock
The other direction: with both coins unlocked the form shows 2.39999823, and the 0.4 BTC coin is then locked with
lockunspent false. Thirty seconds later the prompt still quotes 2.39999823 BTC, and the review shows 1.99999890 BTC from one input. After closing the review the form shows 1.99999890 with Available 2.40000000 BTC, Amount plus fee exceeds available balance and a disabled Review button, until View coins is opened.The prompt uses the form's total (SendCreate.qml#L1199-L1205), and preparing the transaction then reads the wallet afresh. The review page shows the true amount and inputs, and I sent nothing. A lock or unlock made with the app's own Lock coins updates Send at once.
Tested on macOS / Qt 6.9, isolated regtest, offscreen only. The unlock case was run twice, once from the app's console and once from
bitcoin-cli; the lock case once. The console command was set into its field and submitted through the console's Enter handler; every other step was a click or typing through the test bridge. I have not run this on #990.