Skip to content

Commit 612d713

Browse files
committed
Move bitcoin stuff into bitcoin subdir.
It's not very interesting if you're looking for LN code. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 28ea518 commit 612d713

37 files changed

+114
-107
lines changed

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ PROTOCC:=protoc-c
55

66
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
77

8-
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
8+
BITCOIN_OBJS := bitcoin/address.o bitcoin/base58.o bitcoin/pubkey.o bitcoin/script.o bitcoin/shadouble.o bitcoin/signature.o bitcoin/tx.o
9+
10+
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
911

1012
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
1113

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

27-
$(PROGRAMS): % : %.o $(HELPER_OBJS) $(CCAN_OBJS)
29+
$(PROGRAMS): % : %.o $(HELPER_OBJS) $(BITCOIN_OBJS) $(CCAN_OBJS)
2830
$(PROGRAMS:=.o) $(HELPER_OBJS): $(HEADERS)
2931

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

3335
clean:
3436
$(RM) $(PROGRAMS)
35-
$(RM) *.o $(CCAN_OBJS)
37+
$(RM) bitcoin/*.o *.o $(CCAN_OBJS)
3638

3739
ccan-tal.o: $(CCANDIR)/ccan/tal/tal.c
3840
$(CC) $(CFLAGS) -c -o $@ $<

anchor.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include "anchor.h"
2-
#include "bitcoin_tx.h"
2+
#include "bitcoin/tx.h"
33
#include "overflows.h"
44
#include "pkt.h"
55
#include "permute_tx.h"
6-
#include "bitcoin_script.h"
7-
#include "pubkey.h"
6+
#include "bitcoin/script.h"
7+
#include "bitcoin/pubkey.h"
88
#include <ccan/err/err.h>
99

1010
struct bitcoin_tx *anchor_tx_create(const tal_t *ctx,

bitcoin/README

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
These are standard bitcoin manipulation routines which should be
2+
provided by any normal bitcoin library in whatever language you choose.
3+
4+
The ones here are standalone ones taken from bitcoin core and soe I
5+
wrote, many taken from bitcoin-iterate and pasted in here.
6+

bitcoin_address.c renamed to bitcoin/address.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "bitcoin_address.h"
1+
#include "address.h"
22
#include "pubkey.h"
33
#include <ccan/crypto/sha256/sha256.h>
44

File renamed without changes.

base58.c renamed to bitcoin/base58.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
66
#include "base58.h"
77
#include "shadouble.h"
8-
#include "bitcoin_address.h"
8+
#include "address.h"
99
#include "pubkey.h"
1010
#include <assert.h>
1111
#include <ccan/build_assert/build_assert.h>

base58.h renamed to bitcoin/base58.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef LIGHTNING_BASE58_H
2-
#define LIGHTNING_BASE58_H
1+
#ifndef LIGHTNING_BITCOIN_BASE58_H
2+
#define LIGHTNING_BITCOIN_BASE58_H
33
/* FIXME: Use libsecpk1 */
44
#include <ccan/tal/tal.h>
55
#include <ccan/short_types/short_types.h>
@@ -44,4 +44,4 @@ bool raw_decode_base_n(BIGNUM *bn, const char *src, size_t len, int base);
4444
bool raw_decode_base58(BIGNUM *bn, const char *src, size_t len);
4545
void base58_get_checksum(u8 csum[4], const u8 buf[], size_t buflen);
4646

47-
#endif /* PETTYCOIN_BASE58_H */
47+
#endif /* PETTYCOIN_BITCOIN_BASE58_H */
File renamed without changes.

pubkey.h renamed to bitcoin/pubkey.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#ifndef LIGHTNING_PUBKEY_H
2-
#define LIGHTNING_PUBKEY_H
1+
#ifndef LIGHTNING_BITCOIN_PUBKEY_H
2+
#define LIGHTNING_BITCOIN_PUBKEY_H
33
#include <ccan/short_types/short_types.h>
44
#include <ccan/tal/tal.h>
5-
#include "lightning.pb-c.h"
5+
#include "../lightning.pb-c.h"
66

