diff --git a/lightningd/channel.c b/lightningd/channel.c index 28ba8fd7b..a7e2f7811 100644 --- a/lightningd/channel.c +++ b/lightningd/channel.c @@ -481,15 +481,14 @@ struct htlc *channel_get_htlc(struct channel *channel, enum side sender, u64 id) } enum channel_remove_err channel_fulfill_htlc(struct channel *channel, - enum side sender, + enum side owner, u64 id, const struct preimage *preimage) { struct sha256 hash; struct htlc *htlc; - /* Fulfill is done by !creator of HTLC */ - htlc = channel_get_htlc(channel, !sender, id); + htlc = channel_get_htlc(channel, owner, id); if (!htlc) return CHANNEL_ERR_NO_SUCH_ID; @@ -541,12 +540,11 @@ enum channel_remove_err channel_fulfill_htlc(struct channel *channel, } enum channel_remove_err channel_fail_htlc(struct channel *channel, - enum side sender, u64 id) + enum side owner, u64 id) { struct htlc *htlc; - /* Fail is done by !creator of HTLC */ - htlc = channel_get_htlc(channel, !sender, id); + htlc = channel_get_htlc(channel, owner, id); if (!htlc) return CHANNEL_ERR_NO_SUCH_ID; diff --git a/lightningd/channel.h b/lightningd/channel.h index 82d38b3df..c3c5ca616 100644 --- a/lightningd/channel.h +++ b/lightningd/channel.h @@ -261,19 +261,19 @@ enum channel_remove_err { /** * channel_fail_htlc: remove an HTLC, funds to the side which offered it. * @channel: The channel state - * @sender: the side fulfilling the HTLC (opposite to side which sent it) + * @owner: the side who offered the HTLC (opposite to that failing it) * @id: unique HTLC id. * * This will remove the htlc and credit the value of the HTLC (back) * to its offerer. */ enum channel_remove_err channel_fail_htlc(struct channel *channel, - enum side sender, u64 id); + enum side owner, u64 id); /** * channel_fulfill_htlc: remove an HTLC, funds to side which accepted it. * @channel: The channel state - * @sender: the side fulfilling the HTLC (opposite to side which sent it) + * @owner: the side who offered the HTLC (opposite to that fulfilling it) * @id: unique HTLC id. * * If the htlc exists, is not already fulfilled, the preimage is correct and @@ -282,7 +282,7 @@ enum channel_remove_err channel_fail_htlc(struct channel *channel, * and return CHANNEL_ERR_FULFILL_OK. Otherwise, it will return another error. */ enum channel_remove_err channel_fulfill_htlc(struct channel *channel, - enum side sender, + enum side owner, u64 id, const struct preimage *preimage); diff --git a/lightningd/test/run-channel.c b/lightningd/test/run-channel.c index 048a30c58..d852a2a74 100644 --- a/lightningd/test/run-channel.c +++ b/lightningd/test/run-channel.c @@ -255,7 +255,7 @@ static void send_and_fulfill_htlc(struct channel *channel, assert(ret); ret = channel_sending_revoke_and_ack(channel); assert(!ret); - assert(channel_fulfill_htlc(channel, REMOTE, 1337, &r) + assert(channel_fulfill_htlc(channel, LOCAL, 1337, &r) == CHANNEL_ERR_REMOVE_OK); ret = channel_rcvd_commit(channel, NULL, NULL); assert(ret); @@ -277,7 +277,7 @@ static void send_and_fulfill_htlc(struct channel *channel, ret = channel_rcvd_revoke_and_ack(channel, NULL, do_nothing, NULL); assert(!ret); - assert(channel_fulfill_htlc(channel, LOCAL, 1337, &r) + assert(channel_fulfill_htlc(channel, REMOTE, 1337, &r) == CHANNEL_ERR_REMOVE_OK); ret = channel_sending_commit(channel); assert(ret);