MCPcopy Create free account
hub / github.com/ElementsProject/lightning / interactive_send_commitments

Function interactive_send_commitments

channeld/channeld.c:3213–3341  ·  view source on GitHub ↗

The question of "who signs splice commitments first" is the same order as the * splice `tx_signature`s are. This function handles sending & receiving the * required commitments as part of the splicing process. * If the first message received is `tx_abort` or `tx_signatures, NULL is * returned. */

Source from the content-addressed store, hash-verified

3211 * If the first message received is `tx_abort` or `tx_signatures, NULL is
3212 * returned. */
3213static struct commitsig *interactive_send_commitments(struct peer *peer,
3214 struct wally_psbt *psbt,
3215 enum tx_role our_role,
3216 size_t inflight_index,
3217 bool send_commitments,
3218 bool recv_commitments,
3219 const u8 **msg_received,
3220 int allowed_premature_msg)
3221{
3222 struct commitsig_info *result;
3223 const u8 *msg;
3224 struct pubkey my_current_per_commitment_point;
3225 struct inflight *inflight = peer->splice_state->inflights[inflight_index];
3226 s64 funding_diff = sats_diff(inflight->amnt,
3227 peer->channel->funding_sats);
3228 s64 remote_splice_amnt = funding_diff - inflight->splice_amnt;
3229 struct local_anchor_info *local_anchor;
3230 u64 next_index_local = peer->next_index[LOCAL];
3231 u64 next_index_remote = peer->next_index[REMOTE];
3232
3233 if(msg_received)
3234 *msg_received = NULL;
3235
3236 if (do_i_sign_first(peer, psbt, our_role, inflight->force_sign_first)
3237 && send_commitments) {
3238
3239 status_debug("Splice %s: we commit first;"
3240 " next_index_local:%"PRIu64";"
3241 " next_index_remote:%"PRIu64,
3242 our_role == TX_INITIATOR ? "initiator" : "accepter",
3243 next_index_local, next_index_remote);
3244
3245 peer_write(peer->pps, send_commit_part(tmpctx,
3246 peer,
3247 &inflight->outpoint,
3248 inflight->amnt,
3249 NULL, false,
3250 inflight->splice_amnt,
3251 remote_splice_amnt,
3252 next_index_remote - 1,
3253 &peer->old_remote_per_commit,
3254 &local_anchor,
3255 1,
3256 inflight->remote_funding));
3257 }
3258
3259 result = NULL;
3260
3261 if (recv_commitments) {
3262 msg = peer_expect_msg_four(tmpctx, peer,
3263 WIRE_COMMITMENT_SIGNED,
3264 WIRE_TX_SIGNATURES,
3265 WIRE_TX_ABORT,
3266 allowed_premature_msg);
3267
3268 /* If the message is a type that we allow to receive
3269 * prematurely: process this, then come back and get another
3270 * message */

Callers 2

Calls 10

sats_diffFunction · 0.85
do_i_sign_firstFunction · 0.85
peer_writeFunction · 0.85
send_commit_partFunction · 0.85
peer_expect_msg_fourFunction · 0.85
fromwire_peektypeFunction · 0.85
peer_inFunction · 0.85
check_tx_abortFunction · 0.85
get_per_commitment_pointFunction · 0.85
handle_peer_commit_sigFunction · 0.85

Tested by

no test coverage detected