Skip to content

Commit

Permalink
add funding address param to FundNode query (#198)
Browse files Browse the repository at this point in the history
# Add funding address to FundNode query

add optional string `funding address` and javadoc
  • Loading branch information
matthappens authored Aug 15, 2024
2 parents 2acecb6 + 2e6bace commit 9b02e94
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
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

0 comments on commit 9b02e94

Please sign in to comment.