Skip to content

Commit dca343f

Browse files
committed
closingd: add lightning_simpleclosed for option_simple_close
New subdaemon implementing the BOLT2 simple close protocol, replacing `lightning_closingd` when `option_simple_close` is negotiated: - Each peer independently sends `closing_complete` with their fee proposal; - The other side signs it and sends `closing_sig`; - Both sides broadcast two conflicting closing transactions and whichever confirms first wins. Key protocol details: - Closer pays the fee and closee receives their exact channel balance; - TLV variants selected per BOLT2: `closer_output_only`, `closer_and_closee_outputs`, `closee_output_only`; - Sequence 0xFFFFFFFD enables RBF via re-sending `closing_complete`; - Script mismatch on `closee_scriptpubkey` warns and fails to reconnect; common/shutdown_scriptpubkey.h/c: removed `static` from `is_valid_op_return` so it can be used in `simpleclosed.c`
1 parent 111c0ec commit dca343f

5 files changed

Lines changed: 841 additions & 6 deletions

File tree

closingd/Makefile

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,26 @@ CLOSINGD_SRC := closingd/closingd.c \
88
CLOSINGD_OBJS := $(CLOSINGD_SRC:.c=.o)
99
$(CLOSINGD_OBJS): $(CLOSINGD_HEADERS)
1010

11+
# Simple close daemon
12+
SIMPLECLOSED_HEADERS := closingd/simpleclosed_wiregen.h
13+
14+
SIMPLECLOSED_SRC := closingd/simpleclosed.c \
15+
$(SIMPLECLOSED_HEADERS:.h=.c)
16+
17+
SIMPLECLOSED_OBJS := $(SIMPLECLOSED_SRC:.c=.o)
18+
$(SIMPLECLOSED_OBJS): $(SIMPLECLOSED_HEADERS)
19+
1120
# Make sure these depend on everything.
12-
ALL_C_SOURCES += $(CLOSINGD_SRC)
13-
ALL_C_HEADERS += $(CLOSINGD_HEADERS)
14-
ALL_PROGRAMS += lightningd/lightning_closingd
21+
ALL_C_SOURCES += $(CLOSINGD_SRC) $(SIMPLECLOSED_SRC)
22+
ALL_C_HEADERS += $(CLOSINGD_HEADERS) $(SIMPLECLOSED_HEADERS)
23+
ALL_PROGRAMS += lightningd/lightning_closingd lightningd/lightning_simpleclosed
1524

1625
# Here's what lightningd depends on
17-
LIGHTNINGD_CONTROL_HEADERS += closingd/closingd_wiregen.h
18-
LIGHTNINGD_CONTROL_OBJS += closingd/closingd_wiregen.o
26+
LIGHTNINGD_CONTROL_HEADERS += closingd/closingd_wiregen.h closingd/simpleclosed_wiregen.h
27+
LIGHTNINGD_CONTROL_OBJS += closingd/closingd_wiregen.o closingd/simpleclosed_wiregen.o
1928

2029
lightningd/lightning_closingd: $(CLOSINGD_OBJS) $(HSMD_CLIENT_OBJS) libcommon.a
2130

31+
lightningd/lightning_simpleclosed: $(SIMPLECLOSED_OBJS) $(HSMD_CLIENT_OBJS) libcommon.a
32+
2233
-include closingd/test/Makefile

0 commit comments

Comments
 (0)