Skip to content

Commit bfe34ab

Browse files
authored
Use 73 bytes der-encoded signatures in weight estimation (#3210)
While 73 bytes der-encoded signatures aren't standard (they're only possible with high-S signatures), miners could accept such signatures. Most of our tests use 72 bytes der-encoded signatures because we will never generate 73 bytes der-encoded signatures ourselves. But it's more safe to use a 73 bytes signature in our weight estimation because: - it's what the BOLTs recommend - it's what other implementations use (e.g. LDK) which means they may reject our interactive-tx attempts by thinking we're under-paying fees
1 parent 5e1a488 commit bfe34ab

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

eclair-core/src/main/scala/fr/acinq/eclair/transactions/Transactions.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ object Transactions {
9797
}
9898

9999
sealed trait SegwitV0CommitmentFormat extends CommitmentFormat {
100-
override val fundingInputWeight = 384
100+
// see https://github.com/lightning/bolts/blob/master/03-transactions.md#appendix-a-expected-weights
101+
// funding input weight = 4 * funding_input_size + witness_size = 4 * 41 + 222 = 386
102+
override val fundingInputWeight = 386
101103
}
102104

103105
/**

eclair-core/src/test/scala/fr/acinq/eclair/transactions/TransactionsSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ class TransactionsSpec extends AnyFunSuite with Logging {
152152
case _: SimpleTaprootChannelCommitmentFormat => assert(actual == expected)
153153
case _: AnchorOutputsCommitmentFormat =>
154154
// ECDSA signatures are der-encoded, which creates some variability in signature size compared to the baseline.
155-
assert(actual <= expected + 3)
156-
assert(actual >= expected - 3)
155+
assert(actual <= expected + 4)
156+
assert(actual >= expected - 4)
157157
}
158158
}
159159

0 commit comments

Comments
 (0)