Skip to content

Commit

Permalink
Merge pull request #15 from LtbLightning/bug-fix
Browse files Browse the repository at this point in the history
add setLiquiditySourceLsps2
  • Loading branch information
BitcoinZavior authored Oct 17, 2024
2 parents d610d1a + 73e93ad commit 9f3c7d1
Show file tree
Hide file tree
Showing 16 changed files with 1,764 additions and 1,492 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## [0.3.1]

Fixed LSP receive bug

## [0.3.0]

This is the new release of `ldk-node-rn` v0.3.0 .
This is the new release of `ldk-node-rn` v0.3.0

#### APIs added

Expand Down
6 changes: 3 additions & 3 deletions android/.settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
arguments=--init-script /var/folders/jq/5j94k7zj0yq600jvnc_6xqf80000gn/T/d146c9752a26f79b52047fb6dc6ed385d064e120494f96f08ca63a317c41f94c.gradle --init-script /var/folders/jq/5j94k7zj0yq600jvnc_6xqf80000gn/T/52cde0cfcf3e28b8b7510e992210d9614505e0911af0c190bd590d7158574963.gradle
arguments=--init-script /var/folders/77/pwdxzmrn7p53dyts2cw8s2ch0000gn/T/db3b08fc4a9ef609cb16b96b200fa13e563f396e9bb1ed0905fdab7bc3bc513b.gradle --init-script /var/folders/77/pwdxzmrn7p53dyts2cw8s2ch0000gn/T/52cde0cfcf3e28b8b7510e992210d9614505e0911af0c190bd590d7158574963.gradle
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(8.1.1))
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(8.9))
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
java.home=/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
java.home=/Library/Java/JavaVirtualMachines/jdk-18.0.2.jdk/Contents/Home
jvm.arguments=
offline.mode=false
override.workspace.settings=true
Expand Down
46 changes: 46 additions & 0 deletions android/src/main/java/io/ltbl/ldknodern/LdkNodeRnModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,25 @@ class LdkNodeRnModule(reactContext: ReactApplicationContext) :
}.start()
}

@ReactMethod
fun setLiquiditySourceLsps2 (address: String,
nodeId: String,
token: String,
builderId: String,
result: Promise
){
Thread {
try {
_builders[builderId]!!.setLiquiditySourceLsps2(address, nodeId, token)
runOnUiThread {
result.resolve(true)
}
} catch (error: Throwable) {
result.reject("Node setLiquiditySourceLsps2 error", error.localizedMessage, error)
}
}.start()
}

@ReactMethod
fun setGossipSourceP2p(builderId: String, result: Promise) {
Thread {
Expand Down Expand Up @@ -473,6 +492,33 @@ class LdkNodeRnModule(reactContext: ReactApplicationContext) :
}.start()
}

@ReactMethod
fun receiveViaJitChannel(
nodeId: String,
amountMsat: Int,
description: String,
expirySecs: Int,
result: Promise
) {
Thread {
try {
val maxFeeLimitMsat: Int = 20002000
val node = _nodes[nodeId] ?: throw IllegalStateException("Node not found")
val invoice = node.bolt11Payment().receiveViaJitChannel(
amountMsat.toULong(),
description,
expirySecs.toUInt(),
maxFeeLimitMsat.toULong()
)
runOnUiThread {
result.resolve(invoice)
}
} catch (error: Throwable) {
result.reject("Receive payment invoice error", error.message.orEmpty(), error)
}
}.start()
}

