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

Function commit_index_from_msg

channeld/channeld.c:2449–2474  ·  view source on GitHub ↗

Returns 0 if this is for funding, and 1+ for items in inflight array. * Returns -1 if the value is not recognized. */

Source from the content-addressed store, hash-verified

2447 * Returns -1 if the value is not recognized.
2448 */
2449static int commit_index_from_msg(const u8 *msg, struct peer *peer)
2450{
2451 struct bitcoin_txid funding_txid;
2452 struct channel_id channel_id;
2453 struct bitcoin_signature commit_sig;
2454 secp256k1_ecdsa_signature *raw_sigs;
2455 struct tlv_commitment_signed_tlvs *cs_tlv
2456 = tlv_commitment_signed_tlvs_new(tmpctx);
2457 fromwire_commitment_signed(tmpctx, msg, &channel_id, &commit_sig.s,
2458 &raw_sigs, &cs_tlv);
2459
2460 if (!cs_tlv || !cs_tlv->splice_info)
2461 return -1;
2462
2463 funding_txid = *cs_tlv->splice_info;
2464
2465 if (bitcoin_txid_eq(&funding_txid, &peer->channel->funding.txid))
2466 return 0;
2467
2468 for (int i = 0; i < tal_count(peer->splice_state->inflights); i++)
2469 if (bitcoin_txid_eq(&funding_txid,
2470 &peer->splice_state->inflights[i]->outpoint.txid))
2471 return i + 1;
2472
2473 return -1;
2474}
2475
2476static int commit_cmp(const void *a, const void *n, void *peer)
2477{

Callers 1

commit_cmpFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected