diff --git a/locales/en.json b/locales/en.json index 103b3b3ac..745fec29d 100644 --- a/locales/en.json +++ b/locales/en.json @@ -268,6 +268,7 @@ "alias": "Alias", "node": "Node", "channelId": "Channel ID", + "channelPoint": "Channel point", "status": "Status", "statusActive": "Active", "statusInactive": "Inactive", diff --git a/src/components/ChannelCard.tsx b/src/components/ChannelCard.tsx index 471afcc78..a64ce638b 100644 --- a/src/components/ChannelCard.tsx +++ b/src/components/ChannelCard.tsx @@ -1,21 +1,21 @@ -import React from "react"; -import { StyleSheet, Alert, Image, Linking } from "react-native"; -import { Button, Card, CardItem, Body, Row, Right, Text, Left } from "native-base"; -import { Svg, Line } from "react-native-svg"; -import Long from "long"; -import BigNumber from "bignumber.js"; - -import { useStoreActions, useStoreState } from "../state/store"; -import { lnrpc } from "../../proto/lightning"; import * as nativeBaseTheme from "../native-base-theme/variables/commonColor"; -import { valueBitcoin, getUnitNice, valueFiat } from "../utils/bitcoin-units"; + +import { Alert, Image, Linking, StyleSheet } from "react-native"; +import { Body, Button, Card, CardItem, Left, Right, Row, Text } from "native-base"; +import { Line, Svg } from "react-native-svg"; +import { getUnitNice, valueBitcoin, valueFiat } from "../utils/bitcoin-units"; import { identifyService, lightningServices } from "../utils/lightning-services"; +import { useStoreActions, useStoreState } from "../state/store"; + +import BigNumber from "bignumber.js"; import CopyText from "./CopyText"; +import Long from "long"; +import React from "react"; import { constructOnchainExplorerUrl } from "../utils/onchain-explorer"; +import { lnrpc } from "../../proto/lightning"; +import { namespaces } from "../i18n/i18n.constants"; import { toast } from "../utils"; - import { useTranslation } from "react-i18next"; -import { namespaces } from "../i18n/i18n.constants"; const blixtTheme = nativeBaseTheme.blixtTheme; @@ -153,6 +153,14 @@ export function ChannelCard({ channel, alias }: IChannelCardProps) { {channel.chanId?.toString()} + + + {t("channel.channelPoint")} + + + {channel.channelPoint?.toString()} + + {t("channel.status")} diff --git a/src/lndmobile/index.ts b/src/lndmobile/index.ts index 41c9fb7c6..6cc037728 100644 --- a/src/lndmobile/index.ts +++ b/src/lndmobile/index.ts @@ -1,13 +1,14 @@ -import { NativeModules } from "react-native"; -import { sendCommand, sendStreamCommand, decodeStreamResult } from "./utils"; -import { lnrpc, routerrpc, invoicesrpc, devrpc } from "../../proto/lightning"; -import Long from "long"; -import sha from "sha.js"; -import { stringToUint8Array, hexToUint8Array, unicodeStringToUint8Array } from "../utils"; import { TLV_KEYSEND, TLV_RECORD_NAME, TLV_WHATSAT_MESSAGE } from "../utils/constants"; -import { checkLndStreamErrorResponse } from "../utils/lndmobile"; -import { LndMobileEventEmitter } from "../utils/event-listener"; +import { decodeStreamResult, sendCommand, sendStreamCommand } from "./utils"; +import { devrpc, invoicesrpc, lnrpc, routerrpc } from "../../proto/lightning"; import { getChanInfo, listPrivateChannels } from "./channel"; +import { hexToUint8Array, stringToUint8Array, unicodeStringToUint8Array } from "../utils"; + +import { LndMobileEventEmitter } from "../utils/event-listener"; +import Long from "long"; +import { NativeModules } from "react-native"; +import { checkLndStreamErrorResponse } from "../utils/lndmobile"; +import sha from "sha.js"; const { LndMobile, LndMobileTools } = NativeModules; /** @@ -694,3 +695,21 @@ export type IReadLndLogResponse = string[]; export const readLndLog = async (): Promise => { return [""]; }; + + +export const abandonChannel = async (fundingTxId: string, index: number): Promise => { + const response = await sendCommand({ + request: lnrpc.AbandonChannelRequest, + response: lnrpc.AbandonChannelResponse, + method: "AbandonChannel", + options: { + channelPoint: { + fundingTxidStr: fundingTxId, + outputIndex: index, + }, + iKnowWhatIAmDoing: true, + } + }) + + return response; +} diff --git a/src/windows/InitProcess/DEV_Commands.tsx b/src/windows/InitProcess/DEV_Commands.tsx index b93095004..f681b7ff8 100644 --- a/src/windows/InitProcess/DEV_Commands.tsx +++ b/src/windows/InitProcess/DEV_Commands.tsx @@ -1,43 +1,46 @@ -import React, { useState } from "react"; -import { StyleSheet, StatusBar, NativeModules, ScrollView, DeviceEventEmitter, EventEmitter, NativeEventEmitter, Linking } from "react-native"; -import Clipboard from "@react-native-community/clipboard"; -import { Text, Button, Toast, Input, View, Container } from "native-base"; -import Long from "long"; -import { StackNavigationProp } from "@react-navigation/stack"; -import * as base64 from "base64-js"; import * as Keychain from 'react-native-keychain'; -// import Sound from "react-native-sound"; -import { JSHash, CONSTANTS } from "react-native-hash"; -import { generateSecureRandom } from "react-native-securerandom"; -// import RNLocalize from "react-native-localize"; +import * as base64 from "base64-js"; -import { Alert } from "../../utils/alert"; -import { getTransactions, getTransaction, createTransaction, clearTransactions } from "../../storage/database/transaction"; -import { useStoreState, useStoreActions } from "../../state/store"; +import { ANDROID_PUSH_NOTIFICATION_PUSH_CHANNEL_ID, PLATFORM } from "../../utils/constants"; +import { Button, Container, Input, Text, Toast, View } from "native-base"; +// import Sound from "react-native-sound"; +import { CONSTANTS, JSHash } from "react-native-hash"; +import { DeviceEventEmitter, EventEmitter, Linking, NativeEventEmitter, NativeModules, ScrollView, StatusBar, StyleSheet } from "react-native"; +import React, { useState } from "react"; +import { StorageItem, getItem, setItem, setItemObject, storage } from "../../storage/app"; +import { abandonChannel, checkStatus, connectPeer, decodePayReq, getInfo, getNetworkInfo, getNodeInfo, importGraph, listInvoices, listPeers, listUnspent, queryRoutes } from "../../lndmobile/index"; +import { bytesToHexString, bytesToString, stringToUint8Array, toast } from "../../utils"; +import { channelAcceptor, channelAcceptorResponse, closeChannel, decodeChannelAcceptRequest, decodeChannelEvent, listChannels, openChannel, pendingChannels } from "../../lndmobile/channel"; +import { clearTransactions, createTransaction, getTransaction, getTransactions } from "../../storage/database/transaction"; +import { deriveKey, derivePrivateKey, genSeed, initWallet, signMessage } from "../../lndmobile/wallet"; +import { getItemObject, getPin, getWalletPassword, setWalletPassword } from "../../storage/keystore"; import { invoicesrpc, lnrpc } from "../../../proto/lightning"; -import { sendCommand } from "../../lndmobile/utils"; -import { getInfo, connectPeer, listPeers, decodePayReq, queryRoutes, checkStatus, getNodeInfo, listUnspent, getNetworkInfo, importGraph, listInvoices } from "../../lndmobile/index"; -import { initWallet, genSeed, deriveKey, signMessage, derivePrivateKey } from "../../lndmobile/wallet"; -import { pendingChannels, listChannels, openChannel, closeChannel, channelAcceptor, decodeChannelEvent, decodeChannelAcceptRequest, channelAcceptorResponse } from "../../lndmobile/channel"; +import { modifyStatus, queryScores, status } from "../../lndmobile/autopilot"; import { newAddress, sendCoins } from "../../lndmobile/onchain"; -import { storage, StorageItem, setItemObject, getItem, setItem } from "../../storage/app"; -import { status, modifyStatus, queryScores } from "../../lndmobile/autopilot"; -import { RootStackParamList } from "../../Main"; -import { setWalletPassword, getWalletPassword, getItemObject, getPin } from "../../storage/keystore"; +import { useStoreActions, useStoreState } from "../../state/store"; + +import { Alert } from "../../utils/alert"; +import Clipboard from "@react-native-community/clipboard"; import Content from "../../components/Content"; -import { blixtTheme } from "../../native-base-theme/variables/commonColor"; +import { ICLOUD_BACKUP_KEY } from "../../state/ICloudBackup"; +import { ILightningServices } from "../../utils/lightning-services"; +import { LndMobileEventEmitter } from "../../utils/event-listener"; import { LoginMethods } from "../../state/Security"; +import Long from "long"; +import PushNotification from "react-native-push-notification"; +import { RootStackParamList } from "../../Main"; import Spinner from "../../components/Spinner"; - -import secp256k1 from "secp256k1"; -import { bytesToString, bytesToHexString, stringToUint8Array, toast } from "../../utils"; -import { ILightningServices } from "../../utils/lightning-services"; +import { StackNavigationProp } from "@react-navigation/stack"; +import { blixtTheme } from "../../native-base-theme/variables/commonColor"; +import { generateSecureRandom } from "react-native-securerandom"; import { localNotification } from "../../utils/push-notification"; -import { ICLOUD_BACKUP_KEY } from "../../state/ICloudBackup"; import { notificationManager } from "../../state/NotificationManager"; -import PushNotification from "react-native-push-notification"; -import { ANDROID_PUSH_NOTIFICATION_PUSH_CHANNEL_ID, PLATFORM } from "../../utils/constants"; -import { LndMobileEventEmitter } from "../../utils/event-listener"; +import secp256k1 from "secp256k1"; +import { sendCommand } from "../../lndmobile/utils"; + +// import RNLocalize from "react-native-localize"; + + let iCloudStorage: any; console.log(PLATFORM); @@ -50,6 +53,7 @@ interface IProps { continueCallback?: () => void; } export default function DEV_Commands({ navigation, continueCallback }: IProps) { + const [channelPoint, setChannelPoint] = useState(""); const [connectPeerStr, setConnectPeer] = useState(""); const [sat, setSat] = useState(""); const [addr, setAddr] = useState(""); @@ -916,6 +920,35 @@ export default function DEV_Commands({ navigation, continueCallback }: IProps) { + setChannelPoint(text)} + placeholder=":" + value={channelPoint} + /> + { setConnectPeer(text); @@ -932,7 +965,7 @@ export default function DEV_Commands({ navigation, continueCallback }: IProps) { setCommandResult(result); setError({}); } - catch (e) { + catch (e: any) { setError(e); setCommandResult({}); }