Skip to content

Commit

Permalink
Broadcast to both explorer and backend
Browse files Browse the repository at this point in the history
  • Loading branch information
SwapMarket committed Jan 17, 2025
1 parent 052c973 commit af604b5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 66 deletions.
20 changes: 10 additions & 10 deletions src/i18n/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ const dict = {
no_wallet_connected: "No wallet connected",
no_lockup_transaction: "No lockup transaction found",
routing_fee_limit: "Routing fee limit",
broadcast_setting: "Prefer External Broadcast",
broadcast_setting: "External Broadcast",
broadcast_setting_tooltip:
"Use third-party block explorers for broadcasting claim and refund transactions. If fails, fall back to Boltz backend.",
"Use third-party block explorers for broadcasting claim and refund transactions in addition to Boltz backend.",
},
de: {
language: "Deutsch",
Expand Down Expand Up @@ -495,9 +495,9 @@ const dict = {
no_wallet_connected: "Kein Wallet verbunden",
no_lockup_transaction: "Keine Lockup-Transaktion gefunden",
routing_fee_limit: "Routing Gebühr Limit",
broadcast_setting: "Bevorzugte externe Sendung",
broadcast_setting: "Externe Sendung",
broadcast_setting_tooltip:
"Verwenden Sie Drittanbieter-Blockexplorer, um Anspruchs- und Rückerstattungstransaktionen zu senden. Falls dies fehlschlägt, wird auf das Boltz-Backend zurückgegriffen.",
"Verwenden Sie Drittanbieter-Blockexplorer, um Anspruchs- und Rückerstattungstransaktionen zusätzlich zum Boltz-Backend zu senden.",
},
es: {
language: "Español",
Expand Down Expand Up @@ -746,9 +746,9 @@ const dict = {
no_wallet_connected: "No hay monedero conectado",
no_lockup_transaction: "No se encontró ninguna transacción de lockup",
routing_fee_limit: "Límite de la tarifa de enrutamiento",
broadcast_setting: "Preferir transmisión externa",
broadcast_setting: "Transmisión externa",
broadcast_setting_tooltip:
"Utilice exploradores de bloques de terceros para transmitir transacciones de reclamo y reembolso. Si falla, se recurrirá al backend de Boltz.",
"Utilice exploradores de bloques de terceros para transmitir transacciones de reclamo y reembolso además del backend de Boltz",
},
zh: {
language: "中文",
Expand Down Expand Up @@ -970,9 +970,9 @@ const dict = {
no_wallet_connected: "未连接钱包",
no_lockup_transaction: "未找到锁仓交易",
routing_fee_limit: "最大路由费用",
broadcast_setting: "优先使用外部广播",
broadcast_setting: "外部广播",
broadcast_setting_tooltip:
"使用第三方区块浏览器广播认领和退款交易。如果失败,则退回使用Boltz后台。",
"除了Boltz后台外,还使用第三方区块浏览器广播认领和退款交易。",
},
ja: {
language: "日本語",
Expand Down Expand Up @@ -1220,9 +1220,9 @@ const dict = {
no_wallet_connected: "財布はつながっていない!",
no_lockup_transaction: "ロックアップトランザクションが見つかりません",
routing_fee_limit: "ルーティング料金の上限",
broadcast_setting: "外部ブロードキャストを優先",
broadcast_setting: "外部ブロードキャスト",
broadcast_setting_tooltip:
"請求および返金取引をブロードキャストする際にサードパーティのブロックエクスプローラーを使用します。失敗した場合は、Boltzバックエンドを使用します。",
"Boltzバックエンドに加えて、サードパーティのブロックエクスプローラーを使用して請求および返金取引をブロードキャストします。",
},
};

Expand Down
42 changes: 14 additions & 28 deletions src/utils/claim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,38 +329,24 @@ export const claim = async <T extends ReverseSwap | ChainSwap>(
);
}

log.debug(
"Broadcasting claim transaction via",
externalBroadcast ? "block explorer" : "Boltz backend",
);

let res: {
id: string;
};
log.debug("Broadcasting claim transaction");

if (externalBroadcast) {
try {
res = await broadcastToExplorer(
swap.assetSend,
claimTransaction.toHex(),
);
} catch (e) {
log.debug(
"Broadcast to explorer failed, falling back to backend",
e,
);
res = await broadcastTransaction(
swap.assetSend,
claimTransaction.toHex(),
);
}
} else {
res = await broadcastTransaction(
swap.assetSend,
const res = await broadcastToExplorer(
asset,
claimTransaction.toHex(),
);
}
log.debug("Claim transaction broadcast result", res);
log.debug("Claim transaction broadcast result via explorer", res);
if (res.id) {
swap.claimTx = res.id;
}
}

const res = await broadcastTransaction(
asset,
claimTransaction.toHex(),
);
log.debug("Claim transaction broadcast result via backend", res);
if (res.id) {
swap.claimTx = res.id;
}
Expand Down
42 changes: 14 additions & 28 deletions src/utils/refund.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,39 +166,25 @@ const broadcastRefund = async <T extends SubmarineSwap | ChainSwap>(
externalBroadcast: boolean,
): Promise<T> => {
try {
log.debug(
"Broadcasting refund transaction via",
externalBroadcast ? "block explorer" : "Boltz backend",
);

let res: {
id: string;
};

log.debug("Broadcasting refund transaction");
if (externalBroadcast) {
try {
res = await broadcastToExplorer(
swap.assetSend,
txConstructionResponse.transaction.toHex(),
);
} catch (e) {
log.debug(
"Broadcast to explorer failed, falling back to backend",
e,
);
res = await broadcastTransaction(
swap.assetSend,
txConstructionResponse.transaction.toHex(),
);
}
} else {
res = await broadcastTransaction(
const res = await broadcastToExplorer(
swap.assetSend,
txConstructionResponse.transaction.toHex(),
);
}

log.debug("Refund broadcast result", res);
log.debug("Refund broadcast result via explorer", res);
if (res.id) {
swap.refundTx = res.id;
}
}

const res = await broadcastTransaction(
swap.assetSend,
txConstructionResponse.transaction.toHex(),
);

log.debug("Refund broadcast result via backend", res);
if (res.id) {
swap.refundTx = res.id;
}
Expand Down

0 comments on commit af604b5

Please sign in to comment.