|
|
@ -3,7 +3,6 @@ |
|
|
|
#include <ccan/cast/cast.h> |
|
|
|
#include <ccan/container_of/container_of.h> |
|
|
|
#include <ccan/crypto/hkdf_sha256/hkdf_sha256.h> |
|
|
|
#include <ccan/crypto/shachain/shachain.h> |
|
|
|
#include <ccan/fdpass/fdpass.h> |
|
|
|
#include <ccan/io/io.h> |
|
|
|
#include <ccan/mem/mem.h> |
|
|
@ -65,9 +64,6 @@ struct peer { |
|
|
|
/* Our shaseed for generating per-commitment-secrets. */ |
|
|
|
struct sha256 shaseed; |
|
|
|
|
|
|
|
/* Their shachain. */ |
|
|
|
struct shachain their_shachain; |
|
|
|
|
|
|
|
/* BOLT #2:
|
|
|
|
* |
|
|
|
* A sending node MUST set `id` to 0 for the first HTLC it offers, and |
|
|
@ -893,23 +889,6 @@ static struct io_plan *handle_peer_revoke_and_ack(struct io_conn *conn, |
|
|
|
&peer->old_per_commit[REMOTE])); |
|
|
|
} |
|
|
|
|
|
|
|
/* BOLT #2:
|
|
|
|
* |
|
|
|
* A receiving node MAY fail if the `per_commitment_secret` was not |
|
|
|
* generated by the protocol in [BOLT #3] |
|
|
|
*/ |
|
|
|
if (!shachain_add_hash(&peer->their_shachain, |
|
|
|
shachain_index(peer->commit_index[REMOTE]), |
|
|
|
&old_commit_secret)) { |
|
|
|
peer_failed(io_conn_fd(peer->peer_conn), |
|
|
|
&peer->pcs.cs, |
|
|
|
&peer->channel_id, |
|
|
|
WIRE_CHANNEL_PEER_BAD_MESSAGE, |
|
|
|
"Bad shachain for privkey %"PRIu64" %s ", |
|
|
|
peer->commit_index[REMOTE], |
|
|
|
type_to_string(msg, struct privkey, &privkey)); |
|
|
|
} |
|
|
|
|
|
|
|
/* We start timer even if this returns false: we might have delayed
|
|
|
|
* commit because we were waiting for this! */ |
|
|
|
if (channel_rcvd_revoke_and_ack(peer->channel, &changed_htlcs)) |
|
|
@ -917,10 +896,6 @@ static struct io_plan *handle_peer_revoke_and_ack(struct io_conn *conn, |
|
|
|
else |
|
|
|
status_trace("No commits outstanding after recv revoke_and_ack"); |
|
|
|
|
|
|
|
peer->commit_index[REMOTE]++; |
|
|
|
peer->old_per_commit[REMOTE] = peer->current_per_commit[REMOTE]; |
|
|
|
peer->current_per_commit[REMOTE] = next_per_commit; |
|
|
|
|
|
|
|
/* Tell master about things this locks in, wait for response */ |
|
|
|
msg = got_revoke_msg(msg, peer->commit_index[REMOTE], |
|
|
|
&old_commit_secret, changed_htlcs); |
|
|
@ -928,6 +903,10 @@ static struct io_plan *handle_peer_revoke_and_ack(struct io_conn *conn, |
|
|
|
WIRE_CHANNEL_GOT_REVOKE_REPLY, |
|
|
|
handle_reply_wake_peer); |
|
|
|
|
|
|
|
peer->commit_index[REMOTE]++; |
|
|
|
peer->old_per_commit[REMOTE] = peer->current_per_commit[REMOTE]; |
|
|
|
peer->current_per_commit[REMOTE] = next_per_commit; |
|
|
|
|
|
|
|
/* And peer waits for reply. */ |
|
|
|
return io_wait(conn, peer, accepted_revocation, peer); |
|
|
|
} |
|
|
@ -1648,8 +1627,6 @@ int main(int argc, char *argv[]) |
|
|
|
sizeof(peer->announcement_bitcoin_sigs[i])); |
|
|
|
} |
|
|
|
|
|
|
|
shachain_init(&peer->their_shachain); |
|
|
|
|
|
|
|
status_setup_async(&peer->master); |
|
|
|
msg_queue_init(&peer->peer_out, peer); |
|
|
|
|
|
|
|