Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add funding address param to FundNode query #198

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,11 @@ class LightsparkFuturesClient(config: ClientConfig) {
*
* @param nodeId The ID of the node to fund. Must be a REGTEST node.
* @param amountSats The amount of funds to add to the node. Defaults to 10,000,000 SATOSHI.
* @param fundingAddress: L1 address owned by funded node. If null, automatically create new funding address
* @return The amount of funds added to the node.
*/
fun fundNode(nodeId: String, amountSats: Long?): CompletableFuture<CurrencyAmount> =
coroutineScope.future { coroutinesClient.fundNode(nodeId, amountSats) }
fun fundNode(nodeId: String, amountSats: Long?, fundingAddress: String? = null): CompletableFuture<CurrencyAmount> =
coroutineScope.future { coroutinesClient.fundNode(nodeId, amountSats, fundingAddress) }

/**
* Withdraws funds from the account and sends it to the requested bitcoin address.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -729,16 +729,22 @@ class LightsparkCoroutinesClient private constructor(
*
* @param nodeId The ID of the node to fund. Must be a REGTEST node.
* @param amountSats The amount of funds to add to the node. Defaults to 10,000,000 SATOSHI.
* @param fundingAddress: L1 address owned by funded node. If null, automatically create new funding address
* @return The amount of funds added to the node.
*/
suspend fun fundNode(nodeId: String, amountSats: Long?): CurrencyAmount {
suspend fun fundNode(
nodeId: String,
amountSats: Long?,
fundingAddress: String? = null
): CurrencyAmount {
requireValidAuth()
return executeQuery(
Query(
FundNodeMutation,
{
add("node_id", nodeId)
amountSats?.let { add("amount_sats", it) }
fundingAddress?.let { add("funding_address", it)}
},
signingNodeId = nodeId,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,12 @@ class LightsparkSyncClient constructor(config: ClientConfig) {
*
* @param nodeId The ID of the node to fund. Must be a REGTEST node.
* @param amountSats The amount of funds to add to the node. Defaults to 10,000,000 SATOSHI.
* @param fundingAddress: L1 address owned by funded node. If null, automatically create new funding address
* @return The amount of funds added to the node.
*/
@Throws(LightsparkException::class, LightsparkAuthenticationException::class, CancellationException::class)
fun fundNode(nodeId: String, amountSats: Long?): CurrencyAmount =
runBlocking { asyncClient.fundNode(nodeId, amountSats) }
fun fundNode(nodeId: String, amountSats: Long?, fundingAddress: String? = null): CurrencyAmount =
runBlocking { asyncClient.fundNode(nodeId, amountSats, fundingAddress) }

/**
* Withdraws funds from the account and sends it to the requested bitcoin address.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ const val FundNodeMutation = """
mutation FundNode(
${'$'}node_id: ID!,
${'$'}amount_sats: Long
${'$'}funding_address: String
) {
fund_node(input: { node_id: ${'$'}node_id, amount_sats: ${'$'}amount_sats }) {
fund_node(input: {
node_id: ${'$'}node_id,
amount_sats: ${'$'}amount_sats,
funding_address: ${'$'}funding_address
}) {
amount {
...CurrencyAmountFragment
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import kotlinx.serialization.Serializable
data class FundNodeInput(
val nodeId: String,
val amountSats: Long? = null,
val fundingAddress: String? = null,
) {
companion object {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import kotlinx.serialization.Serializable
@SerialName("FundWalletInput")
data class FundWalletInput(
val amountSats: Long? = null,
val fundingAddress: String? = null,
) {
companion object {
}
Expand Down
Loading