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

Function handle_unknown_commitment

onchaind/onchaind.c:3302–3413  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3300}
3301
3302static void handle_unknown_commitment(const struct tx_parts *tx,
3303 u32 tx_blockheight,
3304 const struct basepoints basepoints[NUM_SIDES],
3305 struct tracked_output **outs)
3306{
3307 int to_us_output = -1;
3308 struct htlcs_info *htlcs_info;
3309
3310 onchain_annotate_txin(&tx->txid, 0, TX_CHANNEL_UNILATERAL | TX_THEIRS);
3311
3312 resolved_by_other(outs[0], &tx->txid, UNKNOWN_UNILATERAL);
3313
3314 /* Normally, csv is 1, but for option_will_fund, we need to
3315 * figure out what CSV lock was used */
3316 for (size_t csv = 1; csv <= LEASE_RATE_DURATION; csv++) {
3317 const u8 *local_script;
3318 local_script = scriptpubkey_to_remote(tmpctx,
3319 &basepoints[LOCAL].payment,
3320 csv);
3321
3322 for (size_t i = 0; i < tal_count(tx->outputs); i++) {
3323 struct amount_asset asset;
3324 struct amount_sat amt;
3325 struct bitcoin_outpoint outpoint;
3326 struct tracked_output *out;
3327
3328 if (!wally_tx_output_scripteq(tx->outputs[i],
3329 local_script))
3330 continue;
3331
3332 asset = wally_tx_output_get_amount(tx->outputs[i]);
3333 assert(amount_asset_is_main(&asset));
3334 amt = amount_asset_to_sat(&asset);
3335
3336 outpoint.txid = tx->txid;
3337 outpoint.n = i;
3338
3339 /* BOLT #5:
3340 *
3341 * - MAY take no action in regard to the associated
3342 * `to_remote`, which is simply a P2WPKH output to
3343 * the *local node*.
3344 * - Note: `to_remote` is considered *resolved* by the
3345 * commitment transaction itself.
3346 */
3347 out = new_tracked_output(&outs, &outpoint,
3348 tx_blockheight,
3349 UNKNOWN_UNILATERAL,
3350 amt,
3351 OUTPUT_TO_US, NULL, NULL, NULL);
3352 ignore_output(out);
3353
3354 tell_wallet_to_remote(tx, &outpoint,
3355 tx_blockheight,
3356 local_script,
3357 NULL,
3358 true,
3359 csv);

Callers 1

mainFunction · 0.85

Calls 15

resolved_by_otherFunction · 0.85
scriptpubkey_to_remoteFunction · 0.85
wally_tx_output_scripteqFunction · 0.85
new_tracked_outputFunction · 0.85
ignore_outputFunction · 0.85
tell_wallet_to_remoteFunction · 0.85
record_external_outputFunction · 0.85
init_replyFunction · 0.85
tal_freeFunction · 0.85
wait_for_resolvedFunction · 0.85

Tested by

no test coverage detected