Skip to content

Conversation

accumulator
Copy link
Member

@accumulator accumulator commented Aug 7, 2025

This PR contains initial support for BOLT12

  • parses bolt12 offer payment identifiers,
  • requests bolt12 invoice by sending invoice_request via onion message
  • handles invoice and invoice_error responses
  • initial support for paying bolt12 invoice
    • currently 'abusing' bolt11 data structures like LnAddr, to minimize changes in payment sending code path
    • bolt12 invoice currently stored in Invoice.lightning_invoice with a prefix, because adding a new field to an @attr.s object is a PITA when switching branches, final storage location TBD.

notes w.r.t current state:

  • only first offer_path in offer is queried, iteration of multiple offer_path is TODO
  • only first path in invoice_paths is tried, iteration of multiple path is TODO
  • initial QML GUI is probably outdated
  • initial Qt GUI should be working
  • payments where invoice has no blinded path (introduction point == destination) succeed
  • payments where invoice has blinded path w. >=2 hops fail when testing against CLN, non-final hop however does resolve the next hop, but next hop errors with a invalid HMAC error.
  • calc_hops_data_for_blinded_payment is not computing per-hop fee/amount/cltv values for blinded hops correctly yet.
  • needs gossip enabled, no support for trampoline routing yet.

final_cltv_abs=final_cltv_abs,
total_msat=total_msat,
bolt12_invoice=bolt12_invoice)

Copy link
Member

Choose a reason for hiding this comment

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

bolt12_invoice could be an optional arg

self.payment_key = payment_hash + payment_secret
Logger.__init__(self)

self.bolt12_invoice = bolt12_invoice
Copy link
Member

Choose a reason for hiding this comment

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

apparently unused

"""
erd_key = 'encrypted_data' # used in 'payload' TLV
if tlv_stream_name == 'onionmsg_tlv': # used in 'onionmsg_tlv' TLV
erd_key = 'encrypted_recipient_data'
Copy link
Member

Choose a reason for hiding this comment

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

x = a if t else b

@accumulator accumulator force-pushed the bolt12 branch 4 times, most recently from 92419fc to 59a86cd Compare October 8, 2025 10:49
…ation and schnorr-sign over tlvs,

implicit en/decode utf8 fields, schnorr signature verification.
…ice field, due to inflexibility of

adding fields to @attr.s objects making it hard to use wallets between branches.

TODO: determine final place for bolt12 invoice data in Invoice
add lnonion.calc_hops_data_for_blinded_payment, initial support
for routing to blinded paths in lnpeer, lnworker
…ply_paths.

the former also calculates payinfo information for payment scenarios.
    - offers are not saved and only kept in memory, so only for testing
    - offer_paths are taken from the active channels with peers supporting onion messages
    - only the first channel is included in offer_paths, with the peer as the introduction point
    of the blinded path
    - the offer key is the same as path_id used in the blinded path
    - expiry is included in the offer but ignored elsewhere
@ecdsa
Copy link
Member

ecdsa commented Oct 12, 2025

I have pushed a new version of https://github.com/spesmilo/electrum/commits/test_blinded_payment_onion
This branch adds a unit test for the blinded payment onion creation test vector from the BOLT

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