@ReactMethod
fun listPayments(nodeId: String, result: Promise) {
Thread {
Expand Down
9 changes: 9 additions & 0 deletions ios/LdkNodeRnModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -444,4 +444,13 @@ + (BOOL)requiresMainQueueSetup { return NO; }
resolve: (RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject
)

RCT_EXTERN_METHOD(
setLiquiditySourceLsps2: (nonnull NSString*)address
nodeId: (nonnull NSString*)publicKey
token: (nonnull NSString*)token
buildId: (nonnull NSString*)buildId
resolve: (RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject
)
@end
17 changes: 17 additions & 0 deletions ios/LdkNodeRnModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,23 @@ class LdkNodeRnModule: NSObject {
}
}

@objc
func setLiquiditySourceLsps2(_
address: String,
nodeId: String,
token: String,
buildId: String,
resolve: @escaping RCTPromiseResolveBlock,
reject: @escaping RCTPromiseRejectBlock
) {
DispatchQueue.main.async { [self] in
_builders[buildId]!.setLiquiditySourceLsps2(address: address, nodeId: nodeId, token: token)
resolve(true)
}
}



@objc
func setGossipSourceP2p(_
builderId: String,
Expand Down
151 changes: 77 additions & 74 deletions lib/classes/Builder.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,78 +3,81 @@ import { NativeLoader } from './NativeLoader';
import { NetAddress } from './Bindings';
import { Node } from './Node';
export declare class Builder extends NativeLoader {
id: string;
/**
* Create builder class from [Config]
* @requires config
* @returns Promise<Builder>
*/
fromConfig(config: Config): Promise<Builder>;
/**
* Configures the [Node] instance to source its wallet entropy from a seed file on disk.
*
* If the given file does not exist a new random seed file will be generated and stored at the given location.
* @requires seedPath
* @returns {Promise<boolean>}
*/
setEntropySeedPath(seedPath: string): Promise<boolean>;
/**
* Configures the [Node] instance to source its wallet entropy from the given 64 seed bytes.
*
* **Note:** Panics if the length of the given `seedBytes` differs from 64.
* @requires seedBytes
* @returns {Promise<boolean>}
*/
setEntropySeedBytes(seedBytes: Array<number>): Promise<boolean>;
/**
* Set mnemoninc
*
* @requires mnemoninc
* @param passphrase
* @returns {Promise<boolean>}
*/
setEntropyBip39Mnemonic(mnemoninc: string, passphrase?: string): Promise<boolean>;
/**
* Configures the [Node] instance to source its chain data from the given Esplora server.
* @requires esploraServerUrl
* @returns {Promise<boolean>}
*/
setEsploraServer(esploraServerUrl: string): Promise<boolean>;
/**
* Configures the [Node] instance to source its gossip data from the Lightning peer-to-peer network.
* @returns {Promise<boolean>}
*/
id: string;
/**
* Create builder class from [Config]
* @requires config
* @returns Promise<Builder>
*/
fromConfig(config: Config): Promise<Builder>;
/**
* Configures the [Node] instance to source its wallet entropy from a seed file on disk.
*
* If the given file does not exist a new random seed file will be generated and stored at the given location.
* @requires seedPath
* @returns {Promise<boolean>}
*/
setEntropySeedPath(seedPath: string): Promise<boolean>;
/**
* Configures the [Node] instance to source its wallet entropy from the given 64 seed bytes.
*
* **Note:** Panics if the length of the given `seedBytes` differs from 64.
* @requires seedBytes
* @returns {Promise<boolean>}
*/
setEntropySeedBytes(seedBytes: Array<number>): Promise<boolean>;
/**
* Set mnemoninc
*
* @requires mnemoninc
* @param passphrase
* @returns {Promise<boolean>}
*/
setEntropyBip39Mnemonic(mnemoninc: string, passphrase?: string): Promise<boolean>;
/**
* Configures the [Node] instance to source its chain data from the given Esplora server.
* @requires esploraServerUrl
* @returns {Promise<boolean>}
*/
setEsploraServer(esploraServerUrl: string): Promise<boolean>;
/**
* Configures the [Node] instance to source its gossip data from the Lightning peer-to-peer network.
* @returns {Promise<boolean>}
*/
setGossipSourceP2p(): Promise<boolean>;
/**
* Configures the [Node] instance to source its gossip data from the given RapidGossipSync server.
* @requires rgsServerUrl
* @returns {Promise<boolean>}
*/
setGossipSourceRgs(rgsServerUrl: string): Promise<boolean>;
/**
* Sets the used storage directory path.
* @requires storageDirPath
* @returns {Promise<boolean>}
*/
setStorageDirPath(storageDirPath: string): Promise<boolean>;
/**
* Sets the Bitcoin network used.
* @requires network
* @returns {Promise<boolean>}
*/
setNetwork(network: string): Promise<boolean>;
/**
* Sets the IP addresses and TCP port on which [Node] will listen for incoming network connections.
* @requires listeningAddresses
* @returns {Promise<boolean>}
*/
setListeningAddresses(listeningAddresses: Array<NetAddress>): Promise<boolean>;
/**
* Sets the LiquiditySourceLsps2.
* @returns {Promise<boolean>}
*/
setLiquiditySourceLsps2(address: string, publicKey: string, token: String): Promise<boolean>;

setLiquiditySourceLsps2(address: string, publicKey:string, token:String): Promise<boolean>;

setGossipSourceP2p(): Promise<boolean>;
/**
* Configures the [Node] instance to source its gossip data from the given RapidGossipSync server.
* @requires rgsServerUrl
* @returns {Promise<boolean>}
*/
setGossipSourceRgs(rgsServerUrl: string): Promise<boolean>;
/**
* Sets the used storage directory path.
* @requires storageDirPath
* @returns {Promise<boolean>}
*/
setStorageDirPath(storageDirPath: string): Promise<boolean>;
/**
* Sets the Bitcoin network used.
* @requires network
* @returns {Promise<boolean>}
*/
setNetwork(network: string): Promise<boolean>;
/**
* Sets the IP addresses and TCP port on which [Node] will listen for incoming network connections.
* @requires listeningAddresses
* @returns {Promise<boolean>}
*/
setListeningAddresses(listeningAddresses: Array<NetAddress>): Promise<boolean>;
/**
* Create node
* @returns {Promise<Node>}
*/
build(): Promise<Node>;
}
/**
* Create node
* @returns {Promise<Node>}
*/
build(): Promise<Node>;
}
13 changes: 1 addition & 12 deletions lib/classes/Config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,5 @@ export declare class Config extends NativeLoader {
* @param trustedPeers0conf
* @returns {Promise<Config>}
*/
create(
storageDirPath: string,
logDirPath: string | undefined,
network: string,
listeningAddress: Array<NetAddress> | null,
defaultCltvExpiryDelta?: number,
onchainWalletSyncIntervalSecs?: number,
walletSyncIntervalSecs?: number,
feeRateCacheUpdateIntervalSecs?: number,
trustedPeers0conf?: Array<string>,
probingLiquidityLimitMultiplier?: number,
logLevel?: LogLevel): Promise<Config>;
create(storageDirPath: string, logDirPath: string | undefined, network: string, listeningAddress: Array<NetAddress> | null, defaultCltvExpiryDelta?: number, onchainWalletSyncIntervalSecs?: number, walletSyncIntervalSecs?: number, feeRateCacheUpdateIntervalSecs?: number, trustedPeers0conf?: Array<string>, probingLiquidityLimitMultiplier?: number, logLevel?: LogLevel): Promise<Config>;
}
Loading

0 comments on commit 9f3c7d1

Please sign in to comment.