diff --git a/bitcoin/Makefile b/bitcoin/Makefile index 175b7455c54a..71f3b27c6fbf 100644 --- a/bitcoin/Makefile +++ b/bitcoin/Makefile @@ -24,6 +24,7 @@ BITCOIN_HEADERS := bitcoin/address.h \ bitcoin/block.h \ bitcoin/chainparams.h \ bitcoin/feerate.h \ + bitcoin/groestl.h \ bitcoin/locktime.h \ bitcoin/preimage.h \ bitcoin/privkey.h \ diff --git a/bitcoin/base58.c b/bitcoin/base58.c index e854a73e9843..9057ffd65934 100644 --- a/bitcoin/base58.c +++ b/bitcoin/base58.c @@ -9,6 +9,7 @@ #include "pubkey.h" #include "shadouble.h" #include +#include #include #include #include @@ -19,6 +20,7 @@ extern void groestlhash(void *, const void * , size_t len); static bool my_sha256(void *digest, const void *data, size_t datasz) { +#ifndef COMPILE_FOR_BITCOIN /* make groestl hash compatible to luke's lib */ static bool si = false; uint32_t my_hash[16]; @@ -28,7 +30,10 @@ static bool my_sha256(void *digest, const void *data, size_t datasz) } else { memcpy(digest, my_hash, 32); si = false; - } + }; +#else + sha256(digest, data, datasz); +#endif return true; } diff --git a/bitcoin/groestl.c b/bitcoin/groestl.c index ba070e89a11d..b16d78b832d2 100644 --- a/bitcoin/groestl.c +++ b/bitcoin/groestl.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -5,9 +6,6 @@ #include #include - -void groestlhash(void *, const void *, size_t len); - void groestlhash(void *output, const void *input , size_t len) { uint32_t hash[16]; @@ -47,25 +45,5 @@ void groestlhash(void *output, const void *input , size_t len) } -void groestl_single_hash(void *, const void *, size_t len); - - -void groestl_single_hash(void *output, const void *input , size_t len) -{ - uint32_t hash[16]; - sph_groestl512_context ctx; - - sph_groestl512_init(&ctx); - sph_groestl512(&ctx, input, len); - sph_groestl512_close(&ctx, hash); - int ii; - printf("groestl ouput: "); - for (ii=0; ii < len; ii++) - { - printf ("%.2x",((uint8_t*)hash)[ii]); - }; - memcpy(output, hash, 32); - -} diff --git a/bitcoin/groestl.h b/bitcoin/groestl.h new file mode 100644 index 000000000000..6c01e0ed124c --- /dev/null +++ b/bitcoin/groestl.h @@ -0,0 +1,7 @@ +#ifndef LIGHTNING_BITCOIN_GROESTL_H +#define LIGHTNING_BITCOIN_GROESTL_H +#include "config.h" +#include + +void groestlhash(void *, const void * , size_t); +#endif /* LIGHTNING_BITCOIN_GROESTL_H */ diff --git a/bitcoin/shadouble.c b/bitcoin/shadouble.c index 7be01b6f67f1..13eae037df7b 100644 --- a/bitcoin/shadouble.c +++ b/bitcoin/shadouble.c @@ -1,8 +1,8 @@ #include "shadouble.h" +#include #include #include - -extern void groestlhash(void *, const void * , size_t len); +#include void sha256_double(struct sha256_double *shadouble, const void *p, size_t len) { @@ -13,6 +13,9 @@ void sha256_double(struct sha256_double *shadouble, const void *p, size_t len) void sha256_double_done(struct sha256_ctx *shactx, struct sha256_double *res) { sha256_done(shactx, &res->sha); - /* FIXME sha256(&res->sha, &res->sha, sizeof(res->sha)); */ +#ifdef COMPILE_FOR_BITCOIN + /* FIXME */ + sha256(&res->sha, &res->sha, sizeof(res->sha)); +#endif } REGISTER_TYPE_TO_HEXSTR(sha256_double); diff --git a/tests/benchmark.py b/tests/benchmark.py index 18c756794054..5767dceca419 100644 --- a/tests/benchmark.py +++ b/tests/benchmark.py @@ -23,7 +23,7 @@ def executor(): @pytest.fixture(scope="module") def bitcoind(): - bitcoind = utils.BitcoinD(rpcport=28332) + bitcoind = utils.BitcoinD(rpcport=21441) bitcoind.start() info = bitcoind.rpc.getblockchaininfo() # Make sure we have segwit and some funds