Repository navigation
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 8 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1199 +/- ##
==========================================
- Coverage 88.16% 88.13% -0.04%
==========================================
Files 270 270
Lines 72623 72420 -203
==========================================
- Hits 64031 63829 -202
+ Misses 8592 8591 -1
|
|
This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them. |
75a01e6 to
95bca69
Compare
|
This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them. |
95bca69 to
82938e6
Compare
|
This pull request is a draft, so Manki does not review it automatically. Marking it ready for review starts automatic reviews. Until then, someone with write access to this repository can tick a box below: Review this draft reviews the current commit once, Deeper review does so with more effort, and Review every push reviews it now and again after each push. |
A coin the network has not settled, in a block or with an InstantSend lock, may never exist, and neither would anything built on it. Every build now spends only final coins, and when the waiting ones would fund it, it fails with `BuilderError::FundsAwaitingFinality`. `require_final_inputs` is gone. The trusted self-send rule is removed with it: the change of our own mempool transaction waits in the unconfirmed bucket like any other mempool output, and `WalletCoreBalance::spendable` is the confirmed balance only. BREAKING CHANGE: `TransactionBuilder::require_final_inputs` and `Utxo::is_trusted` are removed, builds no longer spend unconfirmed coins, and `spendable()` excludes unconfirmed funds. Part of #1185
82938e6 to
0fd4770
Compare
|
✅ Review complete in 11m 6s Planner (8s) Review (security · full): 24 findings Judge (4m 53s) Posted: 5 findings Review metadataConfig:
Account limits:
Judge decisions:
Timing:
|
|
Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post |
There was a problem hiding this comment.
🔴 Changes requested: 1 blocker, plus 3 suggestions in threads.
What blocks: Account and wallet data saved with bincode before this change no longer decodes. Utxo loses its is_trusted byte, so every UTXO after the first is read from shifted bytes, and an application that stores wallets this way gets a load error or corrupted coins after upgrading.
1 suggestion · not blocking
✨ The finality trial skips failures that a different input selection could resolve
Suggestion, not blocking · Correctness · Moderate · key-wallet/src/wallet/managed_wallet_info/transaction_builder.rs:496
Why: A payment with no change address returns NoChangeAddress when the final coins require change, even when a waiting coin would fund an exact match. The same early return hides waiting funds when they would reduce an asset lock below the size cap or change which input supplies a valid change address.
How to fix it
Separate configuration errors from failures that depend on the selected inputs. Retry the latter with waiting candidates and return FundsAwaitingFinality only when that selection produces a valid transaction.
Checked in the code
Retries only InsufficientFunds, CoinSelection and TooManyInputs
Returns TransactionTooLarge using the selected input count
Checks the network of the first selected input when routing change
key-wallet/src/wallet/managed_wallet_info/transaction_builder.rs:748: ReturnsNoChangeAddressonly when the selected coins leave changekey-wallet/src/wallet/managed_wallet_info/coin_selection.rs:480: Gives a change-free branch-and-bound match priority over accumulation
- Create an issue for this
3 more suggestions are not listed.
Checked and left out: 1 finding
Not finished checking · 1 possible problem
- A loaded wallet may retain its legacy confirmed balance until the next refresh ·
key-wallet/src/wallet/balance.rs:54
The base update_balance put trusted mempool change into the cachedconfirmedbucket, and serde restores that cache as is. But nothing in this repo deserializes a ManagedWalletInfo snapshot, and the one consumer load path read (platform rehydrate) calls update_balance before use.
The progress comment has the full log under "Judge decisions", in its "Review metadata" fold.
About this review
- Reviewed
689a563, round 1 - 555 changed lines read in 11m 6s
- Found by
claude-opus-5-5andgpt-6.2-sol, judged byclaude-opus-5-5 - Tokens: 9.1M in (7.8M from cache) · 117k out · about $9.06 at API prices
- Runner: self-hosted · started after 11s · peak memory 4.2 GiB of 30.0 GiB
- How Manki reviews
|
Bots are done — your move: address manki-review[bot] requested changes, then post |
|
This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them. |
…-broadcasts # Conflicts: # key-wallet/src/tests/restore_utxos_tests.rs # key-wallet/src/transaction_checking/wallet_checker.rs
|
Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post |
|
Review superseded by the new commit |
|
Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post |
|
Review superseded by the new commit |
|
Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post |
|
✅ Review complete in 10m 9s Planner (6s) Review (security · full): 19 findings Judge (5m 39s) Posted: 4 findings Review metadataConfig:
Account limits:
Judge decisions:
Timing:
Last reviewed
|
There was a problem hiding this comment.
Create an issue for this to track it for later. Manki approves once every warning is handled.
Caution
Claude subscription has used 98% of its weekly limit, past the 90% mark. It resets 2026-12-04 01:00 UTC.
Once a limit is used up, reviews on that account stop until it resets.
1 suggestion · not blocking
✨ restore_utxos still promises to preserve the removed trust flag
Suggestion, not blocking · Documentation · Quick fix · key-wallet/src/wallet/managed_wallet_info/mod.rs:465
Why: The public restore documentation says replacement coins keep their trust, but Utxo no longer carries that state.
rust-dashcore/key-wallet/src/wallet/managed_wallet_info/mod.rs
Lines 463 to 467 in 0ea0afe
How to fix it
Describe only the InstantSend and wallet coin-lock behavior that restore preserves.
Checked in the code
On the flagged line: Says a restored coin keeps the InstantSend lock and trust of any copy it replaces or takes out
Preserves is_instantlocked and line 349 preserves is_locked
rust-dashcore/key-wallet/src/managed_account/managed_core_funds_account.rs
Lines 347 to 352 in 0ea0afe
- Create an issue for this
Findings dismissed by the PR author @ZocoLini (maintain role):
About this review
- Reviewed
0ea0afe, round 2 - 566 changed lines read in 10m 9s
- Found by
claude-opus-5-5andgpt-6.2-sol, judged byclaude-opus-5-5 - Tokens: 9.3M in (7.6M from cache) · 128k out · about $10.49 at API prices
- Runner: self-hosted · started after 8s · peak memory 4.3 GiB of 30.0 GiB
- How Manki reviews
| // Only final coins fund a build: a coin the network has not settled | ||
| // may never exist, and with it anything built on it. | ||
| if !self.allow_waiting_inputs { | ||
| self.inputs.retain(|utxo| utxo.is_confirmed || utxo.is_instantlocked); |
There was a problem hiding this comment.
A seeded copy can hide a funding account's current finality
An earlier round already reviewed these lines and missed this. It is in this PR's own code, so it still holds the approval.
What goes wrong: A caller can seed a coin from a snapshot taken before its InstantSend lock, then attach the funding account after it learns the lock. If the snapshot is seeded first, the account skips its current copy and the builder reports FundsAwaitingFinality for an already-final coin. Conversely, a stale copy marked final is not checked against a waiting copy held by the funding account.
How to fix it and 17 places read · confirmed with tools
How to fix it
Resolve each outpoint to one candidate before selection, using the funding account's coin state whenever it holds that outpoint. Apply this to seeded inputs added on either side of the funding call and to reservation-only funding without offering unseeded coins.
Checked in the code
On the commented line: Trusts the candidate's is_confirmed || is_instantlocked flags
Computes present from already seeded inputs
Skips the funding account's copy when present.contains(&utxo.outpoint)
Appends later seeds with self.inputs.extend(inputs)
key-wallet/src/wallet/managed_wallet_info/transaction_builder.rs:596: Checks account reservations and locks by outpoint, but does not reconcile finalitykey-wallet/src/wallet/managed_wallet_info/transaction_builder.rs:482:if let Ok((_, inputs)) = trial.prepare() {key-wallet/src/wallet/managed_wallet_info/transaction_builder.rs:489:return Err(BuilderError::FundsAwaitingFinality {key-wallet/src/wallet/managed_wallet_info/transaction_builder.rs:570:if !self.allow_waiting_inputs {
In a related repository: dashpay/platform:packages/rs-platform-wallet-ffi/src/core_wallet/transaction_builder.rs:988, dashpay/platform:packages/rs-platform-wallet-ffi/src/core_wallet/transaction_builder.rs:991, dashpay/platform:packages/rs-platform-wallet-ffi/src/core_wallet/transaction_builder.rs:998, dashpay/platform:packages/rs-platform-wallet/src/wallet/core/transaction.rs:639, dashpay/platform:packages/rs-platform-wallet/src/wallet/core/transaction.rs:703, dashpay/platform:packages/rs-platform-wallet/src/wallet/core/transaction.rs:704, dashpay/platform:packages/rs-platform-wallet/src/wallet/core/transaction.rs:706, dashpay/platform:packages/rs-platform-wallet/src/wallet/core/transaction.rs:724, dashpay/platform:packages/rs-platform-wallet/src/wallet/core/transaction.rs:726
Double-checked
Manki tried to disprove this by reading the code and could not. fund_from never offers the funding account's current copy of an outpoint that was already seeded (lines 206 and 225). prepare then drops any input whose own fl…
Second check, on another model
Not settled. The builder keeps the pre-seeded copy and can misreport a final coin as awaiting finality. The tests combine seeding and funding for the same outpoint, but I d… See key-wallet/src/wallet/managed_wallet_info/transaction_builder.rs lines 225, 525, 531, 571, 596, 482, and 489.
- Create an issue for this
| /// Get the spendable balance, the confirmed one. | ||
| pub fn spendable(&self) -> u64 { | ||
| self.confirmed + self.unconfirmed | ||
| self.confirmed |
There was a problem hiding this comment.
A loaded wallet may retain its legacy confirmed balance until the next refresh
An earlier round already reviewed these lines and missed this. It is in this PR's own code, so it still holds the approval.
What goes wrong: The new spendable() getter trusts the cached confirmed bucket, which old snapshots could include trusted mempool change in.
How this was checked: 13 places read, confirmed with tools
Checked in the code
rust-dashcore/key-wallet/src/wallet/managed_wallet_info/mod.rs
Lines 41 to 45 in 0ea0afe
rust-dashcore/key-wallet/src/wallet/managed_wallet_info/mod.rs
Lines 61 to 65 in 0ea0afe
rust-dashcore/key-wallet/src/tests/locked_outpoints_tests.rs
Lines 954 to 961 in 0ea0afe
key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs:502:fn balance(&self) -> WalletCoreBalance {key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs:503:self.balancekey-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs:506:fn update_balance(&mut self) {key-wallet/src/managed_account/managed_core_funds_account.rs:1342:_ => "Failed to generate receive address",key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs:513:let last_processed_height = self.last_processed_height();key-wallet/src/tests/locked_outpoints_tests.rs:954:let json = serde_json::to_string(&info).expect("serialize");key-wallet/src/managed_account/managed_core_funds_account.rs:1245:} else if utxo.is_confirmed || utxo.is_instantlocked {key-wallet/src/wallet/managed_wallet_info/transaction_builder.rs:570:if !self.allow_waiting_inputs {
Double-checked
Manki tried to disprove this by reading the code and could not. The stale-cache path is real. ManagedWalletInfo derives Deserialize with balance not skipped, and balance() returns the field as it is. The base versio… See key-wallet/src/wallet/managed_wallet_info/mod.rs lines 117 and 157, and key-wallet/src/tests/locked_outpoints_tests.rs:981.
Second check, on another model
Double-checked. Direct deserialization restores the public wallet balance cache, and neither balance() nor spendable() refreshes it. The amount can remain wrong across repeate…
- Create an issue for this
| // downgrade it. | ||
| copies.extend(self.utxos.get(&outpoint).cloned()); | ||
| if !copies.is_empty() { | ||
| output.is_instantlocked |= copies.iter().any(|copy| copy.is_instantlocked); |
There was a problem hiding this comment.
✨ Suggestion, not blocking · Correctness · Moderate
Change from the wallet's own unconfirmed sends can no longer be spent, unlike Dash Core
Why: This change drops is_trusted and collect_final_parents, so only is_confirmed || is_instantlocked lets a coin fund a build or count as confirmed balance. A user who sends twice in a row before the first send is InstantSend-locked now gets FundsAwaitingFinality on the second send, and the change from the first send shows as unconfirmed. If a light client never sees the InstantSend lock, this lasts until the next block, about 2.5 minutes. Dash Core trusts a mempool transaction when every input spends one of its own trusted outputs, and with the default m_spend_zero_conf_change = true it selects that change and counts it as trusted balance.
How to fix it, 6 places read, and 4 other checks
How to fix it
Keep a trusted flag on Utxo. Set it from the wallet-wide parent check, as collect_final_parents did, matching CachedTxIsTrusted. Accept is_trusted next to is_confirmed || is_instantlocked in the builder's input filter and in update_balance.
Checked in the code
On the commented line: Only is_instantlocked is carried forward now. The is_trusted latch was removed, and a grep for is_trusted|collect_final_parents under key-wallet/src fi…
self.inputs.retain(|utxo| utxo.is_confirmed || utxo.is_instantlocked); drops own unconfirmed change from coin selection.
else if utxo.is_confirmed || utxo.is_instantlocked { confirmed += value; } else { unconfirmed += value; }
rust-dashcore/key-wallet/src/managed_account/managed_core_funds_account.rs
Lines 1244 to 1248 in 0ea0afe
- dashpay/dash:src/wallet/receive.cpp:264
if (!wallet.m_spend_zero_conf_change || !CachedTxIsFromMe(wallet, wtx, ISMINE_ALL)) return false;, then lines 270-284… - dashpay/dash:src/wallet/wallet.h:170
static const bool DEFAULT_SPEND_ZEROCONF_CHANGE = true; - dashpay/dash:src/wallet/spend.cpp:241
bool safeTx = CachedTxIsTrusted(wallet, wtx, trusted_parents);gates coin selection on trust, not on confirmation. - dashpay/dash:src/wallet/receive.cpp:309 trusted transactions go to
m_mine_trustedbalance.
In a related repository: dashpay/dash:src/wallet/receive.cpp:264, dashpay/dash:src/wallet/spend.cpp:241, dashpay/dash:src/wallet/wallet.h:170
- Create an issue for this
- Dismiss this finding
|
Bots are done — your move: post |
Part of #1185.
A coin the network has not settled, in a block or with an InstantSend lock, may never exist, and neither would a transaction built on it. Every build now spends only final coins. When the waiting coins would fund it, it fails with
BuilderError::FundsAwaitingFinality, added in #1192.The trusted self-send rule is removed with it. The change of our own mempool transaction stays in the unconfirmed bucket like any other mempool output.
Breaking changes
TransactionBuilder::require_final_inputsremoved: final inputs are always required.Utxo::is_trustedremoved. AUtxo, or an account holding one, encoded withbincodethrough serde by an earlier version no longer decodes.WalletCoreBalance::spendable()returns only the confirmed balance.Not covered yet (from #1185)
available/requiredand selected outpoints in the error.PR Hygiene ·
0ea0afe/self-revieweddash-spv(dash-spv/tests/dashd_sync/tests_transaction.rs) — QuantumExplorer or xdustinfacekey-wallet-manager(key-wallet-manager/src/lib.rs,key-wallet-manager/tests/out_of_order_spend_repro_test.rs) — QuantumExplorer or xdustinfacekey-wallet(key-wallet/src/managed_account/managed_account_collection.rs,key-wallet/src/managed_account/managed_account_ref.rs,key-wallet/src/managed_account/managed_core_funds_account.rsand 10 more) — QuantumExplorer or xdustinfaceWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.