diff --git a/lightningd/htlc_end.c b/lightningd/htlc_end.c index 6a775f0e6..de2c138de 100644 --- a/lightningd/htlc_end.c +++ b/lightningd/htlc_end.c @@ -143,8 +143,8 @@ struct htlc_out *htlc_out_check(const struct htlc_out *hout, else if (hout->failuremsg && hout->preimage) return corrupt(abortstr, "Both failed and succeeded"); - if (hout->local && hout->in) - return corrupt(abortstr, "Both local and incoming"); + if (hout->am_origin && hout->in) + return corrupt(abortstr, "Both origin and incoming"); if (hout->in) { if (hout->in->msatoshi < hout->msatoshi) @@ -240,7 +240,7 @@ struct htlc_out *new_htlc_out(const tal_t *ctx, u64 msatoshi, u32 cltv_expiry, const struct sha256 *payment_hash, const u8 *onion_routing_packet, - bool local, + bool am_origin, struct htlc_in *in) { struct htlc_out *hout = tal(ctx, struct htlc_out); @@ -261,7 +261,7 @@ struct htlc_out *new_htlc_out(const tal_t *ctx, hout->failuremsg = NULL; hout->preimage = NULL; - hout->local = local; + hout->am_origin = am_origin; hout->in = NULL; if (in) htlc_out_connect_htlc_in(hout, in); diff --git a/lightningd/htlc_end.h b/lightningd/htlc_end.h index 4660c081d..977bd2209 100644 --- a/lightningd/htlc_end.h +++ b/lightningd/htlc_end.h @@ -71,10 +71,11 @@ struct htlc_out { const u8 *failuremsg; /* If we fulfilled, here's the preimage. */ + /* FIXME: This is basically unused, except as a bool! */ struct preimage *preimage; - /* Is this local? Implies ->in is NULL. */ - bool local; + /* Is this a locally-generated payment? Implies ->in is NULL. */ + bool am_origin; /* Where it's from, if not going to us. */ struct htlc_in *in; @@ -132,7 +133,7 @@ struct htlc_out *new_htlc_out(const tal_t *ctx, u64 msatoshi, u32 cltv_expiry, const struct sha256 *payment_hash, const u8 *onion_routing_packet, - bool local, + bool am_origin, struct htlc_in *in); void connect_htlc_in(struct htlc_in_map *map, struct htlc_in *hin); diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index c03c9d4cb..034ef2340 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -139,7 +139,7 @@ static void fail_out_htlc(struct htlc_out *hout, const char *localfail) { htlc_out_check(hout, __func__); assert(hout->failcode || hout->failuremsg); - if (hout->local) { + if (hout->am_origin) { payment_failed(hout->key.channel->peer->ld, hout, localfail); } else if (hout->in) { fail_in_htlc(hout->in, hout->failcode, hout->failuremsg, @@ -381,7 +381,7 @@ static void rcvd_htlc_reply(struct subd *subd, const u8 *msg, const int *fds UNU if (failure_code) { hout->failcode = (enum onion_type) failure_code; - if (hout->local) { + if (hout->am_origin) { char *localfail = tal_fmt(msg, "%s: %.*s", onion_type_name(failure_code), (int)tal_count(failurestr), @@ -733,7 +733,7 @@ static void fulfill_our_htlc_out(struct channel *channel, struct htlc_out *hout, channel->dbid, hout->msatoshi); - if (hout->local) + if (hout->am_origin) payment_succeeded(ld, hout, preimage); else if (hout->in) fulfill_htlc(hout->in, preimage); @@ -872,7 +872,7 @@ void onchain_failed_our_htlc(const struct channel *channel, wallet_htlc_update(channel->peer->ld->wallet, hout->dbid, hout->hstate, hout->preimage, hout->failcode, hout->failuremsg); - if (hout->local) { + if (hout->am_origin) { assert(why != NULL); char *localfail = tal_fmt(channel, "%s: %s", onion_type_name(WIRE_PERMANENT_CHANNEL_FAILURE), @@ -1746,7 +1746,7 @@ void htlcs_reconnect(struct lightningd *ld, for (hout = htlc_out_map_first(htlcs_out, &outi); hout; hout = htlc_out_map_next(htlcs_out, &outi)) { - if (hout->local) { + if (hout->am_origin) { continue; } diff --git a/wallet/wallet.c b/wallet/wallet.c index bd3ca3760..aeae341c3 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -1349,10 +1349,10 @@ static bool wallet_stmt2htlc_out(struct channel *channel, if (sqlite3_column_type(stmt, 10) != SQLITE_NULL) { out->origin_htlc_id = sqlite3_column_int64(stmt, 10); - out->local = false; + out->am_origin = false; } else { out->origin_htlc_id = 0; - out->local = true; + out->am_origin = true; } /* Need to defer wiring until we can look up all incoming @@ -1399,7 +1399,6 @@ static void fixup_hin(struct wallet *wallet, struct htlc_in *hin) #endif } - bool wallet_htlcs_load_for_channel(struct wallet *wallet, struct channel *chan, struct htlc_in_map *htlcs_in,