77
struct pubkey {
88
u8 key[65];

bitcoin_script.c renamed to bitcoin/script.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#include "bitcoin_script.h"
2-
#include "bitcoin_address.h"
3-
#include "pkt.h"
1+
#include "script.h"
2+
#include "address.h"
43
#include "signature.h"
54
#include "pubkey.h"
65
#include <openssl/ripemd.h>
File renamed without changes.
File renamed without changes.

shadouble.h renamed to bitcoin/shadouble.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef LIGHTNING_SHADOUBLE_H
2-
#define LIGHTNING_SHADOUBLE_H
1+
#ifndef LIGHTNING_BITCOIN_SHADOUBLE_H
2+
#define LIGHTNING_BITCOIN_SHADOUBLE_H
33
#include "config.h"
44
#include <ccan/crypto/sha256/sha256.h>
55

@@ -11,4 +11,4 @@ struct sha256_double {
1111
void sha256_double(struct sha256_double *shadouble, const void *p, size_t len);
1212

1313
void sha256_double_done(struct sha256_ctx *sha256, struct sha256_double *res);
14-
#endif /* PETTYCOIN_SHADOUBLE_H */
14+
#endif /* LIGHTNING_BITCOIN_SHADOUBLE_H */

signature.c renamed to bitcoin/signature.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include "signature.h"
22
#include "shadouble.h"
3-
#include "bitcoin_tx.h"
3+
#include "tx.h"
44
#include "pubkey.h"
5-
#include "bitcoin_script.h"
5+
#include "script.h"
66
#include <openssl/bn.h>
77
#include <openssl/obj_mac.h>
88
#include <assert.h>

signature.h renamed to bitcoin/signature.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#ifndef LIGHTNING_SIGNATURE_H
2-
#define LIGHTNING_SIGNATURE_H
1+
#ifndef LIGHTNING_BITCOIN_SIGNATURE_H
2+
#define LIGHTNING_BITCOIN_SIGNATURE_H
33
#include <ccan/short_types/short_types.h>
44
#include <openssl/ecdsa.h>
55
#include <ccan/tal/tal.h>
6-
#include "lightning.pb-c.h"
6+
#include "../lightning.pb-c.h"
77

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

54-
#endif /* LIGHTNING_SIGNATURE_H */
54+
#endif /* LIGHTNING_BITCOIN_SIGNATURE_H */

bitcoin_tx.c renamed to bitcoin/tx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "bitcoin_tx.h"
1+
#include "tx.h"
22
#include <ccan/crypto/sha256/sha256.h>
33
#include <ccan/err/err.h>
44
#include <ccan/tal/grab_file/grab_file.h>
File renamed without changes.

check-anchor-scriptsigs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
#include <ccan/structeq/structeq.h>
1313
#include "lightning.pb-c.h"
1414
#include "anchor.h"
15-
#include "base58.h"
15+
#include "bitcoin/base58.h"
1616
#include "pkt.h"
17-
#include "bitcoin_script.h"
17+
#include "bitcoin/script.h"
1818
#include "permute_tx.h"
19-
#include "signature.h"
19+
#include "bitcoin/signature.h"
2020
#include "commit_tx.h"
21-
#include "pubkey.h"
21+
#include "bitcoin/pubkey.h"
2222
#include <openssl/ec.h>
2323
#include <unistd.h>
2424

check-commit-sig.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
#include <ccan/read_write_all/read_write_all.h>
1212
#include "lightning.pb-c.h"
1313
#include "anchor.h"
14-
#include "base58.h"
14+
#include "bitcoin/base58.h"
1515
#include "pkt.h"
16-
#include "bitcoin_script.h"
16+
#include "bitcoin/script.h"
1717
#include "permute_tx.h"
18-
#include "signature.h"
18+
#include "bitcoin/signature.h"
1919
#include "commit_tx.h"
20-
#include "pubkey.h"
20+
#include "bitcoin/pubkey.h"
2121
#include <openssl/ec.h>
2222
#include <unistd.h>
2323

close-channel.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
#include <ccan/read_write_all/read_write_all.h>
1212
#include "lightning.pb-c.h"
1313
#include "anchor.h"
14-
#include "base58.h"
14+
#include "bitcoin/base58.h"
1515
#include "pkt.h"
16-
#include "bitcoin_script.h"
16+
#include "bitcoin/script.h"
1717
#include "permute_tx.h"
18-
#include "signature.h"
19-
#include "pubkey.h"
18+
#include "bitcoin/signature.h"
19+
#include "bitcoin/pubkey.h"
2020
#include "close_tx.h"
2121
#include "find_p2sh_out.h"
2222
#include <openssl/ec.h>

close_tx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include "close_tx.h"
2-
#include "shadouble.h"
3-
#include "bitcoin_tx.h"
4-
#include "bitcoin_script.h"
2+
#include "bitcoin/shadouble.h"
3+
#include "bitcoin/tx.h"
4+
#include "bitcoin/script.h"
55
#include "permute_tx.h"
6-
#include "pubkey.h"
6+
#include "bitcoin/pubkey.h"
77
#include "pkt.h"
88

99
struct bitcoin_tx *create_close_tx(const tal_t *ctx,

commit_tx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include "commit_tx.h"
2-
#include "shadouble.h"
3-
#include "bitcoin_tx.h"
4-
#include "bitcoin_script.h"
2+
#include "bitcoin/shadouble.h"
3+
#include "bitcoin/tx.h"
4+
#include "bitcoin/script.h"
55
#include "permute_tx.h"
6-
#include "pubkey.h"
6+
#include "bitcoin/pubkey.h"
77
#include "pkt.h"
88

99
struct bitcoin_tx *create_commit_tx(const tal_t *ctx,

create-close-tx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
#include <ccan/read_write_all/read_write_all.h>
1111
#include "lightning.pb-c.h"
1212
#include "anchor.h"
13-
#include "base58.h"
13+
#include "bitcoin/base58.h"
1414
#include "pkt.h"
15-
#include "bitcoin_script.h"
15+
#include "bitcoin/script.h"
1616
#include "permute_tx.h"
17-
#include "signature.h"
18-
#include "pubkey.h"
17+
#include "bitcoin/signature.h"
18+
#include "bitcoin/pubkey.h"
1919
#include "close_tx.h"
2020
#include "find_p2sh_out.h"
2121
#include <openssl/ec.h>

create-commit-spend-tx.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
#include <ccan/structeq/structeq.h>
1212
#include "lightning.pb-c.h"
1313
#include "anchor.h"
14-
#include "base58.h"
14+
#include "bitcoin/base58.h"
1515
#include "pkt.h"
16-
#include "bitcoin_script.h"
16+
#include "bitcoin/script.h"
1717
#include "permute_tx.h"
18-
#include "signature.h"
18+
#include "bitcoin/signature.h"
1919
#include "commit_tx.h"
20-
#include "pubkey.h"
21-
#include "bitcoin_address.h"
20+
#include "bitcoin/pubkey.h"
21+
#include "bitcoin/address.h"
2222
#include "opt_bits.h"
2323
#include "find_p2sh_out.h"
2424
#include <openssl/ec.h>

create-commit-tx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
#include <ccan/read_write_all/read_write_all.h>
1212
#include "lightning.pb-c.h"
1313
#include "anchor.h"
14-
#include "base58.h"
14+
#include "bitcoin/base58.h"
1515
#include "pkt.h"
16-
#include "bitcoin_script.h"
16+
#include "bitcoin/script.h"
1717
#include "permute_tx.h"
18-
#include "signature.h"
18+
#include "bitcoin/signature.h"
1919
#include "commit_tx.h"
20-
#include "pubkey.h"
20+
#include "bitcoin/pubkey.h"
2121
#include "find_p2sh_out.h"
2222
#include <openssl/ec.h>
2323
#include <unistd.h>

create-steal-tx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
#include <ccan/read_write_all/read_write_all.h>
1212
#include "lightning.pb-c.h"
1313
#include "anchor.h"
14-
#include "base58.h"
14+
#include "bitcoin/base58.h"
1515
#include "pkt.h"
16-
#include "bitcoin_script.h"
16+
#include "bitcoin/script.h"
1717
#include "permute_tx.h"
18-
#include "signature.h"
18+
#include "bitcoin/signature.h"
1919
#include "commit_tx.h"
20-
#include "pubkey.h"
20+
#include "bitcoin/pubkey.h"
2121
#include <openssl/ec.h>
2222
#include <unistd.h>
2323

find_p2sh_out.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "find_p2sh_out.h"
2-
#include "bitcoin_tx.h"
3-
#include "bitcoin_script.h"
2+
#include "bitcoin/tx.h"
3+
#include "bitcoin/script.h"
44
#include <string.h>
55
#include <ccan/err/err.h>
66
#include <ccan/tal/tal.h>

get-anchor-depth.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
#include <ccan/read_write_all/read_write_all.h>
1212
#include "lightning.pb-c.h"
1313
#include "anchor.h"
14-
#include "base58.h"
14+
#include "bitcoin/base58.h"
1515
#include "pkt.h"
16-
#include "bitcoin_script.h"
16+
#include "bitcoin/script.h"
1717
#include "permute_tx.h"
18-
#include "signature.h"
18+
#include "bitcoin/signature.h"
1919
#include "commit_tx.h"
20-
#include "pubkey.h"
20+
#include "bitcoin/pubkey.h"
2121
#include <openssl/ec.h>
2222
#include <unistd.h>
2323

open-anchor-scriptsigs.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
#include <ccan/err/err.h>
66
#include <ccan/opt/opt.h>
77
#include <ccan/read_write_all/read_write_all.h>
8-
#include "bitcoin_tx.h"
9-
#include "signature.h"
8+
#include "bitcoin/tx.h"
9+
#include "bitcoin/signature.h"
1010
#include "lightning.pb-c.h"
1111
#include "pkt.h"
12-
#include "bitcoin_script.h"
13-
#include "bitcoin_address.h"
14-
#include "base58.h"
12+
#include "bitcoin/script.h"
13+
#include "bitcoin/address.h"
14+
#include "bitcoin/base58.h"
1515
#include "anchor.h"
16-
#include "pubkey.h"
16+
#include "bitcoin/pubkey.h"
1717

1818
#include <openssl/ec.h>
1919
#include <unistd.h>

open-channel.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
#include <ccan/err/err.h>
1111
#include <ccan/read_write_all/read_write_all.h>
1212
#include "lightning.pb-c.h"
13-
#include "base58.h"
13+
#include "bitcoin/base58.h"
1414
#include "pkt.h"
15-
#include "bitcoin_script.h"
16-
#include "bitcoin_address.h"
17-
#include "bitcoin_tx.h"
18-
#include "pubkey.h"
19-
#include "shadouble.h"
15+
#include "bitcoin/script.h"
16+
#include "bitcoin/address.h"
17+
#include "bitcoin/tx.h"
18+
#include "bitcoin/pubkey.h"
19+
#include "bitcoin/shadouble.h"
2020
#include <openssl/ec.h>
2121
#include <unistd.h>
2222
#include "opt_bits.h"

open-commit-sig.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
#include <ccan/read_write_all/read_write_all.h>
1212
#include "lightning.pb-c.h"
1313
#include "anchor.h"
14-
#include "base58.h"
14+
#include "bitcoin/base58.h"
1515
#include "pkt.h"
16-
#include "bitcoin_script.h"
16+
#include "bitcoin/script.h"
1717
#include "permute_tx.h"
18-
#include "signature.h"
18+
#include "bitcoin/signature.h"
1919
#include "commit_tx.h"
20-
#include "pubkey.h"
20+
#include "bitcoin/pubkey.h"
2121
#include <openssl/ec.h>
2222
#include <unistd.h>
2323

permute_tx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#ifndef LIGHTNING_PERMUTE_TX_H
22
#define LIGHTNING_PERMUTE_TX_H
3-
#include "bitcoin_tx.h"
3+
#include "bitcoin/tx.h"
44

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

0 commit comments

Comments
 (0)