core-lightning/bitcoin/shadouble.c
Rusty Russell 810abb6b21 bitcoin: create new wrapper type bitcoin_blkid, log backward endianness.
It's just a sha256_double, but importantly when we convert it to a
string (in type_to_string, which is used in logging) we use
bitcoin_blkid_to_hex() so it's reversed as people expect.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-12-21 11:05:38 +00:00

15 lines
414 B
C

#include "shadouble.h"
#include <ccan/mem/mem.h>
void sha256_double(struct sha256_double *shadouble, const void *p, size_t len)
{
sha256(&shadouble->sha, memcheck(p, len), len);
sha256(&shadouble->sha, &shadouble->sha, sizeof(shadouble->sha));
}
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));
}