Skip to content

Commit

Permalink
allow BTC/LTC compile by compilerflag
Browse files Browse the repository at this point in the history
new groestl.h

Signed-off-by: dflate <[email protected]>
  • Loading branch information
dflate committed Sep 13, 2018
1 parent 2fdd549 commit 9494d51
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 28 deletions.
1 change: 1 addition & 0 deletions bitcoin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
7 changes: 6 additions & 1 deletion bitcoin/base58.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "pubkey.h"
#include "shadouble.h"
#include <assert.h>
#include <bitcoin/chainparams.h>
#include <ccan/build_assert/build_assert.h>
#include <ccan/tal/str/str.h>
#include <common/utils.h>
Expand All @@ -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];
Expand All @@ -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;
}

Expand Down
24 changes: 1 addition & 23 deletions bitcoin/groestl.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#include <bitcoin/groestl.h>
#include <bitcoin/sph_groestl.h>
#include <bitcoin/sph_types.h>
#include <ccan/build_assert/build_assert.h>
#include <ccan/tal/str/str.h>
#include <common/utils.h>
#include <stdio.h>


void groestlhash(void *, const void *, size_t len);

void groestlhash(void *output, const void *input , size_t len)
{
uint32_t hash[16];
Expand Down Expand Up @@ -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);

}


7 changes: 7 additions & 0 deletions bitcoin/groestl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef LIGHTNING_BITCOIN_GROESTL_H
#define LIGHTNING_BITCOIN_GROESTL_H
#include "config.h"
#include <sys/types.h>

void groestlhash(void *, const void * , size_t);
#endif /* LIGHTNING_BITCOIN_GROESTL_H */
9 changes: 6 additions & 3 deletions bitcoin/shadouble.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "shadouble.h"
#include <bitcoin/groestl.h>
#include <ccan/mem/mem.h>
#include <common/type_to_string.h>

extern void groestlhash(void *, const void * , size_t len);
#include <common/utils.h>

void sha256_double(struct sha256_double *shadouble, const void *p, size_t len)
{
Expand All @@ -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);
2 changes: 1 addition & 1 deletion tests/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9494d51

Please sign in to comment.