← Back to Pull requests

lnwallet/rpcwallet: keep zero-value prev outputs in remote-sign PSBT #10815

Closed
unknown closed this pull request without merging on May 20, 2026 01:13 UTC
View on GitHub
unknown unknown commented on May 19, 2026 02:07 UTC
Author

In this PR, we fix a sharp edge in RPCKeyRing.remoteSign that silently
broke any signing flow whose to_sign tx references a zero-value prev
output. The canonical hitter is BIP-322 message signing, which mandates
that the virtual to_spend output is exactly value=0 with the message
commitment as pk_script, and that output is referenced as input 0 of
every to_sign tx handed to SignOutputRaw.

Before forwarding the request, remoteSign rebuilds a PSBT from the
unsigned tx and annotates every non-signed input with a WitnessUtxo,
so the downstream walletkit.SignPsbt call can proceed (taproot sighash
needs every prev output, not just the one being signed). When the watch-
only wallet doesn't know an outpoint, the prep stage falls back to the
sign descriptor's PrevOutputFetcher. That fallback used to require
utxo.Value != 0, which silently dropped legitimate zero-value entries
on the floor. The remote signer would then reject the resulting PSBT
with input (index=N) doesn't specify any UTXO info, raised in
walletkit.SignPsbt precisely because input N had neither a
WitnessUtxo nor a NonWitnessUtxo.

The fix

We drop the Value != 0 guard. The only condition that actually matters
is that the fetched entry is usable as a WitnessUtxo: non-nil with a
non-empty PkScript. A zero-value WitnessUtxo with a well-formed
PkScript serializes cleanly into a PSBT, so there's nothing else to
validate at this layer.

We also lift the population loop out of remoteSign into a package-
level helper, populateNonSignedInputWitnessUtxos, so the resolution
policy can be exercised in unit tests without standing up a full wallet
+ remote signer pair. The helper takes a fetchOutpointInfoFn callback
that mirrors lnwallet.WalletController.FetchOutpointInfo. No behavior
change for the wallet-owns-it path or the no-fallback path.

Tests

New unit tests in lnwallet/rpcwallet/rpcwallet_test.go walk through
each resolution branch. The wallet-owns-it case exercises the
FetchOutpointInfo happy path and cross-checks that the signed input
itself is left untouched. The external-fallback case has the wallet
return ErrNotMine and resolves the prev via the fetcher. The zero-
value-fallback case is the BIP-322 regression: same shape as external-
fallback, but the fetcher entry has Value=0, and the test asserts
that WitnessUtxo lands on the PSBT instead of being silently skipped.
Two more cover the unhappy paths: no fetcher attached (input left bare,
warning logged) and a fetcher entry with an empty PkScript (rejected
as unusable, since a PSBT WitnessUtxo with empty script is malformed
at serialization).

Compat

No behavior change for the wallet-owns-it path, the no-fallback path,
or the non-zero-value fallback path. The only new behavior is that
legitimately zero-value entries from the supplied PrevOutputFetcher
land in the PSBT instead of being silently skipped.

Diff: 367 lines (+275 / -92) across 4 files Reviewer: TechLateef Review duration: 1386m
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.43) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 367 lines diff across 4 files
0.43
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.353
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #10815"
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: 42.7% (MEDIUM) · Higher = larger blast radius
42.7%
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: 18.5% · Safe to merge
18.5%