mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 18:11:28 +01:00
d6558deaa4
v2 of channel establishment, in the accpeter case, now sends 2 messages to our peer after saving the information to disk (our commitment signatures and our funding transaction signatures)
9.9 KiB
9.9 KiB
1 | #include <common/cryptomsg.h> |
---|---|
2 | #include <common/channel_config.h> |
3 | #include <common/channel_id.h> |
4 | #include <common/derive_basepoints.h> |
5 | #include <common/features.h> |
6 | #include <common/fee_states.h> |
7 | #include <common/per_peer_state.h> |
8 | # Begin! (passes gossipd-client fd) |
9 | msgtype,channeld_init,1000 |
10 | msgdata,channeld_init,chainparams,chainparams, |
11 | msgdata,channeld_init,our_features,feature_set, |
12 | msgdata,channeld_init,channel_id,channel_id, |
13 | msgdata,channeld_init,funding_txid,bitcoin_txid, |
14 | msgdata,channeld_init,funding_txout,u16, |
15 | msgdata,channeld_init,funding_satoshi,amount_sat, |
16 | msgdata,channeld_init,minimum_depth,u32, |
17 | msgdata,channeld_init,our_config,channel_config, |
18 | msgdata,channeld_init,their_config,channel_config, |
19 | msgdata,channeld_init,fee_states,fee_states, |
20 | msgdata,channeld_init,feerate_min,u32, |
21 | msgdata,channeld_init,feerate_max,u32, |
22 | msgdata,channeld_init,feerate_penalty,u32, |
23 | msgdata,channeld_init,first_commit_sig,bitcoin_signature, |
24 | msgdata,channeld_init,per_peer_state,per_peer_state, |
25 | msgdata,channeld_init,remote_fundingkey,pubkey, |
26 | msgdata,channeld_init,remote_basepoints,basepoints, |
27 | msgdata,channeld_init,remote_per_commit,pubkey, |
28 | msgdata,channeld_init,old_remote_per_commit,pubkey, |
29 | msgdata,channeld_init,opener,enum side, |
30 | msgdata,channeld_init,fee_base,u32, |
31 | msgdata,channeld_init,fee_proportional,u32, |
32 | msgdata,channeld_init,local_msatoshi,amount_msat, |
33 | msgdata,channeld_init,our_basepoints,basepoints, |
34 | msgdata,channeld_init,our_funding_pubkey,pubkey, |
35 | msgdata,channeld_init,local_node_id,node_id, |
36 | msgdata,channeld_init,remote_node_id,node_id, |
37 | msgdata,channeld_init,commit_msec,u32, |
38 | msgdata,channeld_init,cltv_delta,u16, |
39 | msgdata,channeld_init,last_was_revoke,bool, |
40 | msgdata,channeld_init,num_last_sent_commit,u16, |
41 | msgdata,channeld_init,last_sent_commit,changed_htlc,num_last_sent_commit |
42 | msgdata,channeld_init,next_index_local,u64, |
43 | msgdata,channeld_init,next_index_remote,u64, |
44 | msgdata,channeld_init,revocations_received,u64, |
45 | msgdata,channeld_init,next_htlc_id,u64, |
46 | msgdata,channeld_init,num_existing_htlcs,u16, |
47 | msgdata,channeld_init,htlcs,existing_htlc,num_existing_htlcs |
48 | msgdata,channeld_init,local_funding_locked,bool, |
49 | msgdata,channeld_init,remote_funding_locked,bool, |
50 | msgdata,channeld_init,funding_short_id,short_channel_id, |
51 | msgdata,channeld_init,reestablish,bool, |
52 | msgdata,channeld_init,send_shutdown,bool, |
53 | msgdata,channeld_init,remote_shutdown_received,bool, |
54 | msgdata,channeld_init,final_scriptpubkey_len,u16, |
55 | msgdata,channeld_init,final_scriptpubkey,u8,final_scriptpubkey_len |
56 | msgdata,channeld_init,flags,u8, |
57 | msgdata,channeld_init,init_peer_pkt_len,u16, |
58 | msgdata,channeld_init,init_peer_pkt,u8,init_peer_pkt_len |
59 | msgdata,channeld_init,init_peer_pkt_two_len,u16, |
60 | msgdata,channeld_init,init_peer_pkt_two,u8,init_peer_pkt_two_len |
61 | msgdata,channeld_init,reached_announce_depth,bool, |
62 | msgdata,channeld_init,last_remote_secret,secret, |
63 | msgdata,channeld_init,flen,u16, |
64 | msgdata,channeld_init,their_features,u8,flen |
65 | msgdata,channeld_init,upfront_shutdown_script_len,u16, |
66 | msgdata,channeld_init,upfront_shutdown_script,u8,upfront_shutdown_script_len |
67 | msgdata,channeld_init,remote_ann_node_sig,?secp256k1_ecdsa_signature, |
68 | msgdata,channeld_init,remote_ann_bitcoin_sig,?secp256k1_ecdsa_signature, |
69 | msgdata,channeld_init,option_static_remotekey,bool, |
70 | msgdata,channeld_init,option_anchor_outputs,bool, |
71 | msgdata,channeld_init,dev_fast_gossip,bool, |
72 | msgdata,channeld_init,dev_fail_process_onionpacket,bool, |
73 | msgdata,channeld_init,num_penalty_bases,u32, |
74 | msgdata,channeld_init,pbases,penalty_base,num_penalty_bases |
75 | # master->channeld funding hit new depth(funding locked if >= lock depth) |
76 | msgtype,channeld_funding_depth,1002 |
77 | msgdata,channeld_funding_depth,short_channel_id,?short_channel_id, |
78 | msgdata,channeld_funding_depth,depth,u32, |
79 | # Tell channel to offer this htlc |
80 | msgtype,channeld_offer_htlc,1004 |
81 | msgdata,channeld_offer_htlc,amount_msat,amount_msat, |
82 | msgdata,channeld_offer_htlc,cltv_expiry,u32, |
83 | msgdata,channeld_offer_htlc,payment_hash,sha256, |
84 | msgdata,channeld_offer_htlc,onion_routing_packet,u8,1366 |
85 | msgdata,channeld_offer_htlc,blinding,?pubkey, |
86 | # Reply; synchronous since IDs have to increment. |
87 | msgtype,channeld_offer_htlc_reply,1104 |
88 | msgdata,channeld_offer_htlc_reply,id,u64, |
89 | # Empty failure message means success. |
90 | msgdata,channeld_offer_htlc_reply,len,u16, |
91 | msgdata,channeld_offer_htlc_reply,failuremsg,u8,len |
92 | msgdata,channeld_offer_htlc_reply,failurestr,wirestring, |
93 | # Main daemon found out the preimage for an HTLC |
94 | #include <bitcoin/preimage.h> |
95 | msgtype,channeld_fulfill_htlc,1005 |
96 | msgdata,channeld_fulfill_htlc,fulfilled_htlc,fulfilled_htlc, |
97 | # Main daemon says HTLC failed |
98 | msgtype,channeld_fail_htlc,1006 |
99 | msgdata,channeld_fail_htlc,failed_htlc,failed_htlc, |
100 | # When we receive funding_locked. |
101 | msgtype,channeld_got_funding_locked,1019 |
102 | msgdata,channeld_got_funding_locked,next_per_commit_point,pubkey, |
103 | #include <common/penalty_base.h> |
104 | # When we send a commitment_signed message, tell master. |
105 | msgtype,channeld_sending_commitsig,1020 |
106 | msgdata,channeld_sending_commitsig,commitnum,u64, |
107 | msgdata,channeld_sending_commitsig,pbase,?penalty_base, |
108 | msgdata,channeld_sending_commitsig,fee_states,fee_states, |
109 | # SENT_ADD_COMMIT, SENT_REMOVE_ACK_COMMIT, SENT_ADD_ACK_COMMIT, SENT_REMOVE_COMMIT |
110 | msgdata,channeld_sending_commitsig,num_changed,u16, |
111 | msgdata,channeld_sending_commitsig,changed,changed_htlc,num_changed |
112 | msgdata,channeld_sending_commitsig,commit_sig,bitcoin_signature, |
113 | msgdata,channeld_sending_commitsig,num_htlc_sigs,u16, |
114 | msgdata,channeld_sending_commitsig,htlc_sigs,bitcoin_signature,num_htlc_sigs |
115 | # Wait for reply, to make sure it's on disk before we send commit. |
116 | msgtype,channeld_sending_commitsig_reply,1120 |
117 | # When we have a commitment_signed message, tell master to remember. |
118 | msgtype,channeld_got_commitsig,1021 |
119 | msgdata,channeld_got_commitsig,commitnum,u64, |
120 | msgdata,channeld_got_commitsig,fee_states,fee_states, |
121 | msgdata,channeld_got_commitsig,signature,bitcoin_signature, |
122 | msgdata,channeld_got_commitsig,num_htlcs,u16, |
123 | msgdata,channeld_got_commitsig,htlc_signature,bitcoin_signature,num_htlcs |
124 | # RCVD_ADD_COMMIT: we're now committed to their new offered HTLCs. |
125 | msgdata,channeld_got_commitsig,num_added,u16, |
126 | msgdata,channeld_got_commitsig,added,added_htlc,num_added |
127 | # RCVD_REMOVE_COMMIT: we're now no longer committed to these HTLCs. |
128 | msgdata,channeld_got_commitsig,num_fulfilled,u16, |
129 | msgdata,channeld_got_commitsig,fulfilled,fulfilled_htlc,num_fulfilled |
130 | msgdata,channeld_got_commitsig,num_failed,u16, |
131 | msgdata,channeld_got_commitsig,failed,failed_htlc,num_failed |
132 | # RCVD_ADD_ACK_COMMIT, RCVD_REMOVE_ACK_COMMIT |
133 | msgdata,channeld_got_commitsig,num_changed,u16, |
134 | msgdata,channeld_got_commitsig,changed,changed_htlc,num_changed |
135 | msgdata,channeld_got_commitsig,tx,bitcoin_tx, |
136 | # Wait for reply, to make sure it's on disk before we send revocation. |
137 | msgtype,channeld_got_commitsig_reply,1121 |
138 | #include <common/htlc_wire.h> |
139 | msgtype,channeld_got_revoke,1022 |
140 | msgdata,channeld_got_revoke,revokenum,u64, |
141 | msgdata,channeld_got_revoke,per_commitment_secret,secret, |
142 | msgdata,channeld_got_revoke,next_per_commit_point,pubkey, |
143 | # RCVD_ADD_ACK_REVOCATION, RCVD_REMOVE_ACK_REVOCATION, RCVD_ADD_REVOCATION, RCVD_REMOVE_REVOCATION |
144 | msgdata,channeld_got_revoke,fee_states,fee_states, |
145 | msgdata,channeld_got_revoke,num_changed,u16, |
146 | msgdata,channeld_got_revoke,changed,changed_htlc,num_changed |
147 | msgdata,channeld_got_revoke,pbase,?penalty_base, |
148 | msgdata,channeld_got_revoke,penalty_tx,?bitcoin_tx, |
149 | # Wait for reply, to make sure it's on disk before we continue |
150 | # (eg. if we sent another commitment_signed, that would implicitly ack). |
151 | msgtype,channeld_got_revoke_reply,1122 |
152 | # Tell peer to shut down channel. |
153 | msgtype,channeld_send_shutdown,1023 |
154 | msgdata,channeld_send_shutdown,shutdown_len,u16, |
155 | msgdata,channeld_send_shutdown,shutdown_scriptpubkey,u8,shutdown_len |
156 | # Peer told us that channel is shutting down |
157 | msgtype,channeld_got_shutdown,1024 |
158 | msgdata,channeld_got_shutdown,scriptpubkey_len,u16, |
159 | msgdata,channeld_got_shutdown,scriptpubkey,u8,scriptpubkey_len |
160 | # Shutdown is complete, ready for closing negotiation. + peer_fd & gossip_fd. |
161 | msgtype,channeld_shutdown_complete,1025 |
162 | msgdata,channeld_shutdown_complete,per_peer_state,per_peer_state, |
163 | # Re-enable commit timer. |
164 | msgtype,channeld_dev_reenable_commit,1026 |
165 | msgtype,channeld_dev_reenable_commit_reply,1126, |
166 | msgtype,channeld_feerates,1027 |
167 | msgdata,channeld_feerates,feerate,u32, |
168 | msgdata,channeld_feerates,min_feerate,u32, |
169 | msgdata,channeld_feerates,max_feerate,u32, |
170 | msgdata,channeld_feerates,penalty_feerate,u32, |
171 | # master -> channeld: do you have a memleak? |
172 | msgtype,channeld_dev_memleak,1033 |
173 | msgtype,channeld_dev_memleak_reply,1133 |
174 | msgdata,channeld_dev_memleak_reply,leak,bool, |
175 | # Peer presented proof it was from the future. |
176 | msgtype,channeld_fail_fallen_behind,1028 |
177 | # This is NULL if option_static_remotekey. |
178 | msgdata,channeld_fail_fallen_behind,remote_per_commitment_point,?pubkey, |
179 | # Handle a channel specific feerate base ppm configuration |
180 | msgtype,channeld_specific_feerates,1029 |
181 | msgdata,channeld_specific_feerates,feerate_base,u32, |
182 | msgdata,channeld_specific_feerates,feerate_ppm,u32, |
183 | # When we receive announcement_signatures for channel announce |
184 | msgtype,channeld_got_announcement,1017 |
185 | msgdata,channeld_got_announcement,remote_ann_node_sig,secp256k1_ecdsa_signature, |
186 | msgdata,channeld_got_announcement,remote_ann_bitcoin_sig,secp256k1_ecdsa_signature, |
187 | # Ask channeld to send a error message. Used in forgetting channel case. |
188 | msgtype,channeld_send_error,1008 |
189 | msgdata,channeld_send_error,reason,wirestring, |
190 | # Tell master channeld has sent the error message. |
191 | msgtype,channeld_send_error_reply,1108 |
192 | # Tell lightningd we got a onion message (for us, or to fwd) |
193 | msgtype,got_onionmsg_to_us,1142 |
194 | msgdata,got_onionmsg_to_us,reply_blinding,?pubkey, |
195 | msgdata,got_onionmsg_to_us,reply_path_len,u16, |
196 | msgdata,got_onionmsg_to_us,reply_path,onionmsg_path,reply_path_len |
197 | msgtype,got_onionmsg_forward,1143 |
198 | msgdata,got_onionmsg_forward,next_scid,?short_channel_id, |
199 | msgdata,got_onionmsg_forward,next_node_id,?node_id, |
200 | msgdata,got_onionmsg_forward,next_blinding,?pubkey, |
201 | msgdata,got_onionmsg_forward,next_onion,u8,1366 |
202 | # Lightningd tells us to send a onion message. |
203 | msgtype,send_onionmsg,1040 |
204 | msgdata,send_onionmsg,onion,u8,1366 |
205 | msgdata,send_onionmsg,blinding,?pubkey, |