Skip to content

Commit

Permalink
handle channel reserve error
Browse files Browse the repository at this point in the history
  • Loading branch information
futurepaul authored and AnthonyRonning committed Nov 27, 2023
1 parent d17dbb0 commit daf57b8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/i18n/en/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ export default {
"We do not have enough balance to pay the given amount.",
error_invoice_match:
"Amount requested, {{amount}} SATS, does not equal amount set.",
error_channel_reserves: "Not enough available funds.",
error_channel_reserves_explained:
"A portion of your channel balance is reserved for fees. Try sending a smaller amount or adding funds.",
error_clipboard: "Clipboard not supported",
error_keysend: "Keysend failed",
error_LNURL: "LNURL Pay failed",
Expand Down Expand Up @@ -310,7 +313,7 @@ export default {
inbound_outbound_tip:
"Outbound is the amount of money you can spend on lightning. Inbound is the amount you can receive without incurring a lightning service fee.",
reserve_tip:
"About 1% of your channel balance is reserved on lightning for fees.",
"About 1% of your channel balance is reserved on lightning for fees. Additional reserves are required for channels you opened via swap.",
no_channels:
"It looks like you don't have any channels yet. To get started, receive some sats over lightning, or swap some on-chain funds into a channel. Get your hands dirty!"
},
Expand Down
14 changes: 13 additions & 1 deletion src/routes/Send.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Clipboard } from "@capacitor/clipboard";
import { Capacitor } from "@capacitor/core";
import { Contact, MutinyInvoice, TagItem } from "@mutinywallet/mutiny-wasm";
import { useNavigate } from "@solidjs/router";
import { A, useNavigate } from "@solidjs/router";
import {
createEffect,
createMemo,
Expand Down Expand Up @@ -227,6 +227,18 @@ function Failure(props: { reason: string }) {
{i18n.t("send.payment_pending_description")}
</InfoBox>
</Match>
<Match
when={props.reason === "Channel reserve amount is too high."}
>
<MegaEx />
<h1 class="mb-2 mt-4 w-full text-center text-2xl font-semibold md:text-3xl">
{i18n.t("send.error_channel_reserves")}
</h1>
<InfoBox accent="white">
{i18n.t("send.error_channel_reserves_explained")}{" "}
<A href="/settings/channels">{i18n.t("common.why")}</A>
</InfoBox>
</Match>
<Match when={true}>
<MegaEx />
<h1 class="mb-2 mt-4 w-full text-center text-2xl font-semibold md:text-3xl">
Expand Down
5 changes: 1 addition & 4 deletions src/routes/settings/Channels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ export function LiquidityMonitor() {
let reserve = 0n;

for (const channel of channels) {
inbound =
inbound +
BigInt(channel.size) -
BigInt(channel.balance + channel.reserve);
inbound = inbound + BigInt(channel.inbound);
reserve = reserve + BigInt(channel.reserve);
outbound = outbound + BigInt(channel.balance);
}
Expand Down

0 comments on commit daf57b8

Please sign in to comment.