← Back to Pull requests

walletrpc: make no-expiry leases explicit #11396

Closed
unknown closed this pull request without merging on Nov 10, 2026 17:14 UTC
View on GitHub
unknown unknown commented on Oct 22, 2026 00:42 UTC
Author

Summary

Make the RPC lease lifetime introduced by #11125 explicit. That PR's confirmation-count parameters obscure that unused outputs are reserved indefinitely. Replace the count-based RPC lifetime controls and readback with explicit booleans, using the existing wallet lease mechanism.

Issue

The confirmation target does not set an expiration deadline. Any nonzero value disables wall-clock expiry while a UTXO remains unused. Choosing three confirmations instead of another nonzero count makes no difference to that reservation: the output stays locked indefinitely.

The count controls lease-record cleanup after a spending transaction confirms. While the spending transaction remains tracked, ordinary wallet spend tracking already excludes that input from coin selection before confirmation. A retained depth-N lease can keep the input reserved if a previously confirmed spender is reorged out and then removed from the wallet, including removal without a confirmed conflict. This PR deliberately chooses cleanup at the first confirmed spend; a reorg does not restore that removed reservation.

Reorg handling also does not turn the confirmation target into a deadline for an unused input:

  • If the spending transaction returns to the mempool and remains tracked by the wallet, its input is still unavailable for coin selection.

  • If the transaction is removed or replaced, leaving U unspent and clearing its wallet spent marker, U's active lease still excludes it. With no retained spending transaction to reach the target, the reservation has no automatic expiration. If a replacement itself spends U, normal spend tracking continues to exclude U instead.
  • The parameter therefore obscures an indefinite reservation behind a confirmation target that does not define when an unused input becomes available. Its name is confusing and easy to misuse as a reservation that automatically expires after several blocks.

    The resulting indefinite reservation can strand an otherwise spendable input after transaction failure:

    1. U is leased with ReleaseAfterSpendConfs = 3.
    2. Transaction A spends U, later fails, and is removed from the wallet.
    3. Removing A clears U's spent marker, making U otherwise unspent.
    4. U's lease remains active, so ordinary coin selection still excludes it.
    5. Automatic cleanup requires a spending transaction to reach three confirmations. With A gone, additional blocks cannot advance that condition.

    Waiting for more blocks alone never unlocks U; the owner must explicitly release its lease to make the unspent input available for a new payment. The new flags make this responsibility explicit. A no-expiry lease still requires owner release if its spending transaction never confirms.

    Change Description

  • Replace LeaseOutput.release_after_spend_confs with no_expiry, and FundPsbt.input_release_after_spend_confs with input_lease_no_expiry. Remove the release_after_spend_confs response fields from LeaseOutputResponse and UtxoLease. Reserve all four retired protobuf field numbers and names. Callers must migrate and verify the returned boolean acknowledgement.

  • Reject requests carrying retired confirmation-count parameters before lease acquisition or PSBT funding, including requests from old protobuf clients.

  • Reuse the existing wallet lifetime: unused reservations survive restarts, the owner can release them, and the first confirmed spend removes the lease record.

  • Reject a no-expiry flag combined with an explicit duration, require a caller-specific owner ID for no-expiry funding, and document the RPC migration in the release notes.
  • Internally, no_expiry maps to the existing ReleaseAfterSpendConfs = 1 wallet option. Keeping that option is the minimal fix: it reuses wallet storage and cleanup without changing btcwallet. A confirmation count does not define an expiration deadline for an unused input and should not be presented as an expiry policy in btcwallet or other projects. This API expresses no expiry directly and explicitly ends the reservation at the first confirmed spend.

    Validation: focused WalletKit unit tests, the no-expiry RPC integration lifecycle, package and integration lint, protobuf lint/generation checks, and release-note validation passed.

    Diff: 539 lines (+404 / -135) across 6 files Reviewer: Roasbeef Review duration: 28352m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.48) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 539 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.376
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #11396"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 48.0% (MEDIUM) · Higher = larger blast radius
    48.0%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.7% · Safe to merge
    20.7%