Skip to content

bug: key-wallet-manager never sets is_instantlocked on UTXOs, breaking CoinSelector for mempool txs #514

@lklimek

Description

@lklimek

Summary

key-wallet-manager never sets Utxo::is_instantlocked = true, causing CoinSelector to reject all mempool UTXOs as unspendable — even those with InstantSend locks.

Details

The UTXO spendability check (key-wallet/src/utxo.rs)

pub fn is_spendable(&self, current_height: u32) -> bool {
    if self.is_locked { return false; }
    if !self.is_coinbase {
        self.is_confirmed || self.is_instantlocked  // ← requires one of these
    } else {
        current_height >= self.height + 100
    }
}

What's set

Flag Older revisions (e.g. 0bc6592) Newer revisions (e.g. 2bd764f, PR #411)
is_confirmed ❌ Never set ✅ Set via context.confirmed() for block-included txs
is_instantlocked ❌ Never set Still never set

Searching the entire codebase for is_instantlocked = true returns zero matches.

Impact

  • Mempool UTXOs with IS-locks are never marked as is_instantlocked = true
  • CoinSelector filters them out → "No UTXOs available for selection"
  • Users see wallet balance but cannot spend until the tx is mined into a block
  • On older revisions (pre-feat: rewrite, fix and improve the sync architecture #411), all UTXOs are unspendable since is_confirmed wasn't set either

Expected behavior

When the wallet manager processes an InstantSend lock for a transaction, it should set is_instantlocked = true on the corresponding UTXOs, making them immediately spendable per the is_spendable() logic.

Workaround

In dash-evo-tool, we work around this by patching cloned UTXOs before passing them to CoinSelector:

// Workaround: infer spendability from block inclusion
if utxo.height > 0 {
    utxo.is_confirmed = true;   // mined in a block
} else {
    utxo.is_instantlocked = true; // assume IS-locked for mempool txs
}

This is imprecise — it assumes all mempool transactions are IS-locked — but is the only option until the upstream properly tracks IS-lock status.

Versions affected

  • key-wallet 0.42.0 at 0bc6592 — both flags broken
  • key-wallet 0.42.0 at 2bd764fis_confirmed fixed, is_instantlocked still broken

🤖 Co-authored by Claudius the Magnificent AI Agent

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions