Skip to content

Commit 06d0aec

Browse files
authored
Support simple close (#168)
Implements ACINQ/lightning-kmp#597.
1 parent 75ae285 commit 06d0aec

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
kotlin = "2.1.20"
33
kotlinx-io = "0.6.0"
44
clikt = "4.4.0"
5-
ktor = "3.1.0"
5+
ktor = "3.1.2"
66
sqldelight = "2.0.2" # TODO: remove 'addEnclosingTransaction' hack in AfterVersionX files when upgrading
7-
lightningkmp = "1.9.0"
7+
lightningkmp = "1.9.2-SNAPSHOT"
88
kermit-io = "2.0.5"
99

1010
# test dependencies

src/commonMain/kotlin/fr/acinq/phoenixd/Api.kt

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import fr.acinq.lightning.NodeParams
1111
import fr.acinq.lightning.PaymentEvents
1212
import fr.acinq.lightning.blockchain.fee.FeeratePerByte
1313
import fr.acinq.lightning.blockchain.fee.FeeratePerKw
14+
import fr.acinq.lightning.channel.ChannelCloseResponse
1415
import fr.acinq.lightning.channel.ChannelCommand
1516
import fr.acinq.lightning.channel.ChannelFundingResponse
1617
import fr.acinq.lightning.channel.states.*
@@ -453,16 +454,11 @@ class Api(
453454
val channelId = formParameters.getByteVector32("channelId")
454455
val scriptPubKey = formParameters.getAddressAndConvertToScript("address")
455456
val feerate = FeeratePerKw(FeeratePerByte(formParameters.getLong("feerateSatByte").sat))
456-
val res = async {
457-
nodeParams.nodeEvents
458-
.filterIsInstance<PaymentEvents.PaymentSent>()
459-
.map { it.payment }
460-
.filterIsInstance<ChannelCloseOutgoingPayment>()
461-
.first()
457+
when (val r = peer.mutualClose(channelId, scriptPubKey, feerate)) {
458+
is ChannelCloseResponse.Success -> call.respondText(r.closingTxId.toString())
459+
is ChannelCloseResponse.Failure -> call.respondText(r.toString())
460+
else -> call.respondText("no channel available")
462461
}
463-
peer.send(WrappedChannelCommand(channelId, ChannelCommand.Close.MutualClose(scriptPubKey, ClosingFeerates(feerate))))
464-
val channelClose = res.await()
465-
call.respondText(channelClose.txId.toString())
466462
}
467463
}
468464
post("export") {

0 commit comments

Comments
 (0)