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

Function send_commit_part

channeld/channeld.c:1256–1369  ·  view source on GitHub ↗

Returns commitment_signed msg, sets @local_anchor */

Source from the content-addressed store, hash-verified

1254
1255/* Returns commitment_signed msg, sets @local_anchor */
1256static u8 *send_commit_part(const tal_t *ctx,
1257 struct peer *peer,
1258 const struct bitcoin_outpoint *funding,
1259 struct amount_sat funding_sats,
1260 const struct htlc **changed_htlcs,
1261 bool notify_master,
1262 s64 splice_amnt,
1263 s64 remote_splice_amnt,
1264 u64 remote_index,
1265 const struct pubkey *remote_per_commit,
1266 struct local_anchor_info **anchor,
1267 u16 batch_size,
1268 struct pubkey remote_funding_pubkey)
1269{
1270 u8 *msg;
1271 struct bitcoin_signature commit_sig, *htlc_sigs;
1272 struct bitcoin_tx **txs;
1273 const u8 *funding_wscript;
1274 const struct htlc **htlc_map;
1275 struct wally_tx_output *direct_outputs[NUM_SIDES];
1276 struct penalty_base *pbase;
1277 int local_anchor_outnum;
1278 struct pubkey funding_pubkeys[NUM_SIDES] =
1279 { peer->channel->funding_pubkey[LOCAL],
1280 remote_funding_pubkey };
1281 struct tlv_commitment_signed_tlvs *cs_tlv
1282 = tlv_commitment_signed_tlvs_new(tmpctx);
1283
1284 /* In theory, peer will ignore TLV 1 as unknown, but while
1285 * spec is in flux this is dangerous, as it may change: so don't
1286 * send unless negotiated */
1287 if (feature_negotiated(peer->our_features,
1288 peer->their_features,
1289 OPT_SPLICE)) {
1290 status_debug("send_commit_part(splice: %d, remote_splice: %d,"
1291 " index: %"PRIu64")",
1292 (int)splice_amnt, (int)remote_splice_amnt,
1293 remote_index);
1294
1295 cs_tlv->splice_info = tal_dup(cs_tlv, struct bitcoin_txid, &funding->txid);
1296 }
1297
1298 txs = channel_txs(tmpctx, funding, funding_sats, &htlc_map,
1299 direct_outputs, &funding_wscript,
1300 peer->channel, remote_per_commit,
1301 remote_index, REMOTE,
1302 splice_amnt, remote_splice_amnt, &local_anchor_outnum,
1303 funding_pubkeys);
1304 if (!txs)
1305 peer_failed_err(peer->pps, &peer->channel_id,
1306 "Could not create commitment %"PRIu64
1307 " for funding %s",
1308 remote_index,
1309 fmt_bitcoin_outpoint(tmpctx, funding));
1310
1311 if (direct_outputs[LOCAL] != NULL) {
1312 pbase = penalty_base_new(tmpctx, remote_index,
1313 txs[0], direct_outputs[LOCAL]);

Callers 3

send_commitFunction · 0.85
resend_commitmentFunction · 0.85

Calls 13

feature_negotiatedFunction · 0.85
channel_txsFunction · 0.85
fmt_bitcoin_outpointFunction · 0.85
penalty_base_newFunction · 0.85
bitcoin_tx_weightFunction · 0.85
bitcoin_tx_compute_feeFunction · 0.85
sending_commitsig_msgFunction · 0.85
master_wait_sync_replyFunction · 0.85
calc_commitsigsFunction · 0.85
raw_sigsFunction · 0.85
bitcoin_txidClass · 0.70

Tested by

no test coverage detected