lnwallet/rpcwallet: keep zero-value prev outputs in remote-sign PSBT #10815
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
TechLateef
In this PR, we fix a sharp edge in
RPCKeyRing.remoteSignthat silentlybroke any signing flow whose
to_signtx references a zero-value prevoutput. The canonical hitter is BIP-322 message signing, which mandates
that the virtual
to_spendoutput is exactlyvalue=0with the messagecommitment as
pk_script, and that output is referenced as input 0 ofevery
to_signtx handed toSignOutputRaw.Before forwarding the request,
remoteSignrebuilds a PSBT from theunsigned tx and annotates every non-signed input with a
WitnessUtxo,so the downstream
walletkit.SignPsbtcall can proceed (taproot sighashneeds 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 requireutxo.Value != 0, which silently dropped legitimate zero-value entrieson the floor. The remote signer would then reject the resulting PSBT
with
input (index=N) doesn't specify any UTXO info, raised inwalletkit.SignPsbtprecisely because input N had neither aWitnessUtxonor aNonWitnessUtxo.The fix
We drop the
Value != 0guard. The only condition that actually mattersis that the fetched entry is usable as a
WitnessUtxo: non-nil with anon-empty
PkScript. A zero-valueWitnessUtxowith a well-formedPkScriptserializes cleanly into a PSBT, so there's nothing else tovalidate at this layer.
We also lift the population loop out of
remoteSigninto a package-level helper,
populateNonSignedInputWitnessUtxos, so the resolutionpolicy can be exercised in unit tests without standing up a full wallet
+ remote signer pair. The helper takes a
fetchOutpointInfoFncallbackthat mirrors
lnwallet.WalletController.FetchOutpointInfo. No behaviorchange for the wallet-owns-it path or the no-fallback path.
Tests
New unit tests in
lnwallet/rpcwallet/rpcwallet_test.gowalk througheach resolution branch. The wallet-owns-it case exercises the
FetchOutpointInfohappy path and cross-checks that the signed inputitself is left untouched. The external-fallback case has the wallet
return
ErrNotMineand 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 assertsthat
WitnessUtxolands 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(rejectedas unusable, since a PSBT
WitnessUtxowith empty script is malformedat 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
PrevOutputFetcherland in the PSBT instead of being silently skipped.