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

Function interactive_send_commitments

channeld/channeld.c:3087–3215  ·  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

3085 * If the first message received is `tx_abort` or `tx_signatures, NULL is
3086 * returned. */
3087static struct commitsig *interactive_send_commitments(struct peer *peer,
3088 struct wally_psbt *psbt,
3089 enum tx_role our_role,
3090 size_t inflight_index,
3091 bool send_commitments,
3092 bool recv_commitments,
3093 const u8 **msg_received,
3094 int allowed_premature_msg)
3095{
3096 struct commitsig_info *result;
3097 const u8 *msg;
3098 struct pubkey my_current_per_commitment_point;
3099 struct inflight *inflight = peer->splice_state->inflights[inflight_index];
3100 s64 funding_diff = sats_diff(inflight->amnt,
3101 peer->channel->funding_sats);
3102 s64 remote_splice_amnt = funding_diff - inflight->splice_amnt;
3103 struct local_anchor_info *local_anchor;
3104 u64 next_index_local = peer->next_index[LOCAL];
3105 u64 next_index_remote = peer->next_index[REMOTE];
3106
3107 if(msg_received)
3108 *msg_received = NULL;
3109
3110 if (do_i_sign_first(peer, psbt, our_role, inflight->force_sign_first)
3111 && send_commitments) {
3112
3113 status_debug("Splice %s: we commit first;"
3114 " next_index_local:%"PRIu64";"
3115 " next_index_remote:%"PRIu64,
3116 our_role == TX_INITIATOR ? "initiator" : "accepter",
3117 next_index_local, next_index_remote);
3118
3119 peer_write(peer->pps, send_commit_part(tmpctx,
3120 peer,
3121 &inflight->outpoint,
3122 inflight->amnt,
3123 NULL, false,
3124 inflight->splice_amnt,
3125 remote_splice_amnt,
3126 next_index_remote - 1,
3127 &peer->old_remote_per_commit,
3128 &local_anchor,
3129 1,
3130 inflight->remote_funding));
3131 }
3132
3133 result = NULL;
3134
3135 if (recv_commitments) {
3136 msg = peer_expect_msg_four(tmpctx, peer,
3137 WIRE_COMMITMENT_SIGNED,
3138 WIRE_TX_SIGNATURES,
3139 WIRE_TX_ABORT,
3140 allowed_premature_msg);
3141
3142 /* If the message is a type that we allow to receive
3143 * prematurely: process this, then come back and get another
3144 * 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