mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
lightningd/channel: pass owner, not sender to channel_fulfill_htlc / channel_fail_htlc
I got this wrong when using them. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
85fd8218e2
commit
2d635a381b
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user