send: Amount validation stays invalid after funding or coinbase maturity #996

Open
opened 2026-10-12 00:21:40 +00:00 by jarolrod · 0 comments
jarolrod commented 2026-10-12 00:21:40 +00:00 (Migrated from github.com)

An amount entered before the wallet has enough funds can stay invalid after the balance changes. I reproduced this on qt6 with both an ordinary incoming payment and coinbase maturity.

For the ordinary payment, Send shows 2 BTC available but still rejects the existing 1 BTC draft with "Amount exceeds available balance". Review stays disabled until the amount is edited.

#990 fixes the ordinary incoming-payment case in the build I tested. The maturity refresh gap remains, and on #990 it also rejects an amount first entered after maturity. These need to be distinguished when checking the fix.

Environment

  • macOS 26.6.2, Qt 6.9.0, Release builds.
  • Runtime comparisons: qt6 at a91f4b4774f25de061fe1a7c132a91ddde117fca and #990 at 7e432cefdc77a0c473477a34b8b3138d7a0522c2.
  • Rechecked current heads: qt6 at 09c6de77d7f36bf7fa07c354ebeea51105c447a3, #990 at 2f8b6d43f1ced340ed424ef397739b888e63098d. Their relevant wallet/recipient model code is unchanged from the tested builds.
  • Real disposable regtest wallets, with QML test automation used to navigate the GUI and observe validation. Funding and maturity were checked independently through Core RPC.

For the steps below, start the GUI with a fresh regtest datadir, RPC enabled and a fallback fee, for example -regtest -server -fallbackfee=0.0001. cli means bitcoin-cli -regtest -datadir=/absolute/path/to/test-datadir, plus any RPC options for that node.

Case 1: an incoming payment funds an existing draft

  1. Create an empty recipient wallet and a separate funded wallet:

    cli -named createwallet wallet_name=send_draft
    cli -named createwallet wallet_name=send_funder
    FUNDER_ADDR=$(cli -rpcwallet=send_funder getnewaddress)
    cli generatetoaddress 101 "$FUNDER_ADDR"
    RECEIVE_ADDR=$(cli -rpcwallet=send_draft getnewaddress)
    
  2. Select send_draft in the GUI and open Send. Enter destination bcrt1qdavt4j2sd7dlhqsavtnfxvzppw6k7qy97tmnu9 and amount 1 BTC. Confirm that the insufficient-balance error is shown.

  3. Keep the draft open and leave its address and amount untouched. Fund it and confirm the payment:

    cli -rpcwallet=send_funder sendtoaddress "$RECEIVE_ADDR" 2
    cli generatetoaddress 1 "$FUNDER_ADDR"
    cli -rpcwallet=send_draft getbalances
    
  4. Wait for Send's available balance to show 2 BTC. On qt6, the old validation error remains and Review stays disabled. Editing the amount to 1.1 BTC clears it.

Recorded after a ten-second wait:

qt6:
  Core trusted balance: 2 BTC
  GUI available:        2.00000000 BTC
  Validation:           Amount exceeds available balance
  Review enabled:       false
  After editing to 1.1: error cleared; Review enabled

PR #990, same sequence:
  GUI available:        2.00000000 BTC
  Validation:           empty
  Review enabled:       true, without editing

Case 2: an existing draft remains invalid after coinbase maturity

Use a fresh regtest datadir for this case.

  1. Create a wallet and mine one block to it:

    cli -named createwallet wallet_name=send_maturity
    RECEIVE_ADDR=$(cli -rpcwallet=send_maturity getnewaddress)
    OUTSIDE_ADDR=bcrt1qdavt4j2sd7dlhqsavtnfxvzppw6k7qy97tmnu9
    cli generatetoaddress 1 "$RECEIVE_ADDR"
    
  2. Select send_maturity, open Send, and let the initial transaction notification settle. Enter the outside address and 1 BTC. The coinbase is still immature, so the amount is correctly rejected.

  3. Leave the draft untouched and mine the next 100 blocks outside this wallet:

    cli generatetoaddress 100 "$OUTSIDE_ADDR"
    cli -rpcwallet=send_maturity getbalances
    
  4. Core now reports 50 BTC trusted and zero immature. On qt6, after a ten-second wait, Send still shows zero available, retains the amount error and disables Review. Editing to 1.1 BTC makes validation pass, although the available-balance label is stale.

On #990, the stale balance also rejects a newly entered 1 BTC amount after maturity. I checked that separately by leaving the amount empty until step 3 had completed. As a control, changing the receiving address's label triggers a refresh; the GUI then shows 50 BTC and enables Review without changing the amount:

cli -rpcwallet=send_maturity setlabel "$RECEIVE_ADDR" refresh-control

Expected result and remaining work

When funds become spendable, the available balance and existing recipient validation should update together, without editing the draft or triggering an unrelated wallet notification.

The invalid existing draft already occurs on qt6. #990 adds revalidation when balanceChanged is emitted, which fixes case 1. The remaining problem is refreshing after maturity when the intervening blocks create no new transactions for this wallet. Using the stale cached balance also makes case 2 reject freshly entered amounts on #990.

Related to #968 and #633. Regression coverage should keep an invalid draft untouched while an incoming payment confirms and while a coinbase matures, checking the balance, error and Review state together. It should also cover a newly entered amount after maturity and a reorg that reverses maturity.

