예제 #1
0
void queue_pkt_htlc_fulfill(struct peer *peer, struct htlc *htlc,
			    const struct rval *r)
{
	UpdateFulfillHtlc *f = tal(peer, UpdateFulfillHtlc);
	union htlc_staging stage;

	update_fulfill_htlc__init(f);
	f->id = htlc->id;
	f->r = rval_to_proto(f, r);

	/* 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_fulfill_htlc(peer->remote.staging_cstate, htlc, THEIRS);

	stage.fulfill.fulfill = HTLC_FULFILL;
	stage.fulfill.htlc = htlc;
	stage.fulfill.r = *r;
	add_unacked(&peer->remote, &stage);

	remote_changes_pending(peer);

	queue_pkt(peer, PKT__PKT_UPDATE_FULFILL_HTLC, f);
}
예제 #2
0
파일: packets.c 프로젝트: dooglus/lightning
void queue_pkt_htlc_fulfill(struct peer *peer,
		      const struct htlc_progress *htlc_prog)
{
	UpdateFulfillHtlc *f = tal(peer, UpdateFulfillHtlc);
	size_t n;

	update_fulfill_htlc__init(f);
	assert(htlc_prog->stage.type == HTLC_FULFILL);

	f->id = htlc_prog->stage.fulfill.id;
	f->r = sha256_to_proto(f, &htlc_prog->stage.fulfill.r);

	/* 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_fulfill_htlc(peer->them.staging_cstate, n);

	queue_pkt_with_ack(peer, PKT__PKT_UPDATE_FULFILL_HTLC, f,
			   fulfill_their_htlc_ourside, int2ptr(f->id));
}