Skip to content

Commit bac60bb

Browse files
committed
fixed bug in internal hsmd impl of validate_commitment_tx
1 parent 3ad8959 commit bac60bb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

hsmd/libhsmd.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,15 +1365,15 @@ static u8 *handle_validate_commitment_tx(struct hsmd_client *c, const u8 *msg_in
13651365
if (!derive_shaseed(&channel_seed, &shaseed))
13661366
return hsmd_status_bad_request(c, msg_in, "bad derive_shaseed");
13671367

1368-
if (!per_commit_point(&shaseed, &next_per_commitment_point, commit_num))
1368+
if (!per_commit_point(&shaseed, &next_per_commitment_point, commit_num + 1))
13691369
return hsmd_status_bad_request_fmt(
1370-
c, msg_in, "bad per_commit_point %" PRIu64, commit_num);
1370+
c, msg_in, "bad per_commit_point %" PRIu64, commit_num + 1);
13711371

1372-
if (commit_num >= 2) {
1372+
if (commit_num >= 1) {
13731373
old_secret = tal(tmpctx, struct secret);
1374-
if (!per_commit_secret(&shaseed, old_secret, commit_num - 2)) {
1374+
if (!per_commit_secret(&shaseed, old_secret, commit_num - 1)) {
13751375
return hsmd_status_bad_request_fmt(
1376-
c, msg_in, "Cannot derive secret %" PRIu64, commit_num - 2);
1376+
c, msg_in, "Cannot derive secret %" PRIu64, commit_num - 1);
13771377
}
13781378
} else {
13791379
old_secret = NULL;

0 commit comments

Comments
 (0)