From 9fdc1b3ce67a6a47a3e4cd7290b6f134d44a755b Mon Sep 17 00:00:00 2001 From: keraliss Date: Fri, 8 May 2026 22:23:26 +0530 Subject: [PATCH 1/2] manual maker selection --- api1.js | 4 +- coinswap-worker.js | 3 +- src/components/market/Market.js | 27 +-- src/components/settings/FirstTimeSetup.js | 14 +- src/components/swap/Swap.js | 203 ++++++++++++++++++++-- src/styles/output.css | 6 +- 6 files changed, 210 insertions(+), 47 deletions(-) diff --git a/api1.js b/api1.js index e9b69a3..0b056cb 100644 --- a/api1.js +++ b/api1.js @@ -1453,7 +1453,7 @@ function registerCoinswapHandlers() { // Start coinswap ipcMain.handle( 'coinswap:start', - async (event, { amount, makerCount, outpoints, password }) => { + async (event, { amount, makerCount, outpoints, password, selectedMakerAddresses }) => { try { if (!api1State.takerInstance) { return { success: false, error: 'Taker not initialized' }; @@ -1571,7 +1571,7 @@ function registerCoinswapHandlers() { }); const worker = new Worker(path.join(__dirname, 'coinswap-worker.js'), { - workerData: { amount, makerCount, outpoints, config }, + workerData: { amount, makerCount, outpoints, selectedMakerAddresses, config }, }); api1State.activeSwaps.set(swapId, { diff --git a/coinswap-worker.js b/coinswap-worker.js index 6c59af9..64aefa2 100644 --- a/coinswap-worker.js +++ b/coinswap-worker.js @@ -10,7 +10,7 @@ const { parentPort, workerData } = require('worker_threads'); try { const coinswapNapi = require('coinswap-napi'); - const { amount, makerCount, outpoints, config } = workerData; + const { amount, makerCount, outpoints, selectedMakerAddresses, config } = workerData; const protocol = config.protocol || 'v1'; const normalizedProtocol = protocol === 'v2' ? 'Taproot' : 'Legacy'; const protocolName = @@ -58,6 +58,7 @@ const { parentPort, workerData } = require('worker_threads'); sendAmount: amount, makerCount: makerCount, manuallySelectedOutpoints: outpoints || undefined, + preferredMakers: selectedMakerAddresses && selectedMakerAddresses.length > 0 ? selectedMakerAddresses : undefined, }; console.log(`🔄 Syncing offerbook in swap worker before prepare...`); diff --git a/src/components/market/Market.js b/src/components/market/Market.js index 30e93ec..6933eb1 100644 --- a/src/components/market/Market.js +++ b/src/components/market/Market.js @@ -38,20 +38,14 @@ export function Market(container) { } } - function formatTorEndpoint(address, start = 6, end = 0) { + function formatTorEndpoint(address, start = 8, end = 6) { if (!address || typeof address !== 'string') return 'unknown'; const separatorIndex = address.lastIndexOf(':'); - if (separatorIndex === -1) return address; + const host = (separatorIndex !== -1 ? address.slice(0, separatorIndex) : address).replace(/\.onion$/i, ''); - const host = address.slice(0, separatorIndex).replace(/\.onion$/i, ''); - const port = address.slice(separatorIndex + 1); - - if (host.length <= start + end + 3) { - return `${host}:${port}`; - } - - return end > 0 ? `${host.slice(0, start)}..${host.slice(-end)}:${port}` : `${host.slice(0, start)}..:${port}`; + if (host.length <= start + end + 3) return host; + return `${host.slice(0, start)}...${host.slice(-end)}`; } // Check sync state every second @@ -91,14 +85,7 @@ export function Market(container) { const offer = item.offer; const addr = item.address; let fullAddress; - if (typeof addr === 'string') { - fullAddress = addr.includes(':') ? addr : `${addr}:6102`; - } else { - const addressObj = addr || {}; - const onionAddr = addressObj.onion_addr || ''; - const port = addressObj.port || '6102'; - fullAddress = `${onionAddr}:${port}`; - } + fullAddress = typeof addr === 'string' ? addr : `${addr?.onion_addr || ''}:${addr?.port || ''}`; // Handle null offers (unresponsive makers) if (!offer) { @@ -770,7 +757,7 @@ export function Market(container) { .map( (maker) => { return ` -
+
${formatTorEndpoint(maker.address)}
${maker.baseFee}
@@ -871,7 +858,7 @@ export function Market(container) { -
+
Tor Address
Base Fee
% Fee Rate
diff --git a/src/components/settings/FirstTimeSetup.js b/src/components/settings/FirstTimeSetup.js index 3b36276..85f93f2 100644 --- a/src/components/settings/FirstTimeSetup.js +++ b/src/components/settings/FirstTimeSetup.js @@ -140,7 +140,7 @@ export function FirstTimeSetupModal(container, onComplete) { -
+