Skip to content

Commit

Permalink
Move bitcoin stuff into bitcoin subdir.
Browse files Browse the repository at this point in the history
It's not very interesting if you're looking for LN code.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Jun 12, 2015
1 parent 28ea518 commit 612d713
Show file tree
Hide file tree
Showing 37 changed files with 114 additions and 107 deletions.
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ PROTOCC:=protoc-c

PROGRAMS := open-channel open-anchor-scriptsigs leak-anchor-sigs open-commit-sig check-commit-sig check-anchor-scriptsigs get-anchor-depth create-steal-tx create-commit-spend-tx close-channel create-close-tx update-channel update-channel-accept update-channel-signature update-channel-complete create-commit-tx

HELPER_OBJS := base58.o lightning.pb-c.o shadouble.o pkt.o bitcoin_script.o permute_tx.o signature.o bitcoin_tx.o bitcoin_address.o anchor.o commit_tx.o pubkey.o opt_bits.o close_tx.o find_p2sh_out.o
BITCOIN_OBJS := bitcoin/address.o bitcoin/base58.o bitcoin/pubkey.o bitcoin/script.o bitcoin/shadouble.o bitcoin/signature.o bitcoin/tx.o

HELPER_OBJS := lightning.pb-c.o pkt.o permute_tx.o anchor.o commit_tx.o opt_bits.o close_tx.o find_p2sh_out.o

CCAN_OBJS := ccan-crypto-sha256.o ccan-crypto-shachain.o ccan-err.o ccan-tal.o ccan-tal-str.o ccan-take.o ccan-list.o ccan-str.o ccan-opt-helpers.o ccan-opt.o ccan-opt-parse.o ccan-opt-usage.o ccan-read_write_all.o ccan-str-hex.o ccan-tal-grab_file.o ccan-noerr.o

Expand All @@ -24,15 +26,15 @@ FORCE::
lightning.pb-c.c lightning.pb-c.h: lightning.proto
$(PROTOCC) lightning.proto --c_out=.

$(PROGRAMS): % : %.o $(HELPER_OBJS) $(CCAN_OBJS)
$(PROGRAMS): % : %.o $(HELPER_OBJS) $(BITCOIN_OBJS) $(CCAN_OBJS)
$(PROGRAMS:=.o) $(HELPER_OBJS): $(HEADERS)

distclean: clean
$(RM) lightning.pb-c.c lightning.pb-c.h

clean:
$(RM) $(PROGRAMS)
$(RM) *.o $(CCAN_OBJS)
$(RM) bitcoin/*.o *.o $(CCAN_OBJS)

ccan-tal.o: $(CCANDIR)/ccan/tal/tal.c
$(CC) $(CFLAGS) -c -o $@ $<
Expand Down
6 changes: 3 additions & 3 deletions anchor.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "anchor.h"
#include "bitcoin_tx.h"
#include "bitcoin/tx.h"
#include "overflows.h"
#include "pkt.h"
#include "permute_tx.h"
#include "bitcoin_script.h"
#include "pubkey.h"
#include "bitcoin/script.h"
#include "bitcoin/pubkey.h"
#include <ccan/err/err.h>

struct bitcoin_tx *anchor_tx_create(const tal_t *ctx,
Expand Down
6 changes: 6 additions & 0 deletions bitcoin/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
These are standard bitcoin manipulation routines which should be
provided by any normal bitcoin library in whatever language you choose.

The ones here are standalone ones taken from bitcoin core and soe I
wrote, many taken from bitcoin-iterate and pasted in here.

2 changes: 1 addition & 1 deletion bitcoin_address.c → bitcoin/address.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "bitcoin_address.h"
#include "address.h"
#include "pubkey.h"
#include <ccan/crypto/sha256/sha256.h>

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion base58.c → bitcoin/base58.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "base58.h"
#include "shadouble.h"
#include "bitcoin_address.h"
#include "address.h"
#include "pubkey.h"
#include <assert.h>
#include <ccan/build_assert/build_assert.h>
Expand Down
6 changes: 3 additions & 3 deletions base58.h → bitcoin/base58.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef LIGHTNING_BASE58_H
#define LIGHTNING_BASE58_H
#ifndef LIGHTNING_BITCOIN_BASE58_H
#define LIGHTNING_BITCOIN_BASE58_H
/* FIXME: Use libsecpk1 */
#include <ccan/tal/tal.h>
#include <ccan/short_types/short_types.h>
Expand Down Expand Up @@ -44,4 +44,4 @@ bool raw_decode_base_n(BIGNUM *bn, const char *src, size_t len, int base);
bool raw_decode_base58(BIGNUM *bn, const char *src, size_t len);
void base58_get_checksum(u8 csum[4], const u8 buf[], size_t buflen);

