Skip to content

Commit

Permalink
Merge pull request #1600 from synonymdev/recover-outputs-ldk
Browse files Browse the repository at this point in the history
feat(lightning): utility function to recover any unspent outputs
  • Loading branch information
coreyphillips authored Mar 16, 2024
2 parents 8609f56 + 06d0132 commit 8626595
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 11 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ android {
applicationId "to.synonym.bitkit.wallet"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 102
versionCode 110
versionName "1.0"
multiDexEnabled true
missingDimensionStrategy 'react-native-camera', 'general'
Expand Down
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ PODS:
- React-Core
- react-native-keep-awake (1.2.2):
- React-Core
- react-native-ldk (0.0.134):
- react-native-ldk (0.0.135):
- React
- react-native-mmkv (2.11.0):
- MMKV (>= 1.2.13)
Expand Down Expand Up @@ -910,7 +910,7 @@ SPEC CHECKSUMS:
react-native-flipper: 9c1957af24b76493ba74f46d000a5c1d485e7731
react-native-image-picker: 2e2e82aba9b6a91a7c78f7d9afde341a2659c7b8
react-native-keep-awake: ad1d67f617756b139536977a0bf06b27cec0714a
react-native-ldk: e4971770e3773415fff4e5aa04df83f9d5485744
react-native-ldk: fc2d2500236c89d69206f375b11fb99f7d5b3732
react-native-mmkv: e97c0c79403fb94577e5d902ab1ebd42b0715b43
react-native-netinfo: 5ddbf20865bcffab6b43d0e4e1fd8b3896beb898
react-native-quick-base64: a5dbe4528f1453e662fcf7351029500b8b63e7bb
Expand Down
4 changes: 2 additions & 2 deletions ios/bitkit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 102;
CURRENT_PROJECT_VERSION = 110;
DEVELOPMENT_TEAM = KYH47R284B;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = bitkit/Info.plist;
Expand Down Expand Up @@ -587,7 +587,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 102;
CURRENT_PROJECT_VERSION = 110;
DEVELOPMENT_TEAM = KYH47R284B;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = bitkit/Info.plist;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bitkit",
"author": "Synonym",
"version": "1.0.0-beta.102",
"version": "1.0.0-beta.110",
"scripts": {
"start": "react-native start",
"android": "react-native run-android",
Expand Down Expand Up @@ -51,7 +51,7 @@
"@synonymdev/blocktank-client": "0.0.50",
"@synonymdev/blocktank-lsp-http-client": "0.13.1",
"@synonymdev/feeds": "2.1.1",
"@synonymdev/react-native-ldk": "0.0.134",
"@synonymdev/react-native-ldk": "0.0.135",
"@synonymdev/react-native-lnurl": "0.0.7",
"@synonymdev/result": "0.0.2",
"@synonymdev/slashtags-auth": "1.0.0-alpha.6",
Expand Down
24 changes: 24 additions & 0 deletions src/screens/Settings/Lightning/Channels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
payLightningInvoice,
rebroadcastAllKnownTransactions,
recoverOutputs,
recoverOutputsFromForceClose,
refreshLdk,
setupLdk,
} from '../../../utils/lightning';
Expand Down Expand Up @@ -565,6 +566,29 @@ const Channels = ({
setSpendingStuckOutputs(false);
}}
/>
<Button
style={styles.devButton}
text="Spend outputs from force close"
loading={spendingStuckOutputs}
onPress={async (): Promise<void> => {
setSpendingStuckOutputs(true);
const res = await recoverOutputsFromForceClose();
if (res.isOk()) {
showToast({
type: 'info',
title: 'Completed',
description: res.value,
});
} else {
showToast({
type: 'warning',
title: 'No stuck outputs recovered',
description: res.error.message,
});
}
setSpendingStuckOutputs(false);
}}
/>
<Button
style={styles.devButton}
text="Get Node ID"
Expand Down
6 changes: 6 additions & 0 deletions src/utils/lightning/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1710,6 +1710,12 @@ export const recoverOutputs = async (): Promise<Result<string>> => {
return await lm.recoverOutputs();
};

export const recoverOutputsFromForceClose = async (): Promise<
Result<string>
> => {
return await lm.recoverOutputsFromForceClose();
};

/**
* Returns total reserve balance for all open lightning channels.
* @param {TWalletName} [selectedWallet]
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4376,10 +4376,10 @@
dependencies:
b4a "^1.5.3"

"@synonymdev/[email protected].134":
version "0.0.134"
resolved "https://registry.yarnpkg.com/@synonymdev/react-native-ldk/-/react-native-ldk-0.0.134.tgz#36870d17128ca76bf08aea6ba6909187fe7fbdd7"
integrity sha512-Peb6VQ/HLe9Tv+MsjnU2pQR7Yi/oU6GtryUwBbfytvbxdsq0luFkAEKHxzQ/wNjO7z1QYLmMhK6IVqJC3zaT8Q==
"@synonymdev/[email protected].135":
version "0.0.135"
resolved "https://registry.yarnpkg.com/@synonymdev/react-native-ldk/-/react-native-ldk-0.0.135.tgz#402ef9d4804aa300d33662129b8d2d8d51ffa6ff"
integrity sha512-yWvL40LfkVq5zySIDy0I9IZMfGIcGkypkR72jcK1fwWhbcNRsoSsIBEeaSK58JIiBKyJc1bUkfEaTme1kNdgJA==
dependencies:
bech32 "^2.0.0"
bitcoinjs-lib "^6.0.2"
Expand Down

0 comments on commit 8626595

Please sign in to comment.