From 437b65eba10b1d0d1316f44d8df467ca7879262a Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 23 Jul 2018 11:53:02 +0930 Subject: [PATCH] onchaind: clean up types for penalty transactions. We can use pubkey_from_secret() to avoid the ugly sha->secret->privkey conversion. Signed-off-by: Rusty Russell --- onchaind/onchain.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/onchaind/onchain.c b/onchaind/onchain.c index 5144daac3..ea3b12524 100644 --- a/onchaind/onchain.c +++ b/onchaind/onchain.c @@ -1676,7 +1676,6 @@ static void handle_their_cheat(const struct bitcoin_tx *tx, struct keyset *ks; size_t i; struct secret per_commitment_secret; - struct privkey per_commitment_privkey; struct pubkey per_commitment_point; init_reply("Tracking their illegal close: taking all funds"); @@ -1693,15 +1692,11 @@ static void handle_their_cheat(const struct bitcoin_tx *tx, == sizeof(*revocation_preimage)); memcpy(&per_commitment_secret, revocation_preimage, sizeof(per_commitment_secret)); - BUILD_ASSERT(sizeof(per_commitment_privkey) - == sizeof(*revocation_preimage)); - memcpy(&per_commitment_privkey, revocation_preimage, - sizeof(per_commitment_privkey)); - if (!pubkey_from_privkey(&per_commitment_privkey, &per_commitment_point)) + if (!pubkey_from_secret(&per_commitment_secret, &per_commitment_point)) status_failed(STATUS_FAIL_INTERNAL_ERROR, "Failed derive from per_commitment_secret %s", - type_to_string(tmpctx, struct privkey, - &per_commitment_privkey)); + type_to_string(tmpctx, struct secret, + &per_commitment_secret)); status_trace("Deriving keyset %"PRIu64 ": per_commit_point=%s"