From efe0ac13b019efbf96fbbbdd2521590d3d59fca4 Mon Sep 17 00:00:00 2001 From: Thomas HUET <81159533+thomash-acinq@users.noreply.github.com> Date: Wed, 10 Jul 2024 16:57:53 +0200 Subject: [PATCH] Add log when sending BOLT 12 invoice (#684) Log relevant fields when we send an invoice as a reply to an invoice request. --- .../kotlin/fr/acinq/lightning/payment/OfferManager.kt | 5 ++++- .../kotlin/fr/acinq/lightning/wire/LightningMessages.kt | 3 +++ .../kotlin/fr/acinq/lightning/wire/OnionRouting.kt | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/commonMain/kotlin/fr/acinq/lightning/payment/OfferManager.kt b/src/commonMain/kotlin/fr/acinq/lightning/payment/OfferManager.kt index acf60ef53..1d0aa5b2d 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/payment/OfferManager.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/payment/OfferManager.kt @@ -183,7 +183,10 @@ class OfferManager(val nodeParams: NodeParams, val walletParams: WalletParams, v logger.warning { "offerId:${offer.offerId} pathId:${decrypted.pathId} ignoring invoice request, could not build onion message: ${invoiceMessage.value}" } sendInvoiceError("failed to build onion message", decrypted.content.replyPath) } - is Right -> OnionMessageAction.SendMessage(invoiceMessage.value) + is Right -> { + logger.info { "sending BOLT 12 invoice with amount=${invoice.amount}, paymentHash=${invoice.paymentHash}, payerId=${invoice.invoiceRequest.payerId} to introduction node ${destination.route.introductionNodeId}" } + OnionMessageAction.SendMessage(invoiceMessage.value) + } } } } diff --git a/src/commonMain/kotlin/fr/acinq/lightning/wire/LightningMessages.kt b/src/commonMain/kotlin/fr/acinq/lightning/wire/LightningMessages.kt index f314e2cec..48db001c1 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/wire/LightningMessages.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/wire/LightningMessages.kt @@ -1587,6 +1587,9 @@ data class OnionMessage( OnionRoutingPacketSerializer(onionRoutingPacket.payload.size()).write(onionRoutingPacket, out) } + override fun toString(): String = + "OnionMessage(blindingKey=$blindingKey, onionRoutingPacket=OnionRoutingPacket(version=${onionRoutingPacket.version}, publicKey=${onionRoutingPacket.publicKey.toHex()}, payload=<${onionRoutingPacket.payload.size()} bytes>, hmac=${onionRoutingPacket.hmac.toHex()}))" + companion object : LightningMessageReader { const val type: Long = 513 diff --git a/src/commonMain/kotlin/fr/acinq/lightning/wire/OnionRouting.kt b/src/commonMain/kotlin/fr/acinq/lightning/wire/OnionRouting.kt index 13fc115c5..99cda8beb 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/wire/OnionRouting.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/wire/OnionRouting.kt @@ -12,9 +12,9 @@ import fr.acinq.lightning.utils.toByteVector32 data class OnionRoutingPacket( val version: Int, - val publicKey: ByteVector, - val payload: ByteVector, - val hmac: ByteVector32 + val publicKey: ByteVector, + val payload: ByteVector, + val hmac: ByteVector32 ) { companion object { const val PaymentPacketLength = 1300