Files
palladum-lightning/channeld/channeld_wire.csv
Dusty Daemon a8ff8ce717 splice: Add field to DB to track if we’ve sent sigs
We used to use a check on the active psbt to see if our splice signature was in it — but now we need to generate the signature early.

So we have to add a field tracking if we’ve sent it and add it to the database, wire protocols, and inflight objects.
2025-08-14 04:12:17 +09:30

15 KiB

1#include <bitcoin/psbt.h>
2#include <bitcoin/tx.h>
3#include <channeld/inflight.h>
4#include <common/bip32.h>
5#include <common/blockheight_states.h>
6#include <common/cryptomsg.h>
7#include <common/channel_config.h>
8#include <common/channel_id.h>
9#include <common/channel_type.h>
10#include <common/derive_basepoints.h>
11#include <common/features.h>
12#include <common/fee_states.h>
13#include <wire/peer_wire.h>
14# Begin! (passes gossipd-client fd)
15msgtypechanneld_init1000
16msgdatachanneld_initchainparamschainparams
17msgdatachanneld_initour_featuresfeature_set
18msgdatachanneld_initnum_hsm_capabilitiesu16
19msgdatachanneld_inithsm_capabilitiesu32num_hsm_capabilities
20msgdatachanneld_initchannel_idchannel_id
21msgdatachanneld_initfundingbitcoin_outpoint
22msgdatachanneld_initfunding_satoshiamount_sat
23msgdatachanneld_initminimum_depthu32
24msgdatachanneld_initour_blockheightu32
25msgdatachanneld_initblockheight_statesheight_states
26msgdatachanneld_initlease_expiryu32
27msgdatachanneld_initour_configchannel_config
28msgdatachanneld_inittheir_configchannel_config
29msgdatachanneld_initfee_statesfee_states
30msgdatachanneld_initfeerate_minu32
31msgdatachanneld_initfeerate_maxu32
32msgdatachanneld_initfeerate_penaltyu32
33msgdatachanneld_initfirst_commit_sigbitcoin_signature
34msgdatachanneld_initremote_fundingkeypubkey
35msgdatachanneld_initremote_basepointsbasepoints
36msgdatachanneld_initremote_per_commitpubkey
37msgdatachanneld_initold_remote_per_commitpubkey
38msgdatachanneld_initopenerenum side
39msgdatachanneld_initlocal_msatoshiamount_msat
40msgdatachanneld_initour_basepointsbasepoints
41msgdatachanneld_initour_funding_pubkeypubkey
42msgdatachanneld_initcommit_msecu32
43msgdatachanneld_initlast_was_revokebool
44msgdatachanneld_initnum_last_sent_commitu16
45msgdatachanneld_initlast_sent_commitchanged_htlcnum_last_sent_commit
46msgdatachanneld_initnext_index_localu64
47msgdatachanneld_initnext_index_remoteu64
48msgdatachanneld_initrevocations_receivedu64
49msgdatachanneld_initnext_htlc_idu64
50msgdatachanneld_initnum_existing_htlcsu16
51msgdatachanneld_inithtlcsexisting_htlcnum_existing_htlcs
52msgdatachanneld_initlocal_channel_readybool
53msgdatachanneld_initremote_channel_readybool
54msgdatachanneld_initfunding_short_idshort_channel_id
55msgdatachanneld_initreestablishbool
56msgdatachanneld_initsend_shutdownbool
57msgdatachanneld_initremote_shutdown_receivedbool
58msgdatachanneld_initfinal_indexu32
59msgdatachanneld_initfinal_ext_keyext_key
60msgdatachanneld_initfinal_scriptpubkey_lenu16
61msgdatachanneld_initfinal_scriptpubkeyu8final_scriptpubkey_len
62msgdatachanneld_initflagsu8
63msgdatachanneld_initinit_peer_pkt_lenu16
64msgdatachanneld_initinit_peer_pktu8init_peer_pkt_len
65msgdatachanneld_initlast_remote_secretsecret
66msgdatachanneld_initflenu16
67msgdatachanneld_inittheir_featuresu8flen
68msgdatachanneld_initupfront_shutdown_script_lenu16
69msgdatachanneld_initupfront_shutdown_scriptu8upfront_shutdown_script_len
70msgdatachanneld_initdesired_typechannel_type
71msgdatachanneld_initdev_disable_commit?u32
72msgdatachanneld_initnum_penalty_basesu32
73msgdatachanneld_initpbasespenalty_basenum_penalty_bases
74msgdatachanneld_initnum_inflightsu16
75msgdatachanneld_initinflightsinflightnum_inflights
76msgdatachanneld_initscid_aliasshort_channel_id
77# channeld->lightningd: successfully negotated reestablishment.
78msgtypechanneld_reestablished1101
79# master->channeld funding hit new depth(funding locked if >= lock depth)
80# short_channel_id != NULL once we have 3+ confirmations
81msgtypechanneld_funding_depth1002
82msgdatachanneld_funding_depthshort_channel_id?short_channel_id
83msgdatachanneld_funding_depthdepthu32
84msgdatachanneld_funding_depthsplicingbool
85msgdatachanneld_funding_depthtxidbitcoin_txid
86# Tell channel to offer this htlc
87msgtypechanneld_offer_htlc1004
88msgdatachanneld_offer_htlcamount_msatamount_msat
89msgdatachanneld_offer_htlccltv_expiryu32
90msgdatachanneld_offer_htlcpayment_hashsha256
91msgdatachanneld_offer_htlconion_routing_packetu81366
92msgdatachanneld_offer_htlcpath_key?pubkey
93# Reply; synchronous since IDs have to increment.
94msgtypechanneld_offer_htlc_reply1104
95msgdatachanneld_offer_htlc_replyidu64
96# Empty failure message means success.
97msgdatachanneld_offer_htlc_replylenu16
98msgdatachanneld_offer_htlc_replyfailuremsgu8len
99msgdatachanneld_offer_htlc_replyfailurestrwirestring
100# Main daemon found out the preimage for an HTLC
101#include <bitcoin/preimage.h>
102msgtypechanneld_fulfill_htlc1005
103msgdatachanneld_fulfill_htlcfulfilled_htlcfulfilled_htlc
104# Main daemon says HTLC failed
105msgtypechanneld_fail_htlc1006
106msgdatachanneld_fail_htlcfailed_htlcfailed_htlc
107# When we receive channel_ready.
108msgtypechanneld_got_channel_ready1019
109msgdatachanneld_got_channel_readynext_per_commit_pointpubkey
110msgdatachanneld_got_channel_readyalias?short_channel_id
111# When we receive funding_locked.
112msgtypechanneld_got_splice_locked1119
113msgdatachanneld_got_splice_lockedfunding_satsamount_sat
114msgdatachanneld_got_splice_lockedsplice_amnts64
115msgdatachanneld_got_splice_lockedlocked_txidbitcoin_txid
116#include <common/penalty_base.h>
117subtypelocal_anchor_info
118subtypedatalocal_anchor_infocommitment_weightu32
119subtypedatalocal_anchor_infocommitment_feeamount_sat
120subtypedatalocal_anchor_infoanchor_pointbitcoin_outpoint
121# lightningd needs to track our anchor outputs on remote txs.
122# This includes splicesso there could be more than one!
123msgtypechanneld_local_anchor_info1003
124msgdatachanneld_local_anchor_inforemote_commitnumu64
125msgdatachanneld_local_anchor_infonum_anchorsu16
126msgdatachanneld_local_anchor_infoanchorslocal_anchor_infonum_anchors
127# When we send a commitment_signed messagetell master.
128msgtypechanneld_sending_commitsig1020
129msgdatachanneld_sending_commitsigcommitnumu64
130msgdatachanneld_sending_commitsigpbase?penalty_base
131msgdatachanneld_sending_commitsigfee_statesfee_states
132msgdatachanneld_sending_commitsigblockheight_statesheight_states
133# SENT_ADD_COMMITSENT_REMOVE_ACK_COMMITSENT_ADD_ACK_COMMITSENT_REMOVE_COMMIT
134msgdatachanneld_sending_commitsignum_changedu16
135msgdatachanneld_sending_commitsigchangedchanged_htlcnum_changed
136# Wait for replyto make sure it's on disk before we send commit.
137msgtypechanneld_sending_commitsig_reply1120
138# When we have a commitment_signed messagetell master to remember.
139msgtypechanneld_got_commitsig1021
140msgdatachanneld_got_commitsigcommitnumu64
141msgdatachanneld_got_commitsigfee_statesfee_states
142msgdatachanneld_got_commitsigblockheight_statesheight_states
143msgdatachanneld_got_commitsigsignaturebitcoin_signature
144msgdatachanneld_got_commitsignum_htlcsu16
145msgdatachanneld_got_commitsightlc_signaturebitcoin_signaturenum_htlcs
146# RCVD_ADD_COMMIT: we're now committed to their new offered HTLCs.
147msgdatachanneld_got_commitsignum_addedu16
148msgdatachanneld_got_commitsigaddedadded_htlcnum_added
149# RCVD_REMOVE_COMMIT: we're now no longer committed to these HTLCs.
150msgdatachanneld_got_commitsignum_fulfilledu16
151msgdatachanneld_got_commitsigfulfilledfulfilled_htlcnum_fulfilled
152msgdatachanneld_got_commitsignum_failedu16
153msgdatachanneld_got_commitsigfailedfailed_htlcnum_failed
154# RCVD_ADD_ACK_COMMITRCVD_REMOVE_ACK_COMMIT
155msgdatachanneld_got_commitsignum_changedu16
156msgdatachanneld_got_commitsigchangedchanged_htlcnum_changed
157msgdatachanneld_got_commitsigtxbitcoin_tx
158# Inflight splice commitments
159msgdatachanneld_got_commitsignum_inflight_commitsigsu16
160msgdatachanneld_got_commitsiginflight_commitsigscommitsignum_inflight_commitsigs
161subtypecommitsig
162subtypedatacommitsigtxbitcoin_tx
163subtypedatacommitsigcommit_signaturebitcoin_signature
164subtypedatacommitsignum_htlcsu16
165subtypedatacommitsightlc_signaturesbitcoin_signaturenum_htlcs
166# Wait for replyto make sure it's on disk before we send revocation.
167msgtypechanneld_got_commitsig_reply1121
168#include <common/htlc_wire.h>
169msgtypechanneld_got_revoke1022
170msgdatachanneld_got_revokerevokenumu64
171msgdatachanneld_got_revokeper_commitment_secretsecret
172msgdatachanneld_got_revokenext_per_commit_pointpubkey
173# RCVD_ADD_ACK_REVOCATIONRCVD_REMOVE_ACK_REVOCATIONRCVD_ADD_REVOCATIONRCVD_REMOVE_REVOCATION
174msgdatachanneld_got_revokefee_statesfee_states
175msgdatachanneld_got_revokeblockheight_statesheight_states
176msgdatachanneld_got_revokenum_changedu16
177msgdatachanneld_got_revokechangedchanged_htlcnum_changed
178msgdatachanneld_got_revokepbase?penalty_base
179msgdatachanneld_got_revokepenalty_tx?bitcoin_tx
180# Wait for replyto make sure it's on disk before we continue
181# (eg. if we sent another commitment_signedthat would implicitly ack).
182msgtypechanneld_got_revoke_reply1122
183#include <wally_bip32.h>
184# master->channeld: helloI'd like to start a channel splice open
185msgtypechanneld_splice_init7204
186msgdatachanneld_splice_initpsbtwally_psbt
187msgdatachanneld_splice_initrelative_amounts64
188msgdatachanneld_splice_initfeerate_per_kwu32
189msgdatachanneld_splice_initforce_feeratebool
190msgdatachanneld_splice_initskip_stfubool
191# channeld->master: helloI started a channel splice open
192msgtypechanneld_splice_confirmed_init7205
193msgdatachanneld_splice_confirmed_initpsbtwally_psbt
194# master->channeld: Update an active splice
195msgtypechanneld_splice_update7206
196msgdatachanneld_splice_updatepsbtwally_psbt
197# channeld->master: Splice update complete
198msgtypechanneld_splice_confirmed_update7207
199msgdatachanneld_splice_confirmed_updatepsbtwally_psbt
200msgdatachanneld_splice_confirmed_updatecommitments_securedbool
201msgdatachanneld_splice_confirmed_updatesignatures_securedbool
202# channeld->master: Lookup a transaction
203msgtypechanneld_splice_lookup_tx7208
204msgdatachanneld_splice_lookup_txtxidbitcoin_txid
205# master->channeld: Retrieved transaction
206msgtypechanneld_splice_lookup_tx_result7209
207msgdatachanneld_splice_lookup_tx_resulttxbitcoin_tx
208# master->channeld: User has signed psbt and it's ready to complete
209msgtypechanneld_splice_signed7212
210msgdatachanneld_splice_signedpsbtwally_psbt
211msgdatachanneld_splice_signedforce_sign_firstbool
212# channeld->master: Signed psbt is completed
213msgtypechanneld_splice_confirmed_signed7213
214msgdatachanneld_splice_confirmed_signedtxbitcoin_tx
215msgdatachanneld_splice_confirmed_signedoutput_indexu32
216# channeld->master: Splice signatures are about to be sent
217msgtypechanneld_splice_sending_sigs7214
218msgdatachanneld_splice_sending_sigstxbitcoin_txid
219# channeld->master: A feerate error has occured
220msgtypechanneld_splice_feerate_error7215
221msgdatachanneld_splice_feerate_errorfeeamount_msat
222msgdatachanneld_splice_feerate_errortoo_highbool
223# channeld->master: Add an inflight to the DB
224msgtypechanneld_add_inflight7216
225msgdatachanneld_add_inflightremote_fundingpubkey
226msgdatachanneld_add_inflighttx_idbitcoin_txid
227msgdatachanneld_add_inflighttx_outnumu32
228msgdatachanneld_add_inflightfeerateu32
229msgdatachanneld_add_inflightsatoshisamount_sat
230msgdatachanneld_add_inflightsplice_amounts64
231msgdatachanneld_add_inflightpsbtwally_psbt
232msgdatachanneld_add_inflighti_am_initiatorbool
233msgdatachanneld_add_inflightforce_sign_firstbool
234msgdatachanneld_add_inflighti_sent_sigsbool
235# master->channeld: Inflight saved successfully
236msgtypechanneld_got_inflight7217
237# channeld->master: Update inflight with sigs
238msgtypechanneld_update_inflight7219
239msgdatachanneld_update_inflightpsbtwally_psbt
240msgdatachanneld_update_inflightlast_tx?bitcoin_tx
241msgdatachanneld_update_inflightlast_sig?bitcoin_signature
242msgdatachanneld_update_inflightlocked_scid?short_channel_id
243msgdatachanneld_update_inflighti_sent_sigsbool
244# channeld->master: A funding error has occured
245msgtypechanneld_splice_funding_error7220
246msgdatachanneld_splice_funding_errorfundingamount_msat
247msgdatachanneld_splice_funding_errorreq_fundingamount_msat
248msgdatachanneld_splice_funding_erroropener_errorbool
249# channeld->master: A splice state error has occured
250msgtypechanneld_splice_state_error7221
251msgdatachanneld_splice_state_errorstate_errorwirestring
252# channeld->master: Peer rejected our splice
253msgtypechanneld_splice_abort7223
254msgdatachanneld_splice_abortdid_i_initiatebool
255msgdatachanneld_splice_abortinflight_outpoint?bitcoin_outpoint
256msgdatachanneld_splice_abortreasonwirestring
257# master->channeld: Please enter stfu mode
258msgtypechanneld_stfu7224
259# channeld->master: Entered stfu result
260msgtypechanneld_confirmed_stfu7225
261msgdatachanneld_confirmed_stfuavailable_fundsamount_msat
262# master->channeld: Please enter perform tx_abort
263msgtypechanneld_abort7226
264# Tell peer to shut down channel.
265msgtypechanneld_send_shutdown1023
266msgdatachanneld_send_shutdownfinal_index?u32
267msgdatachanneld_send_shutdownfinal_ext_key?ext_key
268msgdatachanneld_send_shutdownshutdown_lenu16
269msgdatachanneld_send_shutdownshutdown_scriptpubkeyu8shutdown_len
270msgdatachanneld_send_shutdownwrong_funding?bitcoin_outpoint
271# Peer told us that channel is shutting down
272msgtypechanneld_got_shutdown1024
273msgdatachanneld_got_shutdownscriptpubkey_lenu16
274msgdatachanneld_got_shutdownscriptpubkeyu8scriptpubkey_len
275msgdatachanneld_got_shutdownwrong_funding?bitcoin_outpoint
276# Shutdown is completeready for closing negotiation. + peer_fd & gossip_fd.
277msgtypechanneld_shutdown_complete1025
278# Re-enable commit timer.
279msgtypechanneld_dev_reenable_commit1026
280msgtypechanneld_dev_reenable_commit_reply1126
281msgtypechanneld_feerates1027
282msgdatachanneld_feeratesfeerateu32
283msgdatachanneld_feeratesmin_feerateu32
284msgdatachanneld_feeratesmax_feerateu32
285msgdatachanneld_feeratespenalty_feerateu32
286# master -> channeld: do you have a memleak?
287msgtypechanneld_dev_memleak1033
288msgtypechanneld_dev_memleak_reply1133
289msgdatachanneld_dev_memleak_replyleakbool
290# Peer presented proof it was from the future.
291msgtypechanneld_fail_fallen_behind1028
292# When we receive announcement_signatures for channel announce
293msgtypechanneld_got_announcement1017
294msgdatachanneld_got_announcementscidshort_channel_id
295msgdatachanneld_got_announcementremote_ann_node_sigsecp256k1_ecdsa_signature
296msgdatachanneld_got_announcementremote_ann_bitcoin_sigsecp256k1_ecdsa_signature
297# Ask channeld to send a error message. Used in forgetting channel case.
298msgtypechanneld_send_error1008
299msgdatachanneld_send_errorreasonwirestring
300# Tell master channeld has sent the error message.
301msgtypechanneld_send_error_reply1108
302# Ask channeld to quiesce.
303msgtypechanneld_dev_quiesce1009
304msgtypechanneld_dev_quiesce_reply1109
305# Tell master we're upgrading the commitment tx.
306msgtypechanneld_upgraded1011
307msgdatachanneld_upgradednew_typechannel_type
308# Tell peer about our latest and greatest blockheight.
309msgtypechanneld_blockheight1012
310msgdatachanneld_blockheightblockheightu32
311# Tell channeld about peer's shachain seed.
312msgtypechanneld_dev_peer_shachain1013
313msgdatachanneld_dev_peer_shachainseedsha256