Repository navigation
wallet rpc: utxo state filtering and per-utxo state in account_utxos - #2128
Conversation
Add optional utxo_states and with_locked parameters to the account_utxos RPC (defaulting to all states / unlocked, i.e. the previous behavior), and include the state of the creating transaction (Confirmed / InMempool / Inactive / Conflicted / Abandoned) in every returned UtxoInfo. With this, callers can obtain a trustworthy spendable view (account_utxos with utxo_states=[Confirmed]) whose coin sum equals account_balance called with the same filter, instead of having to diff the full listing against the balance to spot outputs of dropped transactions. - output_cache: utxos_with_states (the existing utxos now delegates to it), attaching the creating transaction's state to each result; - account/wallet/runtime_wallet/read: get_utxos_with_states and get_multisig_utxos_with_states threading the state through; - wallet-rpc-lib: account_utxos gains the optional parameters; UtxoInfo carries the state; standalone_multisig_utxos responses carry it too; - wallet-rpc-daemon docs regenerated. No behavior change for existing callers that omit the new parameters.
|
🔍 OpenCodeReview found 2 issue(s) in this PR.
📄
|
The account_utxos path was changed to fall back to UtxoStates::ALL for an omitted/empty filter (matching the RPC's server-side default and docs), but get_balance and get_multisig_utxos still fell back to Confirmed-only - an inconsistency with the daemon RPCs they mirror. Unify all three and document the pre-existing Confirmed fallback in the comment, so the default change is explicit.
The security review caught the previous commit over-generalizing: the standalone_multisig_utxos RPC's server-side default for an omitted or empty utxo_states filter is Confirmed-only (unlike account_utxos, which defaults to all states), and the regenerated RPC.md makes no all-states claim for it. Restore the Confirmed fallback with a comment documenting the asymmetry, so remote multisig callers cannot suddenly observe unconfirmed UTXOs.
The PoS block reward is tracked as block data (RewardAdded event), not as a utxo, so account_utxos never lists a LockThenTransfer utxo and the balance-invariant test can only exercise Transfer outputs. Pin the boundary with an assertion so a future wallet change that starts listing them forces the invariant test to be extended.
OpenCodeReview cycle summary
On the cycle-3 finding: PoS block rewards are tracked by the wallet as block data (the |
Summary
Part 3 of the series: #2126 (mempool local-origin orphans) → #2127 (wallet chain-aware repush) → this PR.
Adds optional
utxo_statesandwith_lockedparameters to theaccount_utxosRPC (defaulting to all states / unlocked, i.e. the previous behavior), and includes the state of the creating transaction (Confirmed/InMempool/Inactive/Conflicted/Abandoned) in every returnedUtxoInfo.With this, callers can obtain a trustworthy spendable view —
account_utxoswithutxo_states=["Confirmed"]whose coin sum equalsaccount_balancecalled with the same values — instead of having to diff the full listing against the balance to spot outputs of dropped transactions. This pairs with #2127's reconcile pass, which now deterministically marks dropped transactionsAbandonedin the wallet state.Changes
utxos_with_states(the existingutxosnow delegates to it), attaching the creating transaction's state to each result;get_utxos_with_statesandget_multisig_utxos_with_statesthreading the state through;account_utxosgains the optionalutxo_types,utxo_states,with_lockedparameters;UtxoInfocarries the state;standalone_multisig_utxosresponses carry it too;RPC.mdregenerated;wallet-rpc-lib/tests/basic.rs.Compatibility note
The new
statefield is required on the wire: a client deserializing responses from a daemon that predates it needs to update first. Wallet client and daemon are versioned and released together, and existing callers that omit the new parameters see no behavior change.Tests
wallet-rpc-lib/tests/basic.rs): state filtering, per-UTXO state reporting, spendable-view/balance equivalence;wallet,wallet-controller,node-comm,wallet-rpc-libsuites green; fmt and clippy clean (--all-features --all-targets).