|
@ -2018,8 +2018,10 @@ static void fixup_hout(struct lightningd *ld, struct htlc_out *hout) |
|
|
* For each outgoing HTLC find the incoming HTLC that triggered it. If |
|
|
* For each outgoing HTLC find the incoming HTLC that triggered it. If |
|
|
* we are the origin of the transfer then we cannot resolve the |
|
|
* we are the origin of the transfer then we cannot resolve the |
|
|
* incoming HTLC in which case we just leave it `NULL`. |
|
|
* incoming HTLC in which case we just leave it `NULL`. |
|
|
|
|
|
* |
|
|
|
|
|
* Returns a map of any htlcs we need to retry. |
|
|
*/ |
|
|
*/ |
|
|
void htlcs_reconnect(struct lightningd *ld, |
|
|
struct htlc_in_map *htlcs_reconnect(struct lightningd *ld, |
|
|
struct htlc_in_map *htlcs_in, |
|
|
struct htlc_in_map *htlcs_in, |
|
|
struct htlc_out_map *htlcs_out) |
|
|
struct htlc_out_map *htlcs_out) |
|
|
{ |
|
|
{ |
|
@ -2027,8 +2029,7 @@ void htlcs_reconnect(struct lightningd *ld, |
|
|
struct htlc_out_map_iter outi; |
|
|
struct htlc_out_map_iter outi; |
|
|
struct htlc_in *hin; |
|
|
struct htlc_in *hin; |
|
|
struct htlc_out *hout; |
|
|
struct htlc_out *hout; |
|
|
struct htlc_in_map unprocessed; |
|
|
struct htlc_in_map *unprocessed = tal(NULL, struct htlc_in_map); |
|
|
enum onion_type failcode COMPILER_WANTS_INIT("gcc7.4.0 bad, 8.3 OK"); |
|
|
|
|
|
|
|
|
|
|
|
/* Any HTLCs which happened to be incoming and weren't forwarded before
|
|
|
/* Any HTLCs which happened to be incoming and weren't forwarded before
|
|
|
* we shutdown/crashed: fail them now. |
|
|
* we shutdown/crashed: fail them now. |
|
@ -2036,11 +2037,11 @@ void htlcs_reconnect(struct lightningd *ld, |
|
|
* Note that since we do local processing synchronously, so this never |
|
|
* Note that since we do local processing synchronously, so this never |
|
|
* captures local payments. But if it did, it would be a tiny corner |
|
|
* captures local payments. But if it did, it would be a tiny corner |
|
|
* case. */ |
|
|
* case. */ |
|
|
htlc_in_map_init(&unprocessed); |
|
|
htlc_in_map_init(unprocessed); |
|
|
for (hin = htlc_in_map_first(htlcs_in, &ini); hin; |
|
|
for (hin = htlc_in_map_first(htlcs_in, &ini); hin; |
|
|
hin = htlc_in_map_next(htlcs_in, &ini)) { |
|
|
hin = htlc_in_map_next(htlcs_in, &ini)) { |
|
|
if (hin->hstate == RCVD_ADD_ACK_REVOCATION) |
|
|
if (hin->hstate == RCVD_ADD_ACK_REVOCATION) |
|
|
htlc_in_map_add(&unprocessed, hin); |
|
|
htlc_in_map_add(unprocessed, hin); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for (hout = htlc_out_map_first(htlcs_out, &outi); hout; |
|
|
for (hout = htlc_out_map_first(htlcs_out, &outi); hout; |
|
@ -2081,12 +2082,22 @@ void htlcs_reconnect(struct lightningd *ld, |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
if (hout->in) |
|
|
if (hout->in) |
|
|
htlc_in_map_del(&unprocessed, hout->in); |
|
|
htlc_in_map_del(unprocessed, hout->in); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return unprocessed; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void htlcs_resubmit(struct lightningd *ld, struct htlc_in_map *unprocessed) |
|
|
|
|
|
{ |
|
|
|
|
|
struct htlc_in *hin; |
|
|
|
|
|
struct htlc_in_map_iter ini; |
|
|
|
|
|
enum onion_type failcode COMPILER_WANTS_INIT("gcc7.4.0 bad, 8.3 OK"); |
|
|
|
|
|
|
|
|
/* Now fail any which were stuck. */ |
|
|
/* Now fail any which were stuck. */ |
|
|
for (hin = htlc_in_map_first(&unprocessed, &ini); hin; |
|
|
for (hin = htlc_in_map_first(unprocessed, &ini); |
|
|
hin = htlc_in_map_next(&unprocessed, &ini)) { |
|
|
hin; |
|
|
|
|
|
hin = htlc_in_map_next(unprocessed, &ini)) { |
|
|
log_unusual(hin->key.channel->log, |
|
|
log_unusual(hin->key.channel->log, |
|
|
"Replaying old unprocessed HTLC #%"PRIu64, |
|
|
"Replaying old unprocessed HTLC #%"PRIu64, |
|
|
hin->key.id); |
|
|
hin->key.id); |
|
@ -2102,10 +2113,10 @@ void htlcs_reconnect(struct lightningd *ld, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* Don't leak memory! */ |
|
|
/* Don't leak memory! */ |
|
|
htlc_in_map_clear(&unprocessed); |
|
|
htlc_in_map_clear(unprocessed); |
|
|
|
|
|
tal_free(unprocessed); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if DEVELOPER |
|
|
#if DEVELOPER |
|
|
static struct command_result *json_dev_ignore_htlcs(struct command *cmd, |
|
|
static struct command_result *json_dev_ignore_htlcs(struct command *cmd, |
|
|
const char *buffer, |
|
|
const char *buffer, |
|
|