Esempio n. 1
0
void queue_pkt_htlc_fail(struct peer *peer, struct htlc *htlc)
{
	UpdateFailHtlc *f = tal(peer, UpdateFailHtlc);
	union htlc_staging stage;

	update_fail_htlc__init(f);
	f->id = htlc->id;

	/* FIXME: reason! */
	f->reason = tal(f, FailReason);
	fail_reason__init(f->reason);

	/* BOLT #2:
	 *
	 * The sending node MUST add the HTLC fulfill/fail to the
	 * unacked changeset for its remote commitment
	 */
	assert(cstate_htlc_by_id(peer->remote.staging_cstate, f->id, THEIRS)
	       == htlc);
	cstate_fail_htlc(peer->remote.staging_cstate, htlc, THEIRS);

	stage.fail.fail = HTLC_FAIL;
	stage.fail.htlc = htlc;
	add_unacked(&peer->remote, &stage);

	remote_changes_pending(peer);
	queue_pkt(peer, PKT__PKT_UPDATE_FAIL_HTLC, f);
}
Esempio n. 2
0
void queue_pkt_htlc_fail(struct peer *peer,
		   const struct htlc_progress *htlc_prog)
{
	UpdateFailHtlc *f = tal(peer, UpdateFailHtlc);
	size_t n;

	update_fail_htlc__init(f);
	assert(htlc_prog->stage.type == HTLC_FAIL);

	f->id = htlc_prog->stage.fail.id;
	/* FIXME: reason! */
	f->reason = tal(f, FailReason);
	fail_reason__init(f->reason);

	/* We're about to send this, so their side will have it from now on. */
	n = funding_htlc_by_id(&peer->them.staging_cstate->a, f->id);
	funding_a_fail_htlc(peer->them.staging_cstate, n);

	queue_pkt_with_ack(peer, PKT__PKT_UPDATE_FAIL_HTLC, f,
			   fail_their_htlc_ourside, int2ptr(f->id));
}