Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions bitcoin/shadouble.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,22 @@ void sha256_double(struct sha256_double *shadouble, const void *p, size_t len)
sha256(&shadouble->sha, &shadouble->sha, sizeof(shadouble->sha));
}

void sha256_single(struct sha256_double *shasingle, const void *p, size_t len)
{
sha256(&shasingle->sha, memcheck(p, len), len);
}

void sha256_double_done(struct sha256_ctx *shactx, struct sha256_double *res)
{
sha256_done(shactx, &res->sha);
sha256(&res->sha, &res->sha, sizeof(res->sha));
}

void sha256_single_done(struct sha256_ctx *shactx, struct sha256_double *res)
{
sha256_done(shactx, &res->sha);
}

REGISTER_TYPE_TO_HEXSTR(sha256_double);

void towire_sha256_double(u8 **pptr, const struct sha256_double *sha256d)
Expand Down
4 changes: 4 additions & 0 deletions bitcoin/shadouble.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ void sha256_double(struct sha256_double *shadouble, const void *p, size_t len);

void sha256_double_done(struct sha256_ctx *sha256, struct sha256_double *res);

void sha256_single(struct sha256_double *shasingle, const void *p, size_t len);

void sha256_single_done(struct sha256_ctx *sha256, struct sha256_double *res);

/* marshal/unmarshal functions */
void fromwire_sha256_double(const u8 **cursor, size_t *max,
struct sha256_double *sha256d);
Expand Down
2 changes: 1 addition & 1 deletion bitcoin/tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ void wally_txid(const struct wally_tx *wtx, struct bitcoin_txid *txid)
res = wally_tx_to_bytes(wtx, 0, arr, len, &written);
assert(len == written);

sha256_double(&txid->shad, arr, len);
sha256_single(&txid->shad, arr, len);
tal_free(arr);
}

Expand Down