Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions api1.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,60 @@ function registerTakerHandlers() {
}
});

ipcMain.handle('taker:checkSwapLiquidity', async () => {
try {
if (!api1State.takerInstance) {
return { success: false, error: 'Taker not initialized' };
}

const balance = api1State.takerInstance.getBalances();
const regular = Number(balance?.regular || 0);
const swap = Number(balance?.swap || 0);
const spendable = Number(balance?.spendable || 0);

let maxSwappable = Math.max(regular, swap) - 3000;

if (
typeof api1State.takerInstance.checkSwapLiquidity === 'function'
) {
try {
const nativeResult = api1State.takerInstance.checkSwapLiquidity();
if (typeof nativeResult === 'number') {
maxSwappable = nativeResult;
} else if (
nativeResult &&
typeof nativeResult.maxSwappable === 'number'
) {
maxSwappable = nativeResult.maxSwappable;
} else if (
nativeResult &&
typeof nativeResult.max_swappable === 'number'
) {
maxSwappable = nativeResult.max_swappable;
}
} catch (nativeError) {
console.warn(
'⚠️ checkSwapLiquidity native call failed, using balance fallback:',
nativeError.message
);
}
}

return {
success: true,
liquidity: {
spendable,
regular,
swap,
maxSwappable: Math.max(0, Math.floor(maxSwappable)),
},
};
} catch (error) {
console.error('❌ Failed to check swap liquidity:', error);
return { success: false, error: error.message };
}
});

// Start periodic wallet sync (every 5 minutes)
function startPeriodicWalletSync() {
if (api1State.walletSyncInterval) {
Expand Down Expand Up @@ -1344,6 +1398,64 @@ function registerDialogHandlers() {
function registerTorHandlers() {
const net = require('net');

ipcMain.handle('network:testTcpPort', async (event, config) => {
const host = config?.host || '127.0.0.1';
const port = config?.port;
const timeout = config?.timeout || 3000;

return new Promise((resolve) => {
if (!port) {
resolve({
success: false,
host,
port,
error: 'Port is required',
});
return;
}

const socket = new net.Socket();
let settled = false;

const finish = (result) => {
if (settled) return;
settled = true;
socket.destroy();
resolve(result);
};

socket.setTimeout(timeout);

socket.on('connect', () => {
finish({
success: true,
host,
port,
});
});

socket.on('error', () => {
finish({
success: false,
host,
port,
error: `Cannot connect to ${host}:${port}`,
});
});

socket.on('timeout', () => {
finish({
success: false,
host,
port,
error: `Connection timeout to ${host}:${port}`,
});
});

socket.connect(port, host);
});
});
Comment thread
keraliss marked this conversation as resolved.

ipcMain.handle('tor:testConnection', async (event, config) => {
const socksPort = config?.socksPort || 9050;
const controlPort = config?.controlPort || 9051;
Expand Down
229 changes: 229 additions & 0 deletions execution.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ contextBridge.exposeInMainWorld('api', {
getSyncStatus: (syncId) =>
ipcRenderer.invoke('taker:getSyncStatus', syncId),
getOffers: () => ipcRenderer.invoke('taker:getOffers'),
checkSwapLiquidity: () => ipcRenderer.invoke('taker:checkSwapLiquidity'),
getGoodMakers: () => ipcRenderer.invoke('taker:getGoodMakers'),
getTransactions: (count, skip) =>
ipcRenderer.invoke('taker:getTransactions', { count, skip }),
Expand Down Expand Up @@ -72,4 +73,5 @@ contextBridge.exposeInMainWorld('api', {
saveFile: (options) => ipcRenderer.invoke('dialog:saveFile', options),
restoreWallet: (data) => ipcRenderer.invoke('taker:restore', data),
backupWallet: (data) => ipcRenderer.invoke('taker:backup', data),
testTcpPort: (config) => ipcRenderer.invoke('network:testTcpPort', config),
Comment thread
keraliss marked this conversation as resolved.
});
15 changes: 9 additions & 6 deletions setup-coinswap.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ function runCommand(cmd, options = {}) {
}

// STEP 1 — Clone coinswap-ffi if missing
const BRANCH = 'offerbook-fix';
const REPO_URL = 'https://github.com/citadel-tech/coinswap-ffi.git';

if (!fs.existsSync(FFI_DIR)) {
console.log('➡️ Cloning coinswap-ffi...');
runCommand('git clone https://github.com/citadel-tech/coinswap-ffi.git');
console.log('✓ Cloned coinswap-ffi\n');
console.log(`➡️ Cloning coinswap-ffi (branch ${BRANCH})...`);
runCommand(`git clone -b ${BRANCH} ${REPO_URL}`);
Comment thread
keraliss marked this conversation as resolved.
} else {
console.log('➡️ Updating coinswap-ffi...');
console.log(`➡️ Updating coinswap-ffi to branch ${BRANCH}...`);
// Fetch all branches and checkout the desired one
runCommand('git fetch --all', { cwd: FFI_DIR });
runCommand(`git checkout ${BRANCH}`, { cwd: FFI_DIR });
runCommand('git pull', { cwd: FFI_DIR });
Comment thread
keraliss marked this conversation as resolved.
console.log('✓ coinswap-ffi updated\n');
}

// STEP 2 — Install deps & build coinswap-js
console.log('➡️ Installing dependencies for coinswap-js...');
runCommand('npm install', { cwd: NAPI_SOURCE });
Expand Down
5 changes: 0 additions & 5 deletions src/components/log/Log.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,6 @@ export function LogComponent(container) {
</div>
</div>

<div class="bg-blue-500/10 border border-blue-500/30 rounded-lg p-4">
<p class="text-xs text-blue-400">
<strong>💡 Tip:</strong> The logs shown here are real-time. For detailed debugging or historical logs, open the complete log file.
</p>
</div>
</div>
</div>
`;
Expand Down
Loading