Skip to content

Conversation

@0xEgao
Copy link
Collaborator

@0xEgao 0xEgao commented Jan 24, 2026

Fixes #721, by enforcing the MakerConfig to not be initialized if theminimum_swap_amount is lesser than 10k sats, and by continuously checking the swap-liquidity at certain interval of time.
Note-: The v1-maker server already checks for swap_liquidity at certain interval of time.

@codecov
Copy link

codecov bot commented Jan 24, 2026

Codecov Report

❌ Patch coverage is 61.11111% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.79%. Comparing base (776b75d) to head (7884deb).
⚠️ Report is 92 commits behind head on master.

Files with missing lines Patch % Lines
src/maker/server2.rs 60.00% 8 Missing ⚠️
src/maker/server.rs 50.00% 4 Missing ⚠️
src/maker/config.rs 75.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master     #733       +/-   ##
===========================================
+ Coverage   68.87%   80.79%   +11.92%     
===========================================
  Files          35       49       +14     
  Lines        4932    14431     +9499     
===========================================
+ Hits         3397    11660     +8263     
- Misses       1535     2771     +1236     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mojoX911
Copy link

Request to rebase on master.

@0xEgao
Copy link
Collaborator Author

0xEgao commented Jan 27, 2026

Request to rebase on master.

Done

@github-actions
Copy link

Code Review - Issue Found

Unconditional address generation causing address index exhaustion

The check_swap_liquidity_taproot function unconditionally generates a new external address at lines 404-407 before checking if liquidity is insufficient. Since this function is called every 5 minutes by the monitoring thread, it generates ~105,000 addresses per year even when liquidity is already sufficient.

Problem:

/// Blocks until sufficient liquidity is available for taproot swaps.
fn check_swap_liquidity_taproot(maker: &Maker) -> Result<(), MakerError> {
let sleep_incremental = 10;
let mut sleep_duration = 0;
let funding_addr = maker
.wallet()
.write()?
.get_next_external_address(AddressType::P2TR)?;
while !maker.shutdown.load(Relaxed) {

The address generation should be moved inside the if offer_max_size < min_required block to only generate addresses when actually needed.

Related code showing permanent index increment:

coinswap/src/wallet/api.rs

Lines 1253 to 1257 in b4b55c6

.clone();
self.store.external_index += 1;
self.save_to_disk()?;
Ok(receive_address.assume_checked())
}

@github-actions
Copy link

Code review

Issue: Unnecessary address generation wastes address space

Location: src/maker/server2.rs:408-411

The get_next_external_address() call at the start of check_swap_liquidity_taproot generates a new address and increments the wallet's external index on every invocation, even when liquidity is sufficient and the address is never used.

Since this function is called every 5 minutes from the monitoring loop (

// Start contract broadcast watcher thread
let maker_clone_watcher = maker.clone();
let contract_watcher_handle = thread::Builder::new()
.name("contract-watcher-taproot".to_string())
), this wastes approximately 288 addresses per day in normal operation when liquidity is adequate.

The funding_addr variable is only used inside the if offer_max_size < min_required block at line 423, so the address generation should be moved there.

Suggested fix:

Move the get_next_external_address() call inside the if offer_max_size < min_required block at

if offer_max_size < min_required {
log::warn!(
"[{}] Low taproot swap liquidity | Min: {} sats | Available: {} sats | Fund: {}",
maker.config.network_port,
min_required,
offer_max_size,
funding_addr,
so addresses are only generated when they will actually be displayed to the user.


No other issues found. Checked for bugs and CLAUDE.md compliance.

@0xEgao 0xEgao force-pushed the swap-liquidity branch 2 times, most recently from 5726a8a to 31e1252 Compare January 27, 2026 13:10
@0xEgao
Copy link
Collaborator Author

0xEgao commented Jan 27, 2026

Code review

Issue: Unnecessary address generation wastes address space

Location: src/maker/server2.rs:408-411

The get_next_external_address() call at the start of check_swap_liquidity_taproot generates a new address and increments the wallet's external index on every invocation, even when liquidity is sufficient and the address is never used.

Since this function is called every 5 minutes from the monitoring loop (

// Start contract broadcast watcher thread
let maker_clone_watcher = maker.clone();
let contract_watcher_handle = thread::Builder::new()
.name("contract-watcher-taproot".to_string())

), this wastes approximately 288 addresses per day in normal operation when liquidity is adequate.
The funding_addr variable is only used inside the if offer_max_size < min_required block at line 423, so the address generation should be moved there.

Suggested fix:

Move the get_next_external_address() call inside the if offer_max_size < min_required block at

if offer_max_size < min_required {
log::warn!(
"[{}] Low taproot swap liquidity | Min: {} sats | Available: {} sats | Fund: {}",
maker.config.network_port,
min_required,
offer_max_size,
funding_addr,

so addresses are only generated when they will actually be displayed to the user.
No other issues found. Checked for bugs and CLAUDE.md compliance.

Done

@0xEgao 0xEgao requested a review from mojoX911 January 28, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ensure swap liquidity is never less than miniumum swap size.

2 participants