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

Function handle_unknown_commitment

onchaind/onchaind.c:3276–3387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3274}
3275
3276static void handle_unknown_commitment(const struct tx_parts *tx,
3277 u32 tx_blockheight,
3278 const struct basepoints basepoints[NUM_SIDES],
3279 struct tracked_output **outs)
3280{
3281 int to_us_output = -1;
3282 struct htlcs_info *htlcs_info;
3283
3284 onchain_annotate_txin(&tx->txid, 0, TX_CHANNEL_UNILATERAL | TX_THEIRS);
3285
3286 resolved_by_other(outs[0], &tx->txid, UNKNOWN_UNILATERAL);
3287
3288 /* Normally, csv is 1, but for option_will_fund, we need to
3289 * figure out what CSV lock was used */
3290 for (size_t csv = 1; csv <= LEASE_RATE_DURATION; csv++) {
3291 const u8 *local_script;
3292 local_script = scriptpubkey_to_remote(tmpctx,
3293 &basepoints[LOCAL].payment,
3294 csv);
3295
3296 for (size_t i = 0; i < tal_count(tx->outputs); i++) {
3297 struct amount_asset asset;
3298 struct amount_sat amt;
3299 struct bitcoin_outpoint outpoint;
3300 struct tracked_output *out;
3301
3302 if (!wally_tx_output_scripteq(tx->outputs[i],
3303 local_script))
3304 continue;
3305
3306 asset = wally_tx_output_get_amount(tx->outputs[i]);
3307 assert(amount_asset_is_main(&asset));
3308 amt = amount_asset_to_sat(&asset);
3309
3310 outpoint.txid = tx->txid;
3311 outpoint.n = i;
3312
3313 /* BOLT #5:
3314 *
3315 * - MAY take no action in regard to the associated
3316 * `to_remote`, which is simply a P2WPKH output to
3317 * the *local node*.
3318 * - Note: `to_remote` is considered *resolved* by the
3319 * commitment transaction itself.
3320 */
3321 out = new_tracked_output(&outs, &outpoint,
3322 tx_blockheight,
3323 UNKNOWN_UNILATERAL,
3324 amt,
3325 OUTPUT_TO_US, NULL, NULL, NULL);
3326 ignore_output(out);
3327
3328 tell_wallet_to_remote(tx, &outpoint,
3329 tx_blockheight,
3330 local_script,
3331 NULL,
3332 true,
3333 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