Skip to content

Commit 8abb525

Browse files
Round hold times to decaseconds (#3112)
Hold times in attribution data now use decaseconds instead of milliseconds
1 parent 7b67f33 commit 8abb525

5 files changed

Lines changed: 32 additions & 32 deletions

File tree

docs/release-notes/eclair-vnext.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ See https://github.com/lightning/bolts/pull/1044 for more details.
2222

2323
Attribution data also provides hold times from payment relayers, both for fulfilled and failed HTLCs.
2424

25-
Support is disabled by default as the spec is not yet final.
26-
It can be enabled by setting `eclair.features.option_attribution_data = optional` at the risk of being incompatible with the final spec.
25+
Support is enabled by default.
26+
It can be disabled by setting `eclair.features.option_attribution_data = disabled`.
2727

2828
### API changes
2929

eclair-core/src/main/resources/reference.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ eclair {
7474
option_shutdown_anysegwit = optional
7575
option_dual_fund = optional
7676
option_quiesce = optional
77-
option_attribution_data = disabled
77+
option_attribution_data = optional
7878
option_onion_messages = optional
7979
// This feature should only be enabled when acting as an LSP for mobile wallets.
8080
// When activating this feature, the peer-storage section should be customized to match desired SLAs.

eclair-core/src/main/scala/fr/acinq/eclair/crypto/Sphinx.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ object Sphinx extends Logging {
410410
val previousAttribution = previousAttribution_opt.getOrElse(ByteVector.low(totalLength))
411411
val previousHmacs = getHmacs(previousAttribution).dropRight(1).map(_.drop(1))
412412
val mac = Hmac256(generateKey("um", sharedSecret))
413-
val holdTimes = uint32.encode(holdTime.toMillis).require.bytes ++ previousAttribution.take((maxNumHops - 1) * holdTimeLength)
413+
val holdTimes = uint32.encode(holdTime.toMillis / 100).require.bytes ++ previousAttribution.take((maxNumHops - 1) * holdTimeLength)
414414
val hmacs = computeHmacs(mac, failurePacket_opt.getOrElse(ByteVector.empty), holdTimes, previousHmacs, 0) +: previousHmacs
415415
cipher(holdTimes ++ ByteVector.concat(hmacs.map(ByteVector.concat(_))), sharedSecret)
416416
}
@@ -421,7 +421,7 @@ object Sphinx extends Logging {
421421
*/
422422
def unwrap(encrypted: ByteVector, failurePacket: ByteVector, sharedSecret: ByteVector32, minNumHop: Int): Option[(FiniteDuration, ByteVector)] = {
423423
val bytes = cipher(encrypted, sharedSecret)
424-
val holdTime = uint32.decode(bytes.take(holdTimeLength).bits).require.value.milliseconds
424+
val holdTime = (uint32.decode(bytes.take(holdTimeLength).bits).require.value * 100).milliseconds
425425
val hmacs = getHmacs(bytes)
426426
val mac = Hmac256(generateKey("um", sharedSecret))
427427
if (computeHmacs(mac, failurePacket, bytes.take(maxNumHops * holdTimeLength), hmacs.drop(1), minNumHop) == hmacs.head.drop(minNumHop)) {

0 commit comments

Comments
 (0)