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

Function handle_commit_received

lightningd/dual_open_control.c:3960–4045  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3958}
3959
3960static void handle_commit_received(struct subd *dualopend,
3961 struct channel *channel,
3962 const u8 *msg)
3963{
3964 struct lightningd *ld = dualopend->ld;
3965 struct bitcoin_tx *remote_commit;
3966 struct bitcoin_signature remote_commit_sig;
3967 struct penalty_base *pbase;
3968 struct json_stream *response;
3969 struct openchannel2_psbt_payload *payload;
3970 struct channel_inflight *inflight;
3971 struct command *cmd;
3972 bool updated;
3973
3974 if (!fromwire_dualopend_commit_rcvd(tmpctx, msg,
3975 &remote_commit,
3976 &remote_commit_sig,
3977 &pbase)) {
3978 channel_internal_error(channel,
3979 "Bad WIRE_DUALOPEND_COMMIT_RCVD: %s",
3980 tal_hex(msg, msg));
3981 channel->open_attempt = tal_free(channel->open_attempt);
3982 notify_channel_open_failed(channel->peer->ld, &channel->cid);
3983 return;
3984 }
3985
3986 inflight = channel_current_inflight(channel);
3987 if (!inflight) {
3988 channel_internal_error(channel,
3989 "No inflight found for channel");
3990 return;
3991 }
3992
3993 updated = wallet_update_channel_commit(ld, channel, inflight,
3994 remote_commit,
3995 &remote_commit_sig);
3996
3997 /* FIXME: handle RBF pbases */
3998 if (pbase && channel->state != DUALOPEND_AWAITING_LOCKIN) {
3999 wallet_penalty_base_add(ld->wallet,
4000 channel->dbid,
4001 pbase);
4002 }
4003
4004 switch (channel->opener) {
4005 case LOCAL:
4006 if (!channel->open_attempt || !channel->open_attempt->cmd) {
4007 log_info(channel->log, "No channel open attempt/command!");
4008 channel->open_attempt
4009 = tal_free(channel->open_attempt);
4010 return;
4011 }
4012 cmd = channel->open_attempt->cmd;
4013 response = build_commit_response(cmd, channel, inflight);
4014 channel->open_attempt
4015 = tal_free(channel->open_attempt);
4016 was_pending(command_success(cmd, response));
4017 return;

Callers 1

dual_opend_msgFunction · 0.85

Calls 13

tal_hexFunction · 0.85
tal_freeFunction · 0.85
channel_current_inflightFunction · 0.85
wallet_penalty_base_addFunction · 0.85
log_infoClass · 0.85
build_commit_responseFunction · 0.85
clone_psbtFunction · 0.85
abortFunction · 0.85
channel_internal_errorFunction · 0.70
was_pendingFunction · 0.70

Tested by

no test coverage detected