Skip to content

filter_mode: "selectable" hides coins on both sides of offers, not just the offered side #762

Description

@Lowestofttim

Description

When querying coins via the get_coins RPC with filter_mode: "selectable", coins are hidden on both sides of an offer — the offered side (correct) and the receive side (incorrect). Only coins being offered should be excluded from selectable results, since receive-side coins aren't locked by the offer.

Expected Behavior

A buy offer (offering XCH, requesting CAT) should only lock/hide the XCH coin used in the offer. The CAT coins should remain visible as selectable, since they aren't part of the offer — they're what we expect to receive.

Similarly, a sell offer (offering CAT, requesting XCH) should only lock/hide the CAT coin. XCH coins should remain selectable.

Actual Behavior

filter_mode: "selectable" hides coins on both sides. This means:

  • Buy offers hide both the XCH coin (correct) and a CAT coin (incorrect)
  • Sell offers hide both the CAT coin (correct) and an XCH coin (incorrect)

Evidence

Test environment: 51 buy offers (offering XCH) + 56 sell offers (offering CAT) = 107 total offers active, all created using coin_ids for precise coin selection.

XCH coins

Metric Value
filter_mode: "owned" 127 coins
filter_mode: "selectable" 25 coins
Difference (owned - selectable) 102 coins hidden
Expected hidden (buy offers only) 51 coins
Extra coins hidden 51 (matches sell offer count exactly)

CAT coins

Metric Value
filter_mode: "owned" 143 coins
filter_mode: "selectable" 34 coins
Difference (owned - selectable) 109 coins hidden
Expected hidden (sell offers only) 56 coins
Extra coins hidden 53 (approximately matches buy offer count)

The extra hidden XCH coins (51) match the sell offer count exactly. The extra hidden CAT coins (53) closely match the buy offer count (51), with a small difference likely due to offers created/expired during the test window.

Impact

Any application relying on selectable to count available coins will undercount by roughly 2x when many offers are active. In our case, a market maker bot with 100+ simultaneous offers was incorrectly reporting nearly zero free coins and triggering unnecessary coin-splitting operations.

Workaround

We are currently using filter_mode: "owned" to get all coins, then cross-referencing against our own database of which coins are locked by which offers to determine true availability.

Environment

  • Running a custom build of Sage that includes the coin_ids parameter for make_offer from PR Allow manual coin selection in make offer #761 (Allow manual coin selection in make offer). This is the same PR we raised previously to enable specifying which coin to lock per offer.
  • ~107 simultaneous offers (51 buy, 56 sell), all created using coin_ids to select specific coins
  • Queried via RPC get_coins with mutual TLS
  • This bug exists in the core get_coins filtering logic and is independent of the coin_ids feature — it affects any wallet with active offers

Reproduction

  1. Create multiple buy offers (offering XCH, requesting CAT) using specific coin_ids
  2. Create multiple sell offers (offering CAT, requesting XCH) using specific coin_ids
  3. Query XCH coins with filter_mode: "selectable" and filter_mode: "owned"
  4. Compare the difference — it will be roughly 2x the number of offers involving that coin type, instead of 1x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions