mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 10:46:58 +01:00
daemon: route fulfill back.
As soon as an HTLC we offered is fulfilled, fulfill the HTLC which caused it. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
21fe4fbba7
commit
31a5de644a
3 changed files with 13 additions and 6 deletions
|
@ -737,6 +737,9 @@ Pkt *accept_pkt_htlc_fulfill(struct peer *peer, const Pkt *pkt)
|
|||
if (!structeq(&rhash, &htlc->rhash))
|
||||
return pkt_err(peer, "Invalid r for %"PRIu64, f->id);
|
||||
|
||||
/* We can relay this upstream immediately. */
|
||||
our_htlc_fulfilled(peer, htlc, &r);
|
||||
|
||||
/* BOLT #2:
|
||||
*
|
||||
* ... and the receiving node MUST add the HTLC fulfill/fail
|
||||
|
|
|
@ -43,8 +43,6 @@
|
|||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define FIXME_STUB(peer) do { log_broken((peer)->dstate->base_log, "%s:%u: Implement %s!", __FILE__, __LINE__, __func__); abort(); } while(0)
|
||||
|
||||
struct json_connecting {
|
||||
/* This owns us, so we're freed after command_fail or command_success */
|
||||
struct command *cmd;
|
||||
|
@ -1635,9 +1633,13 @@ static void resolve_our_htlcs(struct peer *peer,
|
|||
* preimage. Otherwise, the other node could spend it once it as *timed out*
|
||||
* as above.
|
||||
*/
|
||||
bool resolve_one_htlc(struct peer *peer, u64 id, const struct rval *preimage)
|
||||
void our_htlc_fulfilled(struct peer *peer, struct htlc *htlc,
|
||||
const struct rval *preimage)
|
||||
{
|
||||
FIXME_STUB(peer);
|
||||
if (htlc->src)
|
||||
command_htlc_fulfill(htlc->src->peer, htlc->src, preimage);
|
||||
else
|
||||
complete_pay_command(peer, htlc, preimage);
|
||||
}
|
||||
|
||||
static void their_htlc_depth(struct peer *peer,
|
||||
|
@ -2514,7 +2516,7 @@ void peer_both_committed_to(struct peer *peer,
|
|||
their_htlc_added(peer, changes[i].add.htlc);
|
||||
break;
|
||||
case HTLC_FULFILL:
|
||||
/* FIXME: resolve_one_htlc(peer, id, preimage); */
|
||||
/* We handled this as soon as we got it. */
|
||||
break;
|
||||
case HTLC_FAIL:
|
||||
our_htlc_failed(peer, changes[i].fail.htlc);
|
||||
|
|
|
@ -269,5 +269,7 @@ struct bitcoin_tx *peer_create_close_tx(struct peer *peer, u64 fee);
|
|||
uint64_t commit_tx_fee(const struct bitcoin_tx *commit,
|
||||
uint64_t anchor_satoshis);
|
||||
|
||||
bool resolve_one_htlc(struct peer *peer, u64 id, const struct rval *preimage);
|
||||
void our_htlc_fulfilled(struct peer *peer, struct htlc *htlc,
|
||||
const struct rval *preimage);
|
||||
|
||||
#endif /* LIGHTNING_DAEMON_PEER_H */
|
||||
|
|
Loading…
Add table
Reference in a new issue