Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add log when sending BOLT 12 invoice #684

Merged
merged 2 commits into from
Jul 10, 2024
Merged

Add log when sending BOLT 12 invoice #684

merged 2 commits into from
Jul 10, 2024

Conversation

thomash-acinq
Copy link
Member

@thomash-acinq thomash-acinq commented Jul 10, 2024

Log relevant fields when we send an invoice as a reply to an invoice request.

Copy link
Member

@t-bast t-bast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's something else that we should fix in this PR: at the beginning of processEvent in Peer.kt, in the handler for MessageReceived, we log the whole incoming message (msg.let { if (it !is Ping && it !is Pong) logger.info { "received $it" } }). This is an issue for onion messages which can be up to 65kB and fill the logs very quickly.

Can you update this to avoid logging the onion itself? It's not useful as we can't easily decrypt it for support anyway. I don't know if simply overriding the toString() on OnionMessage is enough or if we need a specific case in Peer.kt, I'll let you test that.

@@ -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 for ${invoice.amount} to introduction node ${destination.route.introductionNodeId}" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also log the whole invoice? This way we have everything we need to troubleshoot potential issues.
It shouldn't be too spammy.

Suggested change
logger.info { "sending BOLT 12 invoice for ${invoice.amount} to introduction node ${destination.route.introductionNodeId}" }
logger.info { "sending BOLT 12 invoice for ${invoice.amount} to introduction node ${destination.route.introductionNodeId} (invoice=${invoice.toString()})" }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it but the invoice can be very big as we copy all fields from the invoice request. An attacker could make the invoice as large as the largest onion message. Do you still think we should log it?
I would be more comfortable adding specific fields.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hesitated exactly because of that...it's true that the invoice_request can be arbitrarily big because of the padding TLV. Let me check what other fields may be useful for debugging.

Copy link
Member

@t-bast t-bast Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, there are a lot of things that aren't very useful for debugging, let's just also include paymentHash and payerId and we should have the most useful fields!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can just truncate the invoice at a fixed length? That should be enough for debugging normal users

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That wouldn't be useful, if we truncate it we can't decode it...

@thomash-acinq thomash-acinq merged commit efe0ac1 into master Jul 10, 2024
2 checks passed
@thomash-acinq thomash-acinq deleted the more-logs branch July 10, 2024 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants