Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
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
14 changes: 14 additions & 0 deletions 14 INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ You will need several development libraries:
To Build on Ubuntu 15.10
------------------------
Build protobuf-c dependency (>= 1.1.0):

```
sudo apt-get install libprotoc-dev
git clone https://github.com/protobuf-c/protobuf-c.git
Expand All @@ -21,7 +22,20 @@ make install
cd ../
```

Build libsodium:

```
wget https://download.libsodium.org/libsodium/releases/LATEST.tar.gz
tar zxvf LATEST.tar.gz
cd libsodium-1.0.10
./configure
make && make check
make install
cd ../
```

Clone lightning and initialize submodules:

```
git clone https://github.com/ElementsProject/lightning.git
cd lighting
Expand Down
18 changes: 18 additions & 0 deletions 18 bitcoin/shadouble.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "shadouble.h"
#include <ccan/mem/mem.h>
#include <stdio.h>

void sha256_double(struct sha256_double *shadouble, const void *p, size_t len)
{
Expand All @@ -12,3 +13,20 @@ 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));
}

char *sha256_str(const tal_t *ctx, struct sha256 *sha)
{
const size_t size = sizeof(struct sha256);
char *hex = tal_arr(ctx, char, size * 2 + 1);
size_t i = 0;
for (; i < size; i++) {
sprintf(hex + i*2, "%02x", sha->u.u8[size - i - 1]);
}
*(hex + size*2) = '\0';
return hex;
}

char *sha256_double_str(const tal_t *ctx, struct sha256_double *shadouble)
{
return sha256_str(ctx, &shadouble->sha);
}
5 changes: 5 additions & 0 deletions 5 bitcoin/shadouble.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define LIGHTNING_BITCOIN_SHADOUBLE_H
#include "config.h"
#include <ccan/crypto/sha256/sha256.h>
#include <ccan/tal/tal.h>

/* To explicitly distinguish between single sha and bitcoin's standard double */
struct sha256_double {
Expand All @@ -11,4 +12,8 @@ struct sha256_double {
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);

char *sha256_str(const tal_t *ctx, struct sha256 *sha);
char *sha256_double_str(const tal_t *ctx, struct sha256_double *shadouble);

#endif /* LIGHTNING_BITCOIN_SHADOUBLE_H */
9 changes: 4 additions & 5 deletions 9 daemon/bitcoind.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,11 @@ static void process_transactions(struct bitcoin_cli *bcli)
bcli->output + blktok->start);
}
}
/* FIXME: log txid, blkid */

log_debug(bcli->dstate->base_log,
"txid %02x%02x%02x%02x..., conf %u, coinbase %u",
txid.sha.u.u8[0], txid.sha.u.u8[1],
txid.sha.u.u8[2], txid.sha.u.u8[3],
conf, is_coinbase);
"txid %s, conf %u, coinbase %u, blkhash %s",
sha256_double_str(bcli, &txid), conf, is_coinbase,
conf ? sha256_double_str(bcli, &blkhash) : "null");

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you allocate the strings off "bcli" (which will be freed when the command is done), you don't need to free the strings! In fact, you can just do:

log_debug(bcli->dstate->base_log,
              "txid %s, conf %u, coinbase %u, blkhash %s",
              sha256_double_str(bcli, &txid),
                          conf, is_coinbase, conf ? sha256_double_str(bcli, &blkhash) : "null");

Thanks!

cb(bcli->dstate, &txid, conf, is_coinbase,
conf ? &blkhash : NULL);
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.