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

Function handle_unknown_commitment

onchaind/onchaind.c:3454–3567  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3452}
3453
3454static void handle_unknown_commitment(const struct tx_parts *tx,
3455 u32 tx_blockheight,
3456 const struct basepoints basepoints[NUM_SIDES],
3457 struct tracked_output **outs)
3458{
3459 int to_us_output = -1;
3460 struct htlcs_info *htlcs_info;
3461
3462 onchain_annotate_txin(&tx->txid, 0, TX_CHANNEL_UNILATERAL | TX_THEIRS);
3463
3464 resolved_by_other(outs[0], &tx->txid, UNKNOWN_UNILATERAL);
3465
3466 /* Normally, csv is 1, but for option_will_fund, we need to
3467 * figure out what CSV lock was used */
3468 for (size_t csv = 1; csv <= LEASE_RATE_DURATION; csv++) {
3469 const u8 *local_script;
3470 local_script = scriptpubkey_to_remote(tmpctx,
3471 &basepoints[LOCAL].payment,
3472 csv);
3473
3474 for (size_t i = 0; i < tal_count(tx->outputs); i++) {
3475 struct amount_asset asset;
3476 struct amount_sat amt;
3477 struct bitcoin_outpoint outpoint;
3478 struct tracked_output *out;
3479
3480 if (!wally_tx_output_scripteq(tx->outputs[i],
3481 local_script))
3482 continue;
3483
3484 asset = wally_tx_output_get_amount(tx->outputs[i]);
3485 assert(amount_asset_is_main(&asset));
3486 amt = amount_asset_to_sat(&asset);
3487
3488 outpoint.txid = tx->txid;
3489 outpoint.n = i;
3490
3491 /* BOLT #5:
3492 *
3493 * - MAY take no action in regard to the associated
3494 * `to_remote`, which is simply a P2WPKH output to
3495 * the *local node*.
3496 * - Note: `to_remote` is considered *resolved* by the
3497 * commitment transaction itself.
3498 */
3499 out = new_tracked_output(&outs, &outpoint,
3500 tx_blockheight,
3501 UNKNOWN_UNILATERAL,
3502 amt,
3503 OUTPUT_TO_US, NULL, NULL, NULL);
3504 ignore_output(out);
3505
3506 tell_wallet_to_remote(tx, &outpoint,
3507 tx_blockheight,
3508 local_script,
3509 NULL,
3510 true,
3511 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