#endif /* PETTYCOIN_BASE58_H */
#endif /* PETTYCOIN_BITCOIN_BASE58_H */
File renamed without changes.
6 changes: 3 additions & 3 deletions pubkey.h → bitcoin/pubkey.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef LIGHTNING_PUBKEY_H
#define LIGHTNING_PUBKEY_H
#ifndef LIGHTNING_BITCOIN_PUBKEY_H
#define LIGHTNING_BITCOIN_PUBKEY_H
#include <ccan/short_types/short_types.h>
#include <ccan/tal/tal.h>
#include "lightning.pb-c.h"
#include "../lightning.pb-c.h"

struct pubkey {
u8 key[65];
Expand Down
5 changes: 2 additions & 3 deletions bitcoin_script.c → bitcoin/script.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "bitcoin_script.h"
#include "bitcoin_address.h"
#include "pkt.h"
#include "script.h"
#include "address.h"
#include "signature.h"
#include "pubkey.h"
#include <openssl/ripemd.h>
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions shadouble.h → bitcoin/shadouble.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef LIGHTNING_SHADOUBLE_H
#define LIGHTNING_SHADOUBLE_H
#ifndef LIGHTNING_BITCOIN_SHADOUBLE_H
#define LIGHTNING_BITCOIN_SHADOUBLE_H
#include "config.h"
#include <ccan/crypto/sha256/sha256.h>

Expand All @@ -11,4 +11,4 @@ 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);
#endif /* PETTYCOIN_SHADOUBLE_H */
#endif /* LIGHTNING_BITCOIN_SHADOUBLE_H */
4 changes: 2 additions & 2 deletions signature.c → bitcoin/signature.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "signature.h"
#include "shadouble.h"
#include "bitcoin_tx.h"
#include "tx.h"
#include "pubkey.h"
#include "bitcoin_script.h"
#include "script.h"
#include <openssl/bn.h>
#include <openssl/obj_mac.h>
#include <assert.h>
Expand Down
8 changes: 4 additions & 4 deletions signature.h → bitcoin/signature.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef LIGHTNING_SIGNATURE_H
#define LIGHTNING_SIGNATURE_H
#ifndef LIGHTNING_BITCOIN_SIGNATURE_H
#define LIGHTNING_BITCOIN_SIGNATURE_H
#include <ccan/short_types/short_types.h>
#include <openssl/ecdsa.h>
#include <ccan/tal/tal.h>
#include "lightning.pb-c.h"
#include "../lightning.pb-c.h"

