Skip to content

swap_creation_open_fill fails on main: "not enough funds" reserving a fresh claimer address #141

Description

@rsantacroce

swap_creation_open_fill fails on main. Confirmed pre-existing — it fails identically with only the build fixes from #137 applied, so it is not caused by #138.

---- swap_creation_open_fill ----
ErrorObject { code: ServerError(-1), message: "not enough funds", data: None }

test result: FAILED. 10 passed; 1 failed; 1 ignored

Cause

integration_tests/swap_creation.rs reserves the swap for a freshly generated address:

let claimer_address = sidechain.rpc_client.get_new_address().await?;
let accept_txid = sidechain.rpc_client
    .accept_swap(swap_id, Some(claimer_address), Some(0))
    .await?;

But SwapAccept must spend an input owned by the address it reserves for — that is what proves control of it, and it is the rule that stops anyone parking every open swap for free. A brand-new address owns nothing, so coin selection has nothing to choose and returns NotEnoughFunds.

Came in with #135, and merged because CI was already red for the nightly clippy regression described in that PR.

Fix options

  1. Fund claimer_address before the accept — a transfer to it, mined, then reserve. Closest to what a real taker does.
  2. Reserve for an address the wallet already holds a UTXO at.

Option 1 exercises the real flow and is what I would suggest, but it is a judgement call about what the test is meant to prove, so I have not made it.

Note

Everything else passes: 10/11 integration tests and 55 unit tests, against a real bitcoind, electrs, and an enforcer built at the pinned rev a9ca43d.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Mrg9zkV9bEdAvVEjx1RKLx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions