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

Function fail

tests/plugins/channeld_fakenet.c:363–428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

361}
362
363static void fail(struct info *info,
364 struct fake_htlc *htlc STEALS,
365 const struct onion_payload *payload,
366 enum onion_wire failcode)
367{
368 struct failed_htlc *failed;
369 const struct failed_htlc **failed_arr;
370 u8 *msg;
371 struct changed_htlc *changed;
372 enum channel_remove_err err;
373
374 msg = tal_arr(tmpctx, u8, 0);
375 towire_u16(&msg, failcode);
376
377 status_debug("Failing payment at %s due to %s",
378 fmt_node_id(tmpctx, &current_node->id),
379 onion_wire_name(failcode));
380
381 err = channel_fail_htlc(info->channel,
382 LOCAL,
383 htlc->htlc_id,
384 NULL);
385 assert(err == CHANNEL_ERR_REMOVE_OK);
386
387 failed_arr = tal_arr(tmpctx, const struct failed_htlc *, 1);
388 failed_arr[0] = failed = tal(failed_arr, struct failed_htlc);
389 failed->id = htlc->htlc_id;
390 failed->sha256_of_onion = NULL;
391 failed->onion = create_onionreply(failed, &htlc->secrets[tal_count(htlc->secrets) - 1], msg);
392
393 /* We create backwards, using shared secrets to wrap */
394 for (int i = tal_count(htlc->secrets) - 1; i >= 0; i--)
395 failed->onion = wrap_onionreply(failed, &htlc->secrets[i], failed->onion);
396
397 msg = towire_channeld_got_commitsig(NULL,
398 info->commit_num,
399 info->fee_states,
400 info->blockheight_states,
401 &info->fakesig,
402 NULL,
403 NULL,
404 NULL,
405 failed_arr,
406 NULL,
407 info->commit_tx,
408 NULL);
409 daemon_conn_send(info->dc, take(msg));
410
411 changed = tal_arr(tmpctx, struct changed_htlc, 1);
412 changed->id = htlc->htlc_id;
413 changed->newstate = SENT_REMOVE_ACK_COMMIT;
414
415 /* Tell it we committed, too */
416 msg = towire_channeld_sending_commitsig(NULL,
417 info->commit_num,
418 NULL,
419 info->fee_states,
420 info->blockheight_states,

Callers 15

mainFunction · 0.85
add_valsFunction · 0.85
find_valsFunction · 0.85
del_valsFunction · 0.85
add_valsFunction · 0.85
find_valsFunction · 0.85
del_valsFunction · 0.85
add_valsFunction · 0.85
find_valsFunction · 0.85
del_valsFunction · 0.85
del_vals_bykeyFunction · 0.85
add_valsFunction · 0.85

Calls 8

fmt_node_idFunction · 0.85
channel_fail_htlcFunction · 0.85
create_onionreplyFunction · 0.85
wrap_onionreplyFunction · 0.85
daemon_conn_sendFunction · 0.85
pretend_got_revokeFunction · 0.85
tal_freeFunction · 0.85
towire_u16Function · 0.50

Tested by 15

mainFunction · 0.68
add_valsFunction · 0.68
find_valsFunction · 0.68
del_valsFunction · 0.68
add_valsFunction · 0.68
find_valsFunction · 0.68
del_valsFunction · 0.68
add_valsFunction · 0.68
find_valsFunction · 0.68
del_valsFunction · 0.68
del_vals_bykeyFunction · 0.68
add_valsFunction · 0.68