This appends the extra_tlvs to the internal channeld_offer_htlc wire msg. We also recombine the extra_tlvs with the blinded path key for forwarding htlcs. Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
15 KiB
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) | ||||
| 15 | msgtype | channeld_init | 1000 | ||
| 16 | msgdata | channeld_init | chainparams | chainparams | |
| 17 | msgdata | channeld_init | our_features | feature_set | |
| 18 | msgdata | channeld_init | num_hsm_capabilities | u16 | |
| 19 | msgdata | channeld_init | hsm_capabilities | u32 | num_hsm_capabilities |
| 20 | msgdata | channeld_init | channel_id | channel_id | |
| 21 | msgdata | channeld_init | funding | bitcoin_outpoint | |
| 22 | msgdata | channeld_init | funding_satoshi | amount_sat | |
| 23 | msgdata | channeld_init | minimum_depth | u32 | |
| 24 | msgdata | channeld_init | our_blockheight | u32 | |
| 25 | msgdata | channeld_init | blockheight_states | height_states | |
| 26 | msgdata | channeld_init | lease_expiry | u32 | |
| 27 | msgdata | channeld_init | our_config | channel_config | |
| 28 | msgdata | channeld_init | their_config | channel_config | |
| 29 | msgdata | channeld_init | fee_states | fee_states | |
| 30 | msgdata | channeld_init | feerate_min | u32 | |
| 31 | msgdata | channeld_init | feerate_max | u32 | |
| 32 | msgdata | channeld_init | feerate_penalty | u32 | |
| 33 | msgdata | channeld_init | first_commit_sig | bitcoin_signature | |
| 34 | msgdata | channeld_init | remote_fundingkey | pubkey | |
| 35 | msgdata | channeld_init | remote_basepoints | basepoints | |
| 36 | msgdata | channeld_init | remote_per_commit | pubkey | |
| 37 | msgdata | channeld_init | old_remote_per_commit | pubkey | |
| 38 | msgdata | channeld_init | opener | enum side | |
| 39 | msgdata | channeld_init | local_msatoshi | amount_msat | |
| 40 | msgdata | channeld_init | our_basepoints | basepoints | |
| 41 | msgdata | channeld_init | our_funding_pubkey | pubkey | |
| 42 | msgdata | channeld_init | commit_msec | u32 | |
| 43 | msgdata | channeld_init | last_was_revoke | bool | |
| 44 | msgdata | channeld_init | num_last_sent_commit | u16 | |
| 45 | msgdata | channeld_init | last_sent_commit | changed_htlc | num_last_sent_commit |
| 46 | msgdata | channeld_init | next_index_local | u64 | |
| 47 | msgdata | channeld_init | next_index_remote | u64 | |
| 48 | msgdata | channeld_init | revocations_received | u64 | |
| 49 | msgdata | channeld_init | next_htlc_id | u64 | |
| 50 | msgdata | channeld_init | num_existing_htlcs | u16 | |
| 51 | msgdata | channeld_init | htlcs | existing_htlc | num_existing_htlcs |
| 52 | msgdata | channeld_init | local_channel_ready | bool | |
| 53 | msgdata | channeld_init | remote_channel_ready | bool | |
| 54 | msgdata | channeld_init | funding_short_id | short_channel_id | |
| 55 | msgdata | channeld_init | reestablish | bool | |
| 56 | msgdata | channeld_init | send_shutdown | bool | |
| 57 | msgdata | channeld_init | remote_shutdown_received | bool | |
| 58 | msgdata | channeld_init | final_index | u32 | |
| 59 | msgdata | channeld_init | final_ext_key | ext_key | |
| 60 | msgdata | channeld_init | final_scriptpubkey_len | u16 | |
| 61 | msgdata | channeld_init | final_scriptpubkey | u8 | final_scriptpubkey_len |
| 62 | msgdata | channeld_init | flags | u8 | |
| 63 | msgdata | channeld_init | init_peer_pkt_len | u16 | |
| 64 | msgdata | channeld_init | init_peer_pkt | u8 | init_peer_pkt_len |
| 65 | msgdata | channeld_init | last_remote_secret | secret | |
| 66 | msgdata | channeld_init | flen | u16 | |
| 67 | msgdata | channeld_init | their_features | u8 | flen |
| 68 | msgdata | channeld_init | upfront_shutdown_script_len | u16 | |
| 69 | msgdata | channeld_init | upfront_shutdown_script | u8 | upfront_shutdown_script_len |
| 70 | msgdata | channeld_init | desired_type | channel_type | |
| 71 | msgdata | channeld_init | dev_disable_commit | ?u32 | |
| 72 | msgdata | channeld_init | num_penalty_bases | u32 | |
| 73 | msgdata | channeld_init | pbases | penalty_base | num_penalty_bases |
| 74 | msgdata | channeld_init | num_inflights | u16 | |
| 75 | msgdata | channeld_init | inflights | inflight | num_inflights |
| 76 | msgdata | channeld_init | scid_alias | short_channel_id | |
| 77 | # channeld->lightningd: successfully negotated reestablishment. | ||||
| 78 | msgtype | channeld_reestablished | 1101 | ||
| 79 | # master->channeld funding hit new depth(funding locked if >= lock depth) | ||||
| 80 | # short_channel_id != NULL once we have 3+ confirmations | ||||
| 81 | msgtype | channeld_funding_depth | 1002 | ||
| 82 | msgdata | channeld_funding_depth | short_channel_id | ?short_channel_id | |
| 83 | msgdata | channeld_funding_depth | depth | u32 | |
| 84 | msgdata | channeld_funding_depth | splicing | bool | |
| 85 | msgdata | channeld_funding_depth | txid | bitcoin_txid | |
| 86 | # Tell channel to offer this htlc | ||||
| 87 | msgtype | channeld_offer_htlc | 1004 | ||
| 88 | msgdata | channeld_offer_htlc | amount_msat | amount_msat | |
| 89 | msgdata | channeld_offer_htlc | cltv_expiry | u32 | |
| 90 | msgdata | channeld_offer_htlc | payment_hash | sha256 | |
| 91 | msgdata | channeld_offer_htlc | onion_routing_packet | u8 | 1366 |
| 92 | msgdata | channeld_offer_htlc | path_key | ?pubkey | |
| 93 | msgdata | channeld_offer_htlc | extra_tlvs_len | u16 | |
| 94 | msgdata | channeld_offer_htlc | extra_tlvs | u8 | extra_tlvs_len |
| 95 | # Reply; synchronous since IDs have to increment. | ||||
| 96 | msgtype | channeld_offer_htlc_reply | 1104 | ||
| 97 | msgdata | channeld_offer_htlc_reply | id | u64 | |
| 98 | # Empty failure message means success. | ||||
| 99 | msgdata | channeld_offer_htlc_reply | len | u16 | |
| 100 | msgdata | channeld_offer_htlc_reply | failuremsg | u8 | len |
| 101 | msgdata | channeld_offer_htlc_reply | failurestr | wirestring | |
| 102 | # Main daemon found out the preimage for an HTLC | ||||
| 103 | #include <bitcoin/preimage.h> | ||||
| 104 | msgtype | channeld_fulfill_htlc | 1005 | ||
| 105 | msgdata | channeld_fulfill_htlc | fulfilled_htlc | fulfilled_htlc | |
| 106 | # Main daemon says HTLC failed | ||||
| 107 | msgtype | channeld_fail_htlc | 1006 | ||
| 108 | msgdata | channeld_fail_htlc | failed_htlc | failed_htlc | |
| 109 | # When we receive channel_ready. | ||||
| 110 | msgtype | channeld_got_channel_ready | 1019 | ||
| 111 | msgdata | channeld_got_channel_ready | next_per_commit_point | pubkey | |
| 112 | msgdata | channeld_got_channel_ready | alias | ?short_channel_id | |
| 113 | # When we receive funding_locked. | ||||
| 114 | msgtype | channeld_got_splice_locked | 1119 | ||
| 115 | msgdata | channeld_got_splice_locked | funding_sats | amount_sat | |
| 116 | msgdata | channeld_got_splice_locked | splice_amnt | s64 | |
| 117 | msgdata | channeld_got_splice_locked | locked_txid | bitcoin_txid | |
| 118 | #include <common/penalty_base.h> | ||||
| 119 | subtype | local_anchor_info | |||
| 120 | subtypedata | local_anchor_info | commitment_weight | u32 | |
| 121 | subtypedata | local_anchor_info | commitment_fee | amount_sat | |
| 122 | subtypedata | local_anchor_info | anchor_point | bitcoin_outpoint | |
| 123 | # lightningd needs to track our anchor outputs on remote txs. | ||||
| 124 | # This includes splices | so there could be more than one! | |||
| 125 | msgtype | channeld_local_anchor_info | 1003 | ||
| 126 | msgdata | channeld_local_anchor_info | remote_commitnum | u64 | |
| 127 | msgdata | channeld_local_anchor_info | num_anchors | u16 | |
| 128 | msgdata | channeld_local_anchor_info | anchors | local_anchor_info | num_anchors |
| 129 | # When we send a commitment_signed message | tell master. | |||
| 130 | msgtype | channeld_sending_commitsig | 1020 | ||
| 131 | msgdata | channeld_sending_commitsig | commitnum | u64 | |
| 132 | msgdata | channeld_sending_commitsig | pbase | ?penalty_base | |
| 133 | msgdata | channeld_sending_commitsig | fee_states | fee_states | |
| 134 | msgdata | channeld_sending_commitsig | blockheight_states | height_states | |
| 135 | # SENT_ADD_COMMIT | SENT_REMOVE_ACK_COMMIT | SENT_ADD_ACK_COMMIT | SENT_REMOVE_COMMIT | |
| 136 | msgdata | channeld_sending_commitsig | num_changed | u16 | |
| 137 | msgdata | channeld_sending_commitsig | changed | changed_htlc | num_changed |
| 138 | # Wait for reply | to make sure it's on disk before we send commit. | |||
| 139 | msgtype | channeld_sending_commitsig_reply | 1120 | ||
| 140 | # When we have a commitment_signed message | tell master to remember. | |||
| 141 | msgtype | channeld_got_commitsig | 1021 | ||
| 142 | msgdata | channeld_got_commitsig | commitnum | u64 | |
| 143 | msgdata | channeld_got_commitsig | fee_states | fee_states | |
| 144 | msgdata | channeld_got_commitsig | blockheight_states | height_states | |
| 145 | msgdata | channeld_got_commitsig | signature | bitcoin_signature | |
| 146 | msgdata | channeld_got_commitsig | num_htlcs | u16 | |
| 147 | msgdata | channeld_got_commitsig | htlc_signature | bitcoin_signature | num_htlcs |
| 148 | # RCVD_ADD_COMMIT: we're now committed to their new offered HTLCs. | ||||
| 149 | msgdata | channeld_got_commitsig | num_added | u16 | |
| 150 | msgdata | channeld_got_commitsig | added | added_htlc | num_added |
| 151 | # RCVD_REMOVE_COMMIT: we're now no longer committed to these HTLCs. | ||||
| 152 | msgdata | channeld_got_commitsig | num_fulfilled | u16 | |
| 153 | msgdata | channeld_got_commitsig | fulfilled | fulfilled_htlc | num_fulfilled |
| 154 | msgdata | channeld_got_commitsig | num_failed | u16 | |
| 155 | msgdata | channeld_got_commitsig | failed | failed_htlc | num_failed |
| 156 | # RCVD_ADD_ACK_COMMIT | RCVD_REMOVE_ACK_COMMIT | |||
| 157 | msgdata | channeld_got_commitsig | num_changed | u16 | |
| 158 | msgdata | channeld_got_commitsig | changed | changed_htlc | num_changed |
| 159 | msgdata | channeld_got_commitsig | tx | bitcoin_tx | |
| 160 | # Inflight splice commitments | ||||
| 161 | msgdata | channeld_got_commitsig | num_inflight_commitsigs | u16 | |
| 162 | msgdata | channeld_got_commitsig | inflight_commitsigs | commitsig | num_inflight_commitsigs |
| 163 | subtype | commitsig | |||
| 164 | subtypedata | commitsig | tx | bitcoin_tx | |
| 165 | subtypedata | commitsig | commit_signature | bitcoin_signature | |
| 166 | subtypedata | commitsig | num_htlcs | u16 | |
| 167 | subtypedata | commitsig | htlc_signatures | bitcoin_signature | num_htlcs |
| 168 | # Wait for reply | to make sure it's on disk before we send revocation. | |||
| 169 | msgtype | channeld_got_commitsig_reply | 1121 | ||
| 170 | #include <common/htlc_wire.h> | ||||
| 171 | msgtype | channeld_got_revoke | 1022 | ||
| 172 | msgdata | channeld_got_revoke | revokenum | u64 | |
| 173 | msgdata | channeld_got_revoke | per_commitment_secret | secret | |
| 174 | msgdata | channeld_got_revoke | next_per_commit_point | pubkey | |
| 175 | # RCVD_ADD_ACK_REVOCATION | RCVD_REMOVE_ACK_REVOCATION | RCVD_ADD_REVOCATION | RCVD_REMOVE_REVOCATION | |
| 176 | msgdata | channeld_got_revoke | fee_states | fee_states | |
| 177 | msgdata | channeld_got_revoke | blockheight_states | height_states | |
| 178 | msgdata | channeld_got_revoke | num_changed | u16 | |
| 179 | msgdata | channeld_got_revoke | changed | changed_htlc | num_changed |
| 180 | msgdata | channeld_got_revoke | pbase | ?penalty_base | |
| 181 | msgdata | channeld_got_revoke | penalty_tx | ?bitcoin_tx | |
| 182 | # Wait for reply | to make sure it's on disk before we continue | |||
| 183 | # (eg. if we sent another commitment_signed | that would implicitly ack). | |||
| 184 | msgtype | channeld_got_revoke_reply | 1122 | ||
| 185 | #include <wally_bip32.h> | ||||
| 186 | # master->channeld: hello | I'd like to start a channel splice open | |||
| 187 | msgtype | channeld_splice_init | 7204 | ||
| 188 | msgdata | channeld_splice_init | psbt | wally_psbt | |
| 189 | msgdata | channeld_splice_init | relative_amount | s64 | |
| 190 | msgdata | channeld_splice_init | feerate_per_kw | u32 | |
| 191 | msgdata | channeld_splice_init | force_feerate | bool | |
| 192 | msgdata | channeld_splice_init | skip_stfu | bool | |
| 193 | # channeld->master: hello | I started a channel splice open | |||
| 194 | msgtype | channeld_splice_confirmed_init | 7205 | ||
| 195 | msgdata | channeld_splice_confirmed_init | psbt | wally_psbt | |
| 196 | # master->channeld: Update an active splice | ||||
| 197 | msgtype | channeld_splice_update | 7206 | ||
| 198 | msgdata | channeld_splice_update | psbt | wally_psbt | |
| 199 | # channeld->master: Splice update complete | ||||
| 200 | msgtype | channeld_splice_confirmed_update | 7207 | ||
| 201 | msgdata | channeld_splice_confirmed_update | psbt | wally_psbt | |
| 202 | msgdata | channeld_splice_confirmed_update | commitments_secured | bool | |
| 203 | msgdata | channeld_splice_confirmed_update | signatures_secured | bool | |
| 204 | # channeld->master: Lookup a transaction | ||||
| 205 | msgtype | channeld_splice_lookup_tx | 7208 | ||
| 206 | msgdata | channeld_splice_lookup_tx | txid | bitcoin_txid | |
| 207 | # master->channeld: Retrieved transaction | ||||
| 208 | msgtype | channeld_splice_lookup_tx_result | 7209 | ||
| 209 | msgdata | channeld_splice_lookup_tx_result | tx | bitcoin_tx | |
| 210 | # master->channeld: User has signed psbt and it's ready to complete | ||||
| 211 | msgtype | channeld_splice_signed | 7212 | ||
| 212 | msgdata | channeld_splice_signed | psbt | wally_psbt | |
| 213 | msgdata | channeld_splice_signed | force_sign_first | bool | |
| 214 | # channeld->master: Signed psbt is completed | ||||
| 215 | msgtype | channeld_splice_confirmed_signed | 7213 | ||
| 216 | msgdata | channeld_splice_confirmed_signed | tx | bitcoin_tx | |
| 217 | msgdata | channeld_splice_confirmed_signed | output_index | u32 | |
| 218 | # channeld->master: Splice signatures are about to be sent | ||||
| 219 | msgtype | channeld_splice_sending_sigs | 7214 | ||
| 220 | msgdata | channeld_splice_sending_sigs | tx | bitcoin_txid | |
| 221 | # channeld->master: A feerate error has occured | ||||
| 222 | msgtype | channeld_splice_feerate_error | 7215 | ||
| 223 | msgdata | channeld_splice_feerate_error | fee | amount_msat | |
| 224 | msgdata | channeld_splice_feerate_error | too_high | bool | |
| 225 | # channeld->master: Add an inflight to the DB | ||||
| 226 | msgtype | channeld_add_inflight | 7216 | ||
| 227 | msgdata | channeld_add_inflight | remote_funding | pubkey | |
| 228 | msgdata | channeld_add_inflight | tx_id | bitcoin_txid | |
| 229 | msgdata | channeld_add_inflight | tx_outnum | u32 | |
| 230 | msgdata | channeld_add_inflight | feerate | u32 | |
| 231 | msgdata | channeld_add_inflight | satoshis | amount_sat | |
| 232 | msgdata | channeld_add_inflight | splice_amount | s64 | |
| 233 | msgdata | channeld_add_inflight | psbt | wally_psbt | |
| 234 | msgdata | channeld_add_inflight | i_am_initiator | bool | |
| 235 | msgdata | channeld_add_inflight | force_sign_first | bool | |
| 236 | msgdata | channeld_add_inflight | i_sent_sigs | bool | |
| 237 | # master->channeld: Inflight saved successfully | ||||
| 238 | msgtype | channeld_got_inflight | 7217 | ||
| 239 | # channeld->master: Update inflight with sigs | ||||
| 240 | msgtype | channeld_update_inflight | 7219 | ||
| 241 | msgdata | channeld_update_inflight | psbt | wally_psbt | |
| 242 | msgdata | channeld_update_inflight | last_tx | ?bitcoin_tx | |
| 243 | msgdata | channeld_update_inflight | last_sig | ?bitcoin_signature | |
| 244 | msgdata | channeld_update_inflight | locked_scid | ?short_channel_id | |
| 245 | msgdata | channeld_update_inflight | i_sent_sigs | bool | |
| 246 | # channeld->master: A funding error has occured | ||||
| 247 | msgtype | channeld_splice_funding_error | 7220 | ||
| 248 | msgdata | channeld_splice_funding_error | funding | amount_msat | |
| 249 | msgdata | channeld_splice_funding_error | req_funding | amount_msat | |
| 250 | msgdata | channeld_splice_funding_error | opener_error | bool | |
| 251 | # channeld->master: A splice state error has occured | ||||
| 252 | msgtype | channeld_splice_state_error | 7221 | ||
| 253 | msgdata | channeld_splice_state_error | state_error | wirestring | |
| 254 | # channeld->master: Peer rejected our splice | ||||
| 255 | msgtype | channeld_splice_abort | 7223 | ||
| 256 | msgdata | channeld_splice_abort | did_i_initiate | bool | |
| 257 | msgdata | channeld_splice_abort | inflight_outpoint | ?bitcoin_outpoint | |
| 258 | msgdata | channeld_splice_abort | reason | wirestring | |
| 259 | # master->channeld: Please enter stfu mode | ||||
| 260 | msgtype | channeld_stfu | 7224 | ||
| 261 | # channeld->master: Entered stfu result | ||||
| 262 | msgtype | channeld_confirmed_stfu | 7225 | ||
| 263 | msgdata | channeld_confirmed_stfu | available_funds | amount_msat | |
| 264 | # master->channeld: Please enter perform tx_abort | ||||
| 265 | msgtype | channeld_abort | 7226 | ||
| 266 | # Tell peer to shut down channel. | ||||
| 267 | msgtype | channeld_send_shutdown | 1023 | ||
| 268 | msgdata | channeld_send_shutdown | final_index | ?u32 | |
| 269 | msgdata | channeld_send_shutdown | final_ext_key | ?ext_key | |
| 270 | msgdata | channeld_send_shutdown | shutdown_len | u16 | |
| 271 | msgdata | channeld_send_shutdown | shutdown_scriptpubkey | u8 | shutdown_len |
| 272 | msgdata | channeld_send_shutdown | wrong_funding | ?bitcoin_outpoint | |
| 273 | # Peer told us that channel is shutting down | ||||
| 274 | msgtype | channeld_got_shutdown | 1024 | ||
| 275 | msgdata | channeld_got_shutdown | scriptpubkey_len | u16 | |
| 276 | msgdata | channeld_got_shutdown | scriptpubkey | u8 | scriptpubkey_len |
| 277 | msgdata | channeld_got_shutdown | wrong_funding | ?bitcoin_outpoint | |
| 278 | # Shutdown is complete | ready for closing negotiation. + peer_fd & gossip_fd. | |||
| 279 | msgtype | channeld_shutdown_complete | 1025 | ||
| 280 | # Re-enable commit timer. | ||||
| 281 | msgtype | channeld_dev_reenable_commit | 1026 | ||
| 282 | msgtype | channeld_dev_reenable_commit_reply | 1126 | ||
| 283 | msgtype | channeld_feerates | 1027 | ||
| 284 | msgdata | channeld_feerates | feerate | u32 | |
| 285 | msgdata | channeld_feerates | min_feerate | u32 | |
| 286 | msgdata | channeld_feerates | max_feerate | u32 | |
| 287 | msgdata | channeld_feerates | penalty_feerate | u32 | |
| 288 | # master -> channeld: do you have a memleak? | ||||
| 289 | msgtype | channeld_dev_memleak | 1033 | ||
| 290 | msgtype | channeld_dev_memleak_reply | 1133 | ||
| 291 | msgdata | channeld_dev_memleak_reply | leak | bool | |
| 292 | # Peer presented proof it was from the future. | ||||
| 293 | msgtype | channeld_fail_fallen_behind | 1028 | ||
| 294 | # When we receive announcement_signatures for channel announce | ||||
| 295 | msgtype | channeld_got_announcement | 1017 | ||
| 296 | msgdata | channeld_got_announcement | scid | short_channel_id | |
| 297 | msgdata | channeld_got_announcement | remote_ann_node_sig | secp256k1_ecdsa_signature | |
| 298 | msgdata | channeld_got_announcement | remote_ann_bitcoin_sig | secp256k1_ecdsa_signature | |
| 299 | # Ask channeld to send a error message. Used in forgetting channel case. | ||||
| 300 | msgtype | channeld_send_error | 1008 | ||
| 301 | msgdata | channeld_send_error | reason | wirestring | |
| 302 | # Tell master channeld has sent the error message. | ||||
| 303 | msgtype | channeld_send_error_reply | 1108 | ||
| 304 | # Ask channeld to quiesce. | ||||
| 305 | msgtype | channeld_dev_quiesce | 1009 | ||
| 306 | msgtype | channeld_dev_quiesce_reply | 1109 | ||
| 307 | # Tell master we're upgrading the commitment tx. | ||||
| 308 | msgtype | channeld_upgraded | 1011 | ||
| 309 | msgdata | channeld_upgraded | new_type | channel_type | |
| 310 | # Tell peer about our latest and greatest blockheight. | ||||
| 311 | msgtype | channeld_blockheight | 1012 | ||
| 312 | msgdata | channeld_blockheight | blockheight | u32 | |
| 313 | # Tell channeld about peer's shachain seed. | ||||
| 314 | msgtype | channeld_dev_peer_shachain | 1013 | ||
| 315 | msgdata | channeld_dev_peer_shachain | seed | sha256 |