Browse Source

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>
ppa-0.6.1
Rusty Russell 10 years ago
parent
commit
612d713470
  1. 8
      Makefile
  2. 6
      anchor.c
  3. 6
      bitcoin/README
  4. 2
      bitcoin/address.c
  5. 0
      bitcoin/address.h
  6. 2
      bitcoin/base58.c
  7. 6
      bitcoin/base58.h
  8. 0
      bitcoin/pubkey.c
  9. 6
      bitcoin/pubkey.h
  10. 5
      bitcoin/script.c
  11. 0
      bitcoin/script.h
  12. 0
      bitcoin/shadouble.c
  13. 6
      bitcoin/shadouble.h
  14. 4
      bitcoin/signature.c
  15. 8
      bitcoin/signature.h
  16. 2
      bitcoin/tx.c
  17. 0
      bitcoin/tx.h
  18. 8
      check-anchor-scriptsigs.c
  19. 8
      check-commit-sig.c
  20. 8
      close-channel.c
  21. 8
      close_tx.c
  22. 8
      commit_tx.c
  23. 8
      create-close-tx.c
  24. 10
      create-commit-spend-tx.c
  25. 8
      create-commit-tx.c
  26. 8
      create-steal-tx.c
  27. 4
      find_p2sh_out.c
  28. 8
      get-anchor-depth.c
  29. 12
      open-anchor-scriptsigs.c
  30. 12
      open-channel.c
  31. 8
      open-commit-sig.c
  32. 2
      permute_tx.h
  33. 8
      pkt.c
  34. 8
      update-channel-accept.c
  35. 8
      update-channel-complete.c
  36. 8
      update-channel-signature.c
  37. 8
      update-channel.c

8
Makefile

@ -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
@ -24,7 +26,7 @@ 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
@ -32,7 +34,7 @@ distclean: clean
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 $@ $<

6
anchor.c

@ -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,

6
bitcoin/README

@ -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
bitcoin_address.c → bitcoin/address.c

@ -1,4 +1,4 @@
#include "bitcoin_address.h"
#include "address.h"
#include "pubkey.h"
#include <ccan/crypto/sha256/sha256.h>

0
bitcoin_address.h → bitcoin/address.h

2
base58.c → bitcoin/base58.c

@ -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>

6
base58.h → bitcoin/base58.h

@ -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>
@ -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 */

0
pubkey.c → bitcoin/pubkey.c

6
pubkey.h → bitcoin/pubkey.h

@ -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];

5
bitcoin_script.c → bitcoin/script.c

@ -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>

0
bitcoin_script.h → bitcoin/script.h

0
shadouble.c → bitcoin/shadouble.c

6
shadouble.h → bitcoin/shadouble.h

@ -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>
@ -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
signature.c → bitcoin/signature.c

@ -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>

8
signature.h → bitcoin/signature.h

@ -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,
@ -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
bitcoin_tx.c → bitcoin/tx.c

@ -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>

0
bitcoin_tx.h → bitcoin/tx.h

8
check-anchor-scriptsigs.c

@ -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>

8
check-commit-sig.c

@ -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>

8
close-channel.c

@ -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>

8
close_tx.c

@ -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,

8
commit_tx.c

@ -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,

8
create-close-tx.c

@ -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>

10
create-commit-spend-tx.c

@ -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>

8
create-commit-tx.c

@ -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>

8
create-steal-tx.c

@ -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>

4
find_p2sh_out.c

@ -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>

8
get-anchor-depth.c

@ -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>

12
open-anchor-scriptsigs.c

@ -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>

12
open-channel.c

@ -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"

8
open-commit-sig.c

@ -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>

2
permute_tx.h

@ -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.

8
pkt.c

@ -2,10 +2,10 @@
#include <ccan/tal/grab_file/grab_file.h>
#include <ccan/err/err.h>
#include "pkt.h"
#include "bitcoin_tx.h"
#include "bitcoin_address.h"
#include "pubkey.h"
#include "signature.h"
#include "bitcoin/tx.h"
#include "bitcoin/address.h"
#include "bitcoin/pubkey.h"
#include "bitcoin/signature.h"
#include <stdio.h>
static struct pkt *to_pkt(const tal_t *ctx, Pkt__PktCase type, void *msg)

8
update-channel-accept.c

@ -10,13 +10,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>

8
update-channel-complete.c

@ -11,13 +11,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 "find_p2sh_out.h"
#include <openssl/ec.h>
#include <unistd.h>

8
update-channel-signature.c

@ -7,13 +7,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>

8
update-channel.c

@ -10,13 +10,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>

Loading…
Cancel
Save