|
@ -364,7 +364,8 @@ void add_peer(struct lightningd *ld, u64 unique_id, |
|
|
peer->channel_info = NULL; |
|
|
peer->channel_info = NULL; |
|
|
peer->last_was_revoke = false; |
|
|
peer->last_was_revoke = false; |
|
|
peer->last_sent_commit = NULL; |
|
|
peer->last_sent_commit = NULL; |
|
|
peer->num_commits_sent = peer->num_commits_received |
|
|
peer->commit_index[LOCAL] |
|
|
|
|
|
= peer->commit_index[REMOTE] |
|
|
= peer->num_revocations_received = 0; |
|
|
= peer->num_revocations_received = 0; |
|
|
peer->next_htlc_id = 0; |
|
|
peer->next_htlc_id = 0; |
|
|
shachain_init(&peer->their_shachain); |
|
|
shachain_init(&peer->their_shachain); |
|
@ -1058,8 +1059,8 @@ static bool peer_start_channeld_hsmfd(struct subd *hsm, const u8 *resp, |
|
|
cfg->deadline_blocks, |
|
|
cfg->deadline_blocks, |
|
|
peer->last_was_revoke, |
|
|
peer->last_was_revoke, |
|
|
peer->last_sent_commit, |
|
|
peer->last_sent_commit, |
|
|
peer->num_commits_sent, |
|
|
peer->commit_index[LOCAL], |
|
|
peer->num_commits_received, |
|
|
peer->commit_index[REMOTE], |
|
|
peer->num_revocations_received, |
|
|
peer->num_revocations_received, |
|
|
peer->next_htlc_id, |
|
|
peer->next_htlc_id, |
|
|
htlcs, htlc_states, |
|
|
htlcs, htlc_states, |
|
@ -1110,6 +1111,14 @@ static void peer_start_channeld(struct peer *peer, enum peer_state oldstate, |
|
|
-1, 1, peer_start_channeld_hsmfd, peer); |
|
|
-1, 1, peer_start_channeld_hsmfd, peer); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static bool peer_commit_initial(struct peer *peer) |
|
|
|
|
|
{ |
|
|
|
|
|
peer->commit_index[LOCAL] = peer->commit_index[REMOTE] = 1; |
|
|
|
|
|
|
|
|
|
|
|
/* FIXME: Db channel_info, etc. */ |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
static bool opening_funder_finished(struct subd *opening, const u8 *resp, |
|
|
static bool opening_funder_finished(struct subd *opening, const u8 *resp, |
|
|
const int *fds, |
|
|
const int *fds, |
|
|
struct funding_channel *fc) |
|
|
struct funding_channel *fc) |
|
@ -1181,10 +1190,8 @@ static bool opening_funder_finished(struct subd *opening, const u8 *resp, |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* We should have sent and received the first commitsig */ |
|
|
if (!peer_commit_initial(fc->peer)) { |
|
|
if (!peer_save_commitsig_received(fc->peer, 0) |
|
|
peer_internal_error(fc->peer, "Initial peer to db failed"); |
|
|
|| !peer_save_commitsig_sent(fc->peer, 0)) { |
|
|
|
|
|
peer_internal_error(fc->peer, "Saving commitsig failed"); |
|
|
|
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -1245,9 +1252,7 @@ static bool opening_fundee_finished(struct subd *opening, |
|
|
/* old_remote_per_commit not valid yet, copy valid one. */ |
|
|
/* old_remote_per_commit not valid yet, copy valid one. */ |
|
|
channel_info->old_remote_per_commit = channel_info->remote_per_commit; |
|
|
channel_info->old_remote_per_commit = channel_info->remote_per_commit; |
|
|
|
|
|
|
|
|
/* We should have sent and received the first commitsig */ |
|
|
if (!peer_commit_initial(peer)) |
|
|
if (!peer_save_commitsig_received(peer, 0) |
|
|
|
|
|
|| !peer_save_commitsig_sent(peer, 0)) |
|
|
|
|
|
return false; |
|
|
return false; |
|
|
|
|
|
|
|
|
log_debug(peer->log, "Watching funding tx %s", |
|
|
log_debug(peer->log, "Watching funding tx %s", |
|
|