Skip to content

Commit 236ae64

Browse files
Merge pull request #24 from synonymdev/connect-peer-from-uri
connectPeerFromUri convenience function
2 parents 7e84623 + 0992dfe commit 236ae64

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@synonymdev/react-native-lightning",
33
"title": "React Native Lightning",
4-
"version": "0.0.33",
4+
"version": "0.0.34",
55
"description": "React Native wrapper for Lndmobile",
66
"main": "./dist/index.js",
77
"types": "./dist/index.d.ts",

src/lnd.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class LND {
218218
}
219219

220220
/**
221-
* LND ConnectPeer
221+
* LND ConnectPeer with pubkey and host
222222
* @returns {Promise<Ok<lnrpc.ConnectPeerResponse> | Err<unknown>>}
223223
* @param host
224224
* @param pubkey
@@ -241,6 +241,21 @@ class LND {
241241
}
242242
}
243243

244+
/**
245+
* LND ConnectPeer from single URI string
246+
* @returns {Promise<Ok<lnrpc.ConnectPeerResponse> | Err<unknown>>}
247+
* @param host
248+
* @param pubkey
249+
*/
250+
async connectPeerFromUri(uri: string): Promise<Result<lnrpc.ConnectPeerResponse>> {
251+
const params = uri.split('@');
252+
if (params.length !== 2) {
253+
return err('Invalid URI');
254+
}
255+
256+
return await this.connectPeer(params[0], params[1]);
257+
}
258+
244259
/**
245260
* LND OpenChannelSync
246261
* @returns {Promise<Err<unknown, Error> | Ok<lnrpc.ChannelPoint, Error> | Err<unknown, any>>}

0 commit comments

Comments
 (0)