Commit Graph

401 Commits

Author SHA1 Message Date
Rusty Russell 98d2dc2d4c wire: update to BOLT 17ceba42dc6607b637a713a9bc051f63c1357edd "BOLT 4: onion message support."
We don't need to patch it in anymore, now it's merged.  However, we do
move the message itself from onion_wire.csv to peer_wire.csv (we
should get more sophisticated with our parsing, but this works for
now!).

The resulting peer_wire.csv is identical, the onion_wire.csv file is
slightly reordered.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-20 13:56:46 +09:30
Rusty Russell 4413bfa6be wire: update to BOLT aad959a297ff66946effb165518143be15777dd6 "tools: remove option handling now last optional field was removed."
No effect on us, we didn't use this field anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-20 13:56:46 +09:30
Rusty Russell cfca4e010f common: rename tlv_payload's "blinding_point" to "current_blinding_point" as per spec.
Simple rename in a few internal places.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-20 13:56:46 +09:30
Rusty Russell cc2c720dd9 wire: fix up messy patches (make extract-onion-csv)
These patches are no longer necessary now blinded payments were
merged into the spec.

However, the spec did rename "blinding_point" inside `payload` to
"current_blinding_point" so we temporarily add a patch to change it back.

You can see wire/onion_wire.csv is reordered, but unchanged.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-20 13:56:46 +09:30
Rusty Russell 232fba878e wire: fix up messy patches (make extract-peer-csv)
They didn't actually apply properly!

I regenerated the dual-funding CSV from the latest commit
(091397fc0798c4b2bdb36dbaa9f5b4b1d4a463e1) and made it a single patch.

I tried doing the same for splicing, but the implementation has drifted
far from the spec, so I simply opted for a patch which didn't change anything.

You can see the resulting "wire/peer_wire.csv" is the same, except fields
are now in a less-random order!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-09-20 13:56:46 +09:30
Matt Morehouse 4ef718276f wire: correct argument order 2023-09-18 13:58:45 +09:30
Dusty Daemon 4628e3ace8 channeld: Code to implement splicing
Update the lightningd <-> channeld interface with lots of new commands to needed to facilitate spicing.

Implement the channeld splicing protocol leveraging the interactivetx protocol.

Implement lightningd’s channel_control to support channeld in its splicing efforts.

Changelog-Added: Added the features to enable splicing & resizing of active channels.
2023-07-31 21:00:22 +09:30
niftynei 0cd7fe5089 spec: update to latest dual-funding wire changes
the witnesses are maddeningly weird now (you concat everything together)

we also changed some things to be s64's (it's a teeny tiny change)
2023-07-13 19:34:47 +09:30
Dustin Dettmer aba4d18ed1 signed types: add handlers for signed types
We're adding signed types to the spec! This adds the support mechanisms
for them.
2023-07-13 19:34:47 +09:30
Rusty Russell e7d4c3175a build: remove --enable-experimental-features / EXPERIMENTAL_FEATURES
Changelog-EXPERIMENTAL: Build: all experimental features are now runtime-enabled; no more ./configure --enable-experimental-features
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-05-23 09:34:08 +09:30
Rusty Russell 4deb552fe9 build: don't generate experimental variants of wire files.
We no longer have any experimental-only wire definitions.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-05-23 09:34:08 +09:30
Rusty Russell ccf084156d channeld: use explicit --experimental-upgrade flag, not #ifdef EXPERIMENTAL_FEATURES
And no longer insist on opt_quiesce.

Changelog-EXPERIMENTAL: Config: `--experimental-upgrade-protocol` enables simple channel upgrades.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-05-23 09:34:08 +09:30
Rusty Russell 6c23349c72 channeld: allow stfu based on peer features, not EXPERIMENTAL_FEATURES.
Changelog-EXPERIMENTAL: Config: `--experimental-quiesce` enables queiescence, for testing.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-05-23 09:34:08 +09:30
Rusty Russell e51460be28 wire: remove our own blinded payments patch since it's in spec.
Since this was merged, `make extract-peer-csv` was broken!

But the field names changed:
1. `tlv_update_add_tlvs` -> `tlv_update_add_htlc_tlvs`
2. `blinding` -> `blinding_point`.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-05-23 09:34:08 +09:30
Rusty Russell 15f8e1e63c Makefile: update bolts to 60cfb5972ad4bec4c49ee0f9e729fb3352fcdc6a.
"BOLT 4: Remove legacy format, make var_onion_optin compulsory."

This also renamed the redundant "tlv_payload" to "payload", so we
replace "tlv_tlv_payload" with "tlv_payload" everyhere!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-04-07 21:22:56 +09:30
Rusty Russell 06d42694d5 wire: fix extracted patch.
Too much context, it didn't apply if you try to rebuild from source!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-04-07 21:22:56 +09:30
Rusty Russell 2005ca436e common/gossmap: don't memcpy NULL, 0, and don't add 0 to NULL pointer.
Of course, NULL and length 0 are natural partners, but We Can't Have Nice Things.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2023-04-05 06:12:24 +09:30
adi2011 66d98c327f peer_wire_is_internal helper.
We are now going to have messages which we know about, but yet we
don't handle ourselves.

[ I reversed this from Adi's, as that was clearer! --RR ]
2023-02-08 08:37:59 -06:00
adi2011 5f481aaf96 wire: Add patch file for peer storage bkp
Add msg type peer_storage and your_peer_storage
2023-02-08 08:37:59 -06:00
niftynei f465032f6f rfc-dual-fund: update to latest spec for dual-funding
- Renamed zerod_channel_ids to temporary_channel_id
- Renamed witness_stack->witnesses
- Renamed witness_element->witness_elements
- open_channel2 now includes second commitment point
- accept_channel2 now includes second commitment point

Current commit on rfc branch 64f7f360b9f3c2664d078e2129cfe83098fc4617

Changelog-EXPERIMENTAL: Protocol: dual-funding spec changed in incompatible ways, won't work with old versions (but maybe soon with Eclair!!)
2023-02-08 15:04:27 +10:30
niftynei 739d3c7b47 v2 open: if flagged, check that all our inputs are confirmed
not amazing, since we'll probably call openchannel_update multiple
times per open, but this is the simplest way to confirm that we're
not sending unconfirmed outputs to peer.
2023-02-07 21:03:36 -06:00
niftynei 4da0d6230e dual-fund: update to latest, add in updates to rbf amounts
You can now pick a different amount during the RBF phase
2023-02-04 15:31:16 +10:30
Michael Schmoock ad249607d6 dual-fund: update extracted CSVs to latest bolt draft
Changelog-None
2023-02-04 15:31:16 +10:30
Rusty Russell da3506e6a0 wire: use correct number of update_add_tlvs blinding field.
See: #5823
Reported-by: @t-bast
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-EXPERIMENTAL: `offers` breaking blinded payments change (update_add_tlvs fix, Eclair compat)
2023-01-30 13:24:29 +10:30
Rusty Russell 179f573e45 lightningd/invoice.c, plugins/fetchinvoice.c: use tlv_make_fields() instead of towire/fromwire hack.
I forgot this existed!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-11-09 15:08:03 +01:00
Rusty Russell 1e3cb01546 bolt12: import the latest spec, update to fit.
I know this is an unforgivably large diff, but the spec has changed so
much that most of this amounts to a rewrite.

Some points:
* We no longer have "offer_id" fields, we generate that locally, as all
  offer fields are mirrored into invoice_request and then invoice.
* Because of that mirroring, field names all have explicit offer/invreq/invoice
  prefixes.
* The `refund_for` fields have been removed from spec: will re-add locally later.
* quantity_min was removed, max == 0 now mean "must specify a quantity".
* I have put recurrence fields back in locally.

This brings us to 655df03d8729c0918bdacac99eb13fdb0ee93345 ("BOLT 12:
add explicit invoice_node_id.")

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-11-09 15:08:03 +01:00
Rusty Russell a4c482dc07 common/sphinx: don't use fixed lengths anywhere.
1. Remove the very concept of ONION_REPLY_SIZE, instead make it a
   local variable in create_onionreply().

2. Use the proper fromwire_ primitives in unwrap_onionreply() so we
   don't have to do explicit length checks.

3. Make fromwire_tal_arrn() return NULL if it fails to pull, instead of
   a zero-length allocation.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: Protocol: we now correctly decrypt non-256-length onion errors (we always forwarded them fine, now we actually can parse them).
2022-11-08 17:40:57 +01:00
Rusty Russell f158b529d3 wire/Makefile: fix missing wire/bolt12_exp_wiregen.c in ALL_C_SOURCES.
And add it as a requirement to the test programs!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-10-26 11:29:06 +10:30
Rusty Russell 5cf86a1a2e common: update to latest onion message spec.
Mainly, field name changes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-EXPERIMENTAL: Protocol: Support for forwarding blinded payments (as per latest draft)
2022-10-26 11:29:06 +10:30
Rusty Russell 8eee5dd7fd channeld, lightningd: allow blinded payments with !EXPERIMENTAL_FEATURES.
Gate it (where necessary) by the route-blinding feature bit.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-10-26 11:29:06 +10:30
Rusty Russell 426886ff9b lightningd: return invalid_onon_blinding for any blinded payment error.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-10-26 11:29:06 +10:30
Rusty Russell 56939295de wire: add latest Route Blinding htlc fields from https://github.com/lightning/bolts/pull/765
This is as of commit aed5518a80aade56218da87f92e0a39963b660cf

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-10-26 11:29:06 +10:30
Rusty Russell 662c6931f3 Remove point32.
The x-only dream is dead.  Remove all trace.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-10-26 11:29:06 +10:30
Rusty Russell e30ea91908 BOLTs: update to more recent bolt12 spec.
It's 2b7ad577d7a790b302bd1aa044b22c809c76e49d, which reverts the
point32 changes.

It also restores send_invoice in `invoice`, which we had removed
from spec and put into the recurrence patch.

I originally had implemented compatibility, but other changes
which followed this are far too widespread.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-EXPERIMENTAL: offers: complete rework of spec from other teams (yay!) breaks previous compatibility (boo!)
2022-10-26 11:29:06 +10:30
Rusty Russell eac8401f84 Makefile: separate bolt12 wireobjects
Most things don't want them, so don't link it into everything by default.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-10-26 11:29:06 +10:30
Rusty Russell 41ef85318d onionmessages: remove obsolete onion message parsing.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-29 16:10:57 +09:30
Rusty Russell 253b25522b BOLT: update to version which requires option_channel_htlc_max.
We will now simply reject old-style ones as invalid.  Turns out the
only trace we could find is a channel between two nodes unconnected to
the rest of the network.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: Protocol: We now require all channel_update messages include htlc_maximum_msat (as per latest BOLTs)
2022-09-24 15:22:27 +09:30
Rusty Russell 2da5244e83 jsonrpc: make error codes an enum.
This allows GDB to print values, but also allows us to use them in
'case' statements.  This wasn't allowed before because they're not
constant terms.

This also made it clear there's a clash between two error codes,
so move one.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: JSON-RPC: Error code from bcli plugin changed from 400 to 500.
2022-09-19 10:18:55 +09:30
Rusty Russell 2ac775f9f4 lightningd: fix crash with -O3 -flto.
It's foolish to ban passing NULL, 0 to memcpy, memset et al, but
it's been done.  At high level of optimization, GCC assumes this doesn't
happen, and yep, assumes "if (ctx)" inside tal_free() must be true.

So when a psbt is NULL, and psbt_get_bytes returns NULL, a crash ensues:

```
lightningd: FATAL SIGNAL 6 (version v0.12.0rc2-6-g47efa5d-modded)
0x5557dfc42fef send_backtrace
	common/daemon.c:33
0x5557dfc42fef crashdump
	common/daemon.c:46
0x7fe93ef5851f ???
	./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x7fe93efaca7c __pthread_kill_implementation
	./nptl/pthread_kill.c:44
0x7fe93efaca7c __pthread_kill_internal
	./nptl/pthread_kill.c:78
0x7fe93efaca7c __GI___pthread_kill
	./nptl/pthread_kill.c:89
0x7fe93ef58475 __GI_raise
	../sysdeps/posix/raise.c:26
0x7fe93ef3e7f2 __GI_abort
	./stdlib/abort.c:79
0x5557dfbb0c28 call_error
	ccan/ccan/tal/tal.c:93
0x5557dfbb0c34 check_bounds
	ccan/ccan/tal/tal.c:165
0x5557dfbb0c34 to_tal_hdr
	ccan/ccan/tal/tal.c:178
0x5557dfc7a1d3 tal_free
	ccan/ccan/tal/tal.c:482
0x5557dfc609d3 tal_free
	ccan/ccan/tal/tal.c:477
0x5557dfc609d3 towire_wally_psbt
	bitcoin/psbt.c:743
0x5557dfbc5dfc towire_dualopend_got_offer_reply
	openingd/dualopend_wiregen.c:358
0x5557dfbc5dfc openchannel2_hook_cb
	lightningd/dual_open_control.c:671
0x5557dfc22f4f plugin_hook_callback
	lightningd/plugin_hook.c:210
0x5557dfc1dfbe plugin_response_handle
	lightningd/plugin.c:591
0x5557dfc1dfbe plugin_read_json_one
	lightningd/plugin.c:702
0x5557dfc1dfbe plugin_read_json
	lightningd/plugin.c:747
0x5557dfc71756 next_plan
	ccan/ccan/io/io.c:59
0x5557dfc775d5 io_ready
	ccan/ccan/io/io.c:417
0x5557dfc775d5 io_loop
	ccan/ccan/io/poll.c:453
0x5557dfbdb1ce io_loop
	ccan/ccan/io/poll.c:380
0x5557dfbdb1ce io_loop_with_timers
	lightningd/io_loop_with_timers.c:22
0x5557dfbb37d1 main
	lightningd/lightningd.c:1195
0x7fe93ef3fd8f __libc_start_call_main
	../sysdeps/nptl/libc_start_call_main.h:58
0x7fe93ef3fe3f __libc_start_main_impl
	../csu/libc-start.c:392
0x5557dfbb6e84 ???
	???:0
0xffffffffffffffff ???
	???:0
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-12 14:00:41 +02:00
Rusty Russell 1b30ea4b82 doc: update BOLTs to bc86304b4b0af5fd5ce9d24f74e2ebbceb7e2730
This contains the zeroconf stuff, with funding_locked renamed to
channel_ready.  I change that everywhere, and try to fix up the
comments.

Also the `alias` field is called `short_channel_id`.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: Protocol: `funding_locked` is now called `channel_ready` as per latest BOLTs.
2022-09-12 09:34:52 +09:30
Rusty Russell 341bbdfcbe doc: increase BOLT level to 03468e17563650fb9bfe58b2da4d1e5d28e92009
`flags` in `channel_disabled` gets renamed.  We don't use it anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-12 09:34:52 +09:30
Rusty Russell a56b17c759 wire/test: neaten and complete tlv checks.
In particular, we didn't check the remote_addr in the init msg.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-12 09:34:52 +09:30
Rusty Russell e0259b246e test: fix tlvs test in funding_locked tlv.
This FIXME caught my eye, as it's wrong: TLVs are canonical, so they cannot
differ in bits and be equal.

The equality function needs to be written correctly, however, otherwise it
will crash!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-12 09:34:52 +09:30
Alex Myers ddf8fbdb5d gossipd: fix crash from gossip_store v10 changes
routing.c fixed to properly remove rate-limited gossip_store entries
when channels are closed. This caused gossipd to crash on a subsequent
gossip_store_load. Also corrects an overzealous limit of one gossip_store
entry per message (should now allow one broadcastable and one
rate-limited). Addresses issues 5387, 5395.

Changelog-None
2022-07-12 14:18:06 +09:30
Christian Decker 9d3cb95489 wire: Add funding_locked tlv patch from PR lightning/bolts#910
Minimal set of changes to update the peer_wire.csv to include the TLV
field in the `funding_locked` message, and add type 1=alias from that
PR too.
2022-07-04 22:14:06 +02:00
Vincenzo Palazzo 7ff62b4a00 lightnind: remove`DEFAULT_PORT` global definition
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2022-06-28 06:09:01 +09:30
Rusty Russell 7c8dc62035 channeld: take over gossip_rcvd_filter.c and is_msg_gossip_broadcast.
channeld is the only user of these functions, since it now streams
all gossip itself.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-06-17 14:14:02 +09:30
Rusty Russell abd01a1701 Makefile: update to include fix for remote_addr generation.
Now it's formatted properly, we don't need the patch.

But we need to explicitly marshal/unmarshal into a byte stream,
which involves some code rearrangement.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-05-19 09:47:32 +09:30
Rusty Russell 836c1b805b doc: update c-lightning to Core Lightning almost everywhere.
Mostly comments and docs: some places are actually paths, which
I have avoided changing.  We may migrate them slowly, particularly
when they're user-visible.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-04-07 06:53:26 +09:30
Rusty Russell e01abf0b34 bolt11: support payment_metadata.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-04-02 09:40:18 +10:30