Skip to content

Commit

Permalink
wallet: Use persistent shachain for remote secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
cdecker authored and rustyrussell committed Aug 10, 2017
1 parent 1ff64ef commit 85d2256
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lightningd/peer_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ void add_peer(struct lightningd *ld, u64 unique_id,
= peer->next_index[REMOTE]
= peer->num_revocations_received = 0;
peer->next_htlc_id = 0;
shachain_init(&peer->their_shachain);
wallet_shachain_init(ld->wallet, &peer->their_shachain);
peer->closing_sig_received = NULL;

idname = type_to_string(peer, struct pubkey, id);
Expand Down
3 changes: 2 additions & 1 deletion lightningd/peer_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <lightningd/channel_config.h>
#include <lightningd/peer_state.h>
#include <stdbool.h>
#include <wallet/wallet.h>
#include <wire/peer_wire.h>

#define ANNOUNCE_MIN_DEPTH 6
Expand All @@ -29,7 +30,7 @@ struct peer {
u8 *error;

/* Their shachain. */
struct shachain their_shachain;
struct wallet_shachain their_shachain;

/* What's happening. */
enum peer_state state;
Expand Down
6 changes: 3 additions & 3 deletions lightningd/peer_htlcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1131,9 +1131,9 @@ int peer_got_revoke(struct peer *peer, const u8 *msg)
* 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(revokenum),
&per_commitment_secret)) {
if (!wallet_shachain_add_hash(peer->ld->wallet, &peer->their_shachain,
shachain_index(revokenum),
&per_commitment_secret)) {
char *err = tal_fmt(peer,
"Bad per_commitment_secret %s for %"PRIu64,
type_to_string(msg, struct sha256,
Expand Down

0 comments on commit 85d2256

Please sign in to comment.