Skip to content

bolt12: preparation 1#10546

Merged
SomberNight merged 10 commits intospesmilo:masterfrom
f321x:bolt12_preparation_1
Apr 20, 2026
Merged

bolt12: preparation 1#10546
SomberNight merged 10 commits intospesmilo:masterfrom
f321x:bolt12_preparation_1

Conversation

@f321x
Copy link
Copy Markdown
Member

@f321x f321x commented Mar 25, 2026

the bolt12 branch is getting large, so i cherry picked some commits that can already be reviewed and merged into master step by step. these are mostly onion message changes.

@f321x f321x force-pushed the bolt12_preparation_1 branch 6 times, most recently from 4ed0aed to efa2a14 Compare March 30, 2026 10:55
@f321x f321x marked this pull request as ready for review March 30, 2026 12:25
accumulator and others added 10 commits April 1, 2026 09:07
…ply_paths.

the former also calculates payinfo information for payment scenarios.
include payment_relay struct for payment blinded_paths.
Add unittest to test the payment path of get_blinded_paths_to_me
Mock LNWallet._add_peer so direct connection fallbacks don't
cause an exception.
This allows restricting blinded paths to channels that have sufficient receive
capacity for payment.

NOTE: this might have privacy issues, as this can be used to probe channel capacity.
Maybe randomize leeway?

@f321x: changed to use scid alias in create_blinded_path
Factor out code from `send_onion_message_to` into a separate
function `_create_route_to_introduction_point` to make it
easier to reason about it and more testable.
Don't include first hop of the path,
this is the hop from us to the first node and we don't
need a payload for ourselves.

Also adds unittest checking this.
@f321x f321x force-pushed the bolt12_preparation_1 branch from efa2a14 to 4254c9a Compare April 1, 2026 07:08
Copy link
Copy Markdown
Member

@SomberNight SomberNight left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks!

Comment thread electrum/onion_message.py
Comment on lines +432 to +433
# randomize list
rchans = sorted(my_channels, key=lambda x: random())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

minor nit, no need to fix here, just wanted to pitch:
rchans = util.random_shuffled_copy(my_channels)
((1) perhaps easier to read; (2) random.shuffle probably uses a Fisher-Yates shuffle, so takes linear time, while sorting is n*log(n))

electrum/electrum/util.py

Lines 2240 to 2244 in 16c8cb5

def random_shuffled_copy(x: Iterable[T]) -> List[T]:
"""Returns a shuffled copy of the input."""
x_copy = list(x) # copy
random.shuffle(x_copy) # shuffle in-place
return x_copy

Comment thread electrum/onion_message.py
Comment on lines +666 to +671
# get next path (round robin)
dests = req.node_id_or_blinded_paths
if isinstance(req.node_id_or_blinded_paths, bytes):
dests = [req.node_id_or_blinded_paths]
dest = dests[req.current_index]
req.current_index = (req.current_index + 1) % len(dests)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could be a method of Request that returns dest and internally mutates current_index.

@SomberNight SomberNight merged commit b45d89e into spesmilo:master Apr 20, 2026
15 of 17 checks passed
@f321x f321x deleted the bolt12_preparation_1 branch April 20, 2026 15:10
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