Skip to content

Commit

Permalink
Replace --max-absolute-fee by --max-mining-fee (#32)
Browse files Browse the repository at this point in the history
It makes much more sense to consider only the mining fee, for the absolute fee check, as it is volatile and amount-independent. The service fee is in % and predictable.

The default value is equivalent as before (1% of the default `auto-liquidity`, given that the previous value of 2% included the 1% liquidity service fee). Previous option is deprecated and explicitly rejected.
  • Loading branch information
pm47 authored Apr 10, 2024
1 parent 75247e4 commit 5e1ab0d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 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.6.2-FEECREDIT-5"
val lightningKmp = "1.6.2-FEECREDIT-6"
val sqlDelight = "2.0.1"
val okio = "3.8.0"
val clikt = "4.2.2"
Expand Down
21 changes: 11 additions & 10 deletions src/commonMain/kotlin/fr/acinq/lightning/bin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,14 @@ class Phoenixd : CliktCommand() {
"5m" to 5_000_000.sat,
"10m" to 10_000_000.sat,
).default(2_000_000.sat, "2m")
val maxAbsoluteFee by option("--max-absolute-fee", help = "Max absolute fee for on-chain operations. Includes mining fee and service fee for auto-liquidity.")
val maxAbsoluteFee by option("--max-absolute-fee", hidden = true).deprecated("--max-absolute-fee is deprecated, use --max-mining-fee instead", error = true)
val maxMiningFee by option("--max-mining-fee", help = "Max mining fee for on-chain operations, in satoshis")
.int().convert { it.sat }
.restrictTo(5_000.sat..100_000.sat)
.defaultLazy("2% of auto-liquidity amount") {
autoLiquidity * 2 / 100
.restrictTo(5_000.sat..200_000.sat)
.defaultLazy("1% of auto-liquidity amount") {
autoLiquidity * 1 / 100
}
val maxFeeCredit by option("--max-fee-credit", help = "Max fee credit, if reached payments will be rejected.").choice(
val maxFeeCredit by option("--max-fee-credit", help = "Max fee credit, if reached payments will be rejected").choice(
"off" to 0.sat,
"50k" to 50_000.sat,
"100k" to 100_000.sat,
Expand Down Expand Up @@ -219,9 +220,9 @@ class Phoenixd : CliktCommand() {
)
val lsp = LSP.from(chain)
val liquidityPolicy = LiquidityPolicy.Auto(
maxAbsoluteFee = liquidityOptions.maxAbsoluteFee,
maxMiningFee = liquidityOptions.maxMiningFee,
maxRelativeFeeBasisPoints = liquidityOptions.maxRelativeFeeBasisPoints,
skipAbsoluteFeeCheck = false,
skipMiningFeeCheck = false,
maxAllowedCredit = liquidityOptions.maxFeeCredit
)
val keyManager = LocalKeyManager(seed.seed, chain, lsp.swapInXpub)
Expand Down Expand Up @@ -309,10 +310,10 @@ class Phoenixd : CliktCommand() {
.collect {
when (val reason = it.reason) {
is LiquidityEvents.Decision.Rejected.Reason.OverMaxCredit -> {
consoleLog(yellow("lightning payment rejected (amount=${it.amount.truncateToSatoshi()}): over max fee credit=${reason.maxAllowedCredit}"))
consoleLog(yellow("lightning payment rejected (amount=${it.amount.truncateToSatoshi()}): over max fee credit (max=${reason.maxAllowedCredit})"))
}
is LiquidityEvents.Decision.Rejected.Reason.TooExpensive.OverAbsoluteFee -> {
consoleLog(yellow("lightning payment rejected (amount=${it.amount.truncateToSatoshi()}): fee=${it.fee.truncateToSatoshi()} > maxFee=${reason.maxAbsoluteFee}"))
is LiquidityEvents.Decision.Rejected.Reason.TooExpensive.OverMaxMiningFee -> {
consoleLog(yellow("lightning payment rejected (amount=${it.amount.truncateToSatoshi()}): over max mining fee (max=${reason.maxMiningFee})"))
}
is LiquidityEvents.Decision.Rejected.Reason.TooExpensive.OverRelativeFee -> {
consoleLog(yellow("lightning payment rejected (amount=${it.amount.truncateToSatoshi()}): fee=${it.fee.truncateToSatoshi()} more than ${reason.maxRelativeFeeBasisPoints.toDouble() / 100}% of amount"))
Expand Down

0 comments on commit 5e1ab0d

Please sign in to comment.