enum sighash_type {
SIGHASH_ALL = 1,
Expand Down Expand Up @@ -51,4 +51,4 @@ bool check_2of2_sig(struct bitcoin_tx *tx, size_t input_num,
Signature *signature_to_proto(const tal_t *ctx, const struct signature *sig);
bool proto_to_signature(const Signature *pb, struct signature *sig);

#endif /* LIGHTNING_SIGNATURE_H */
#endif /* LIGHTNING_BITCOIN_SIGNATURE_H */
2 changes: 1 addition & 1 deletion bitcoin_tx.c → bitcoin/tx.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "bitcoin_tx.h"
#include "tx.h"
#include <ccan/crypto/sha256/sha256.h>
#include <ccan/err/err.h>
#include <ccan/tal/grab_file/grab_file.h>
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions check-anchor-scriptsigs.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
#include <ccan/structeq/structeq.h>
#include "lightning.pb-c.h"
#include "anchor.h"
#include "base58.h"
#include "bitcoin/base58.h"
#include "pkt.h"
#include "bitcoin_script.h"
#include "bitcoin/script.h"
#include "permute_tx.h"
#include "signature.h"
#include "bitcoin/signature.h"
#include "commit_tx.h"
#include "pubkey.h"
#include "bitcoin/pubkey.h"
#include <openssl/ec.h>
#include <unistd.h>

Expand Down
8 changes: 4 additions & 4 deletions check-commit-sig.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
#include <ccan/read_write_all/read_write_all.h>
#include "lightning.pb-c.h"
#include "anchor.h"
#include "base58.h"
#include "bitcoin/base58.h"
#include "pkt.h"
#include "bitcoin_script.h"
#include "bitcoin/script.h"
#include "permute_tx.h"
#include "signature.h"
#include "bitcoin/signature.h"
#include "commit_tx.h"
#include "pubkey.h"
#include "bitcoin/pubkey.h"
#include <openssl/ec.h>
#include <unistd.h>

Expand Down
8 changes: 4 additions & 4 deletions close-channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
#include <ccan/read_write_all/read_write_all.h>
#include "lightning.pb-c.h"
#include "anchor.h"
#include "base58.h"
#include "bitcoin/base58.h"
#include "pkt.h"
#include "bitcoin_script.h"
#include "bitcoin/script.h"
#include "permute_tx.h"
#include "signature.h"
#include "pubkey.h"
#include "bitcoin/signature.h"
#include "bitcoin/pubkey.h"
#include "close_tx.h"
#include "find_p2sh_out.h"
#include <openssl/ec.h>
Expand Down
8 changes: 4 additions & 4 deletions close_tx.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "close_tx.h"
#include "shadouble.h"
#include "bitcoin_tx.h"
#include "bitcoin_script.h"
#include "bitcoin/shadouble.h"
#include "bitcoin/tx.h"
#include "bitcoin/script.h"
#include "permute_tx.h"
#include "pubkey.h"
#include "bitcoin/pubkey.h"
#include "pkt.h"

struct bitcoin_tx *create_close_tx(const tal_t *ctx,
Expand Down
8 changes: 4 additions & 4 deletions commit_tx.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "commit_tx.h"
#include "shadouble.h"
#include "bitcoin_tx.h"
#include "bitcoin_script.h"
#include "bitcoin/shadouble.h"
#include "bitcoin/tx.h"
#include "bitcoin/script.h"
#include "permute_tx.h"
#include "pubkey.h"
#include "bitcoin/pubkey.h"
#include "pkt.h"

struct bitcoin_tx *create_commit_tx(const tal_t *ctx,
Expand Down
8 changes: 4 additions & 4 deletions create-close-tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
#include <ccan/read_write_all/read_write_all.h>
#include "lightning.pb-c.h"
#include "anchor.h"
#include "base58.h"
#include "bitcoin/base58.h"
#include "pkt.h"
#include "bitcoin_script.h"
#include "bitcoin/script.h"
#include "permute_tx.h"
#include "signature.h"
#include "pubkey.h"
#include "bitcoin/signature.h"
#include "bitcoin/pubkey.h"
#include "close_tx.h"
#include "find_p2sh_out.h"
#include <openssl/ec.h>
Expand Down
10 changes: 5 additions & 5 deletions create-commit-spend-tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
#include <ccan/structeq/structeq.h>
#include "lightning.pb-c.h"
#include "anchor.h"
#include "base58.h"
#include "bitcoin/base58.h"
#include "pkt.h"
#include "bitcoin_script.h"
#include "bitcoin/script.h"
#include "permute_tx.h"
#include "signature.h"
#include "bitcoin/signature.h"
#include "commit_tx.h"
#include "pubkey.h"
#include "bitcoin_address.h"
#include "bitcoin/pubkey.h"
#include "bitcoin/address.h"
#include "opt_bits.h"
#include "find_p2sh_out.h"
#include <openssl/ec.h>
Expand Down
8 changes: 4 additions & 4 deletions create-commit-tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
#include <ccan/read_write_all/read_write_all.h>
#include "lightning.pb-c.h"
#include "anchor.h"
#include "base58.h"
#include "bitcoin/base58.h"
#include "pkt.h"
#include "bitcoin_script.h"
#include "bitcoin/script.h"
#include "permute_tx.h"
#include "signature.h"
#include "bitcoin/signature.h"
#include "commit_tx.h"
#include "pubkey.h"
#include "bitcoin/pubkey.h"
#include "find_p2sh_out.h"
#include <openssl/ec.h>
#include <unistd.h>
Expand Down
8 changes: 4 additions & 4 deletions create-steal-tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
#include <ccan/read_write_all/read_write_all.h>
#include "lightning.pb-c.h"
#include "anchor.h"
#include "base58.h"
#include "bitcoin/base58.h"
#include "pkt.h"
#include "bitcoin_script.h"
#include "bitcoin/script.h"
#include "permute_tx.h"
#include "signature.h"
#include "bitcoin/signature.h"
#include "commit_tx.h"
#include "pubkey.h"
#include "bitcoin/pubkey.h"
#include <openssl/ec.h>
#include <unistd.h>

Expand Down
4 changes: 2 additions & 2 deletions find_p2sh_out.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "find_p2sh_out.h"
#include "bitcoin_tx.h"
#include "bitcoin_script.h"
#include "bitcoin/tx.h"
#include "bitcoin/script.h"
#include <string.h>
#include <ccan/err/err.h>
#include <ccan/tal/tal.h>
Expand Down
8 changes: 4 additions & 4 deletions get-anchor-depth.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
#include <ccan/read_write_all/read_write_all.h>
#include "lightning.pb-c.h"
#include "anchor.h"
#include "base58.h"
#include "bitcoin/base58.h"
#include "pkt.h"
#include "bitcoin_script.h"
#include "bitcoin/script.h"
#include "permute_tx.h"
#include "signature.h"
#include "bitcoin/signature.h"
#include "commit_tx.h"
#include "pubkey.h"
#include "bitcoin/pubkey.h"
#include <openssl/ec.h>
#include <unistd.h>

Expand Down
12 changes: 6 additions & 6 deletions open-anchor-scriptsigs.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
#include <ccan/err/err.h>
#include <ccan/opt/opt.h>
#include <ccan/read_write_all/read_write_all.h>
#include "bitcoin_tx.h"
#include "signature.h"
#include "bitcoin/tx.h"
#include "bitcoin/signature.h"
#include "lightning.pb-c.h"
#include "pkt.h"
#include "bitcoin_script.h"
#include "bitcoin_address.h"
#include "base58.h"
#include "bitcoin/script.h"
#include "bitcoin/address.h"
#include "bitcoin/base58.h"
#include "anchor.h"
#include "pubkey.h"
#include "bitcoin/pubkey.h"

#include <openssl/ec.h>
#include <unistd.h>
Expand Down
12 changes: 6 additions & 6 deletions open-channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
#include <ccan/err/err.h>
#include <ccan/read_write_all/read_write_all.h>
#include "lightning.pb-c.h"
#include "base58.h"
#include "bitcoin/base58.h"
#include "pkt.h"
#include "bitcoin_script.h"
#include "bitcoin_address.h"
#include "bitcoin_tx.h"
#include "pubkey.h"
#include "shadouble.h"
#include "bitcoin/script.h"
#include "bitcoin/address.h"
#include "bitcoin/tx.h"
#include "bitcoin/pubkey.h"
#include "bitcoin/shadouble.h"
#include <openssl/ec.h>
#include <unistd.h>
#include "opt_bits.h"
Expand Down
8 changes: 4 additions & 4 deletions open-commit-sig.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
#include <ccan/read_write_all/read_write_all.h>
#include "lightning.pb-c.h"
#include "anchor.h"
#include "base58.h"
#include "bitcoin/base58.h"
#include "pkt.h"
#include "bitcoin_script.h"
#include "bitcoin/script.h"
#include "permute_tx.h"
#include "signature.h"
#include "bitcoin/signature.h"
#include "commit_tx.h"
#include "pubkey.h"
#include "bitcoin/pubkey.h"
#include <openssl/ec.h>
#include <unistd.h>

Expand Down
2 changes: 1 addition & 1 deletion permute_tx.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef LIGHTNING_PERMUTE_TX_H
#define LIGHTNING_PERMUTE_TX_H
#include "bitcoin_tx.h"
#include "bitcoin/tx.h"

/* Given the two seeds, permute the transaction inputs.
* map[0] is set to the new index of input 0, etc.
Expand Down
Loading

0 comments on commit 612d713

Please sign in to comment.