An amount entered before the wallet has enough funds can stay invalid after the balance changes. I reproduced this on `qt6` with both an ordinary incoming payment and coinbase maturity. For the ordinary payment, Send shows 2 BTC available but still rejects the existing 1 BTC draft with "Amount exceeds available balance". Review stays disabled until the amount is edited. #990 fixes the ordinary incoming-payment case in the build I tested. The maturity refresh gap remains, and on #990 it also rejects an amount first entered after maturity. These need to be distinguished when checking the fix. ### Environment - macOS 26.6.2, Qt 6.9.0, Release builds. - Runtime comparisons: `qt6` at `a91f4b4774f25de061fe1a7c132a91ddde117fca` and #990 at `7e432cefdc77a0c473477a34b8b3138d7a0522c2`. - Rechecked current heads: `qt6` at `09c6de77d7f36bf7fa07c354ebeea51105c447a3`, #990 at `2f8b6d43f1ced340ed424ef397739b888e63098d`. Their relevant wallet/recipient model code is unchanged from the tested builds. - Real disposable regtest wallets, with QML test automation used to navigate the GUI and observe validation. Funding and maturity were checked independently through Core RPC. For the steps below, start the GUI with a fresh regtest datadir, RPC enabled and a fallback fee, for example `-regtest -server -fallbackfee=0.0001`. `cli` means `bitcoin-cli -regtest -datadir=/absolute/path/to/test-datadir`, plus any RPC options for that node. ### Case 1: an incoming payment funds an existing draft 1. Create an empty recipient wallet and a separate funded wallet: ```sh cli -named createwallet wallet_name=send_draft cli -named createwallet wallet_name=send_funder FUNDER_ADDR=$(cli -rpcwallet=send_funder getnewaddress) cli generatetoaddress 101 "$FUNDER_ADDR" RECEIVE_ADDR=$(cli -rpcwallet=send_draft getnewaddress) ``` 2. Select `send_draft` in the GUI and open **Send**. Enter destination `bcrt1qdavt4j2sd7dlhqsavtnfxvzppw6k7qy97tmnu9` and amount **1 BTC**. Confirm that the insufficient-balance error is shown. 3. Keep the draft open and leave its address and amount untouched. Fund it and confirm the payment: ```sh cli -rpcwallet=send_funder sendtoaddress "$RECEIVE_ADDR" 2 cli generatetoaddress 1 "$FUNDER_ADDR" cli -rpcwallet=send_draft getbalances ``` 4. Wait for Send's available balance to show 2 BTC. On `qt6`, the old validation error remains and Review stays disabled. Editing the amount to 1.1 BTC clears it. Recorded after a ten-second wait: ```text qt6: Core trusted balance: 2 BTC GUI available: 2.00000000 BTC Validation: Amount exceeds available balance Review enabled: false After editing to 1.1: error cleared; Review enabled PR #990, same sequence: GUI available: 2.00000000 BTC Validation: empty Review enabled: true, without editing ``` ### Case 2: an existing draft remains invalid after coinbase maturity Use a fresh regtest datadir for this case. 1. Create a wallet and mine one block to it: ```sh cli -named createwallet wallet_name=send_maturity RECEIVE_ADDR=$(cli -rpcwallet=send_maturity getnewaddress) OUTSIDE_ADDR=bcrt1qdavt4j2sd7dlhqsavtnfxvzppw6k7qy97tmnu9 cli generatetoaddress 1 "$RECEIVE_ADDR" ``` 2. Select `send_maturity`, open **Send**, and let the initial transaction notification settle. Enter the outside address and **1 BTC**. The coinbase is still immature, so the amount is correctly rejected. 3. Leave the draft untouched and mine the next 100 blocks outside this wallet: ```sh cli generatetoaddress 100 "$OUTSIDE_ADDR" cli -rpcwallet=send_maturity getbalances ``` 4. Core now reports 50 BTC trusted and zero immature. On `qt6`, after a ten-second wait, Send still shows zero available, retains the amount error and disables Review. Editing to 1.1 BTC makes validation pass, although the available-balance label is stale. On #990, the stale balance also rejects a **newly entered** 1 BTC amount after maturity. I checked that separately by leaving the amount empty until step 3 had completed. As a control, changing the receiving address's label triggers a refresh; the GUI then shows 50 BTC and enables Review without changing the amount: ```sh cli -rpcwallet=send_maturity setlabel "$RECEIVE_ADDR" refresh-control ``` ### Expected result and remaining work When funds become spendable, the available balance and existing recipient validation should update together, without editing the draft or triggering an unrelated wallet notification. The invalid existing draft already occurs on `qt6`. #990 adds revalidation when `balanceChanged` is emitted, which fixes case 1. The remaining problem is refreshing after maturity when the intervening blocks create no new transactions for this wallet. Using the stale cached balance also makes case 2 reject freshly entered amounts on #990. Related to #968 and #633. Regression coverage should keep an invalid draft untouched while an incoming payment confirms and while a coinbase matures, checking the balance, error and Review state together. It should also cover a newly entered amount after maturity and a reorg that reverses maturity.
Sign in to join this conversation.
No description provided.