Skip to content

Commit

Permalink
Upgrade to lightning-kmp 1.8.2 (#116)
Browse files Browse the repository at this point in the history
This upgrade a side-effects on how we store mining fees for liquidity
events.

---------

Co-authored-by: pm47 <[email protected]>
  • Loading branch information
dpad85 and pm47 authored Oct 10, 2024
1 parent 9a7ebcb commit f92c6a9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
object Versions {
val kotlin = "1.9.23"
val lightningKmp = "1.8.0"
val lightningKmp = "1.8.2"
val sqlDelight = "2.0.1"
val okio = "3.8.0"
val clikt = "4.2.2"
Expand Down
1 change: 1 addition & 0 deletions src/commonMain/kotlin/fr/acinq/lightning/bin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ class Phoenixd : CliktCommand() {
maxAbsoluteFee = liquidityOptions.maxMiningFee,
maxRelativeFeeBasisPoints = liquidityOptions.maxRelativeFeeBasisPoints,
skipAbsoluteFeeCheck = false,
considerOnlyMiningFeeForAbsoluteFeeCheck = true,
maxAllowedFeeCredit = liquidityOptions.maxFeeCredit
)
val keyManager = LocalKeyManager(seed.seed, chain, lsp.swapInXpub)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class InboundLiquidityQueries(val database: PhoenixDatabase) {
database.transaction {
queries.insert(
id = payment.id.toString(),
// We store the full mining fee in the database, for compatibility reasons. See comment in the mapper below for details.
mining_fees_sat = payment.miningFees.sat,
channel_id = payment.channelId.toByteArray(),
tx_id = payment.txId.value.toByteArray(),
Expand Down Expand Up @@ -89,12 +90,16 @@ class InboundLiquidityQueries(val database: PhoenixDatabase) {
confirmed_at: Long?,
locked_at: Long?
): InboundLiquidityOutgoingPayment {
val purchase = PurchaseData.decodeAsCanonical(lease_type, lease_blob)
return InboundLiquidityOutgoingPayment(
id = UUID.fromString(id),
miningFees = mining_fees_sat.sat,
// Attention! With the new OTF and lightning-kmp#710, the liquidity mining fee is split between `localMiningFee` and `purchase.miningFee`.
// However, for compatibility reasons with legacy lease data, we keep storing the "merged" mining fee in the mining_fee_sat column.
// It means that to retrieve the `localMiningFee`, we must subtract `purchase.miningFee` from the `mining_fee_sat` column.
localMiningFees = mining_fees_sat.sat - purchase.fees.miningFee,
channelId = channel_id.toByteVector32(),
txId = TxId(tx_id),
purchase = PurchaseData.decodeAsCanonical(lease_type, lease_blob),
purchase = purchase,
createdAt = created_at,
confirmedAt = confirmed_at,
lockedAt = locked_at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Stores in a flat row payments standing for an inbound liquidity request (which are done through a splice).
-- The purchase data are stored in a complex column, as a json-encoded blob. See InboundLiquidityLeaseType file.
-- The purchase data are stored in a complex column, as a json-encoded blob.
--
-- Note that these purchase data used to be called "lease" in the old on-the-fly channel mechanism, that's why the
-- colum uses that name, it's a legacy artifact. They now map to a "LiquidityAds.Purchase" object.
Expand Down

0 comments on commit f92c6a9

Please sign in to comment.