Browse Source

common/channel_id: move channel_id into its own file.

The definition was in wire/wire.h, and helper functions in fromwire.c!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
nifty/pset-pre
Rusty Russell 4 years ago
committed by Christian Decker
parent
commit
fda5f0b427
  1. 1
      channeld/Makefile
  2. 8
      channeld/test/run-commit_tx.c
  3. 8
      channeld/test/run-full_channel.c
  4. 8
      cli/test/run-large-input.c
  5. 8
      cli/test/run-remove-hint.c
  6. 1
      closingd/Makefile
  7. 1
      common/Makefile
  8. 26
      common/channel_id.c
  9. 29
      common/channel_id.h
  10. 1
      common/coin_mvt.h
  11. 1
      common/json_helpers.c
  12. 1
      common/json_tok.c
  13. 1
      common/peer_status_wire.csv
  14. 1
      connectd/Makefile
  15. 1
      devtools/Makefile
  16. 1
      gossipd/Makefile
  17. 7
      gossipd/test/run-bench-find_route.c
  18. 7
      gossipd/test/run-crc32_of_update.c
  19. 7
      gossipd/test/run-extended-info.c
  20. 7
      gossipd/test/run-find_route-specific.c
  21. 7
      gossipd/test/run-find_route.c
  22. 7
      gossipd/test/run-next_block_range.c
  23. 7
      gossipd/test/run-overlong.c
  24. 7
      gossipd/test/run-txout_failure.c
  25. 1
      hsmd/Makefile
  26. 1
      lightningd/Makefile
  27. 1
      lightningd/json.c
  28. 1
      lightningd/options.c
  29. 7
      lightningd/test/run-find_my_abspath.c
  30. 11
      lightningd/test/run-invoice-select-inchan.c
  31. 7
      lightningd/test/run-jsonrpc.c
  32. 7
      lightningd/test/run-log-pruning.c
  33. 1
      onchaind/Makefile
  34. 1
      openingd/Makefile
  35. 1
      openingd/opening_wire.csv
  36. 4
      wallet/test/run-wallet.c
  37. 2
      wire/Makefile
  38. 24
      wire/fromwire.c
  39. 7
      wire/test/run-peer-wire.c
  40. 7
      wire/test/run-tlvstream.c
  41. 5
      wire/towire.c
  42. 11
      wire/wire.h

1
channeld/Makefile

@ -42,6 +42,7 @@ CHANNELD_COMMON_OBJS := \
common/bip32.o \
common/blinding.o \
common/channel_config.o \
common/channel_id.o \
common/crypto_state.o \
common/crypto_sync.o \
common/cryptomsg.o \

8
channeld/test/run-commit_tx.c

@ -13,6 +13,7 @@ static bool print_superverbose;
#include <ccan/err/err.h>
#include <ccan/str/hex/hex.h>
#include <common/amount.h>
#include <common/channel_id.h>
#include <common/key_derive.h>
#include <common/status.h>
@ -26,12 +27,19 @@ size_t bigsize_get(const u8 *p UNNEEDED, size_t max UNNEEDED, bigsize_t *val UNN
/* Generated stub for bigsize_put */
size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED)
{ fprintf(stderr, "bigsize_put called!\n"); abort(); }
/* Generated stub for fromwire_channel_id */
void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "fromwire_channel_id called!\n"); abort(); }
/* Generated stub for status_fmt */
void status_fmt(enum log_level level UNNEEDED,
const struct node_id *peer UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "status_fmt called!\n"); abort(); }
/* Generated stub for towire_channel_id */
void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "towire_channel_id called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
/* bitcoind loves its backwards txids! */

8
channeld/test/run-full_channel.c

@ -9,6 +9,7 @@
#include <ccan/err/err.h>
#include <ccan/str/hex/hex.h>
#include <common/amount.h>
#include <common/channel_id.h>
#include <common/sphinx.h>
#include <common/type_to_string.h>
#include <stdio.h>
@ -21,6 +22,10 @@ size_t bigsize_get(const u8 *p UNNEEDED, size_t max UNNEEDED, bigsize_t *val UNN
/* Generated stub for bigsize_put */
size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED)
{ fprintf(stderr, "bigsize_put called!\n"); abort(); }
/* Generated stub for fromwire_channel_id */
void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "fromwire_channel_id called!\n"); abort(); }
/* Generated stub for memleak_add_helper_ */
void memleak_add_helper_(const tal_t *p UNNEEDED, void (*cb)(struct htable *memtable UNNEEDED,
const tal_t *)){ }
@ -31,6 +36,9 @@ void memleak_remove_htable(struct htable *memtable UNNEEDED, const struct htable
void status_failed(enum status_failreason code UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "status_failed called!\n"); abort(); }
/* Generated stub for towire_channel_id */
void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "towire_channel_id called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
void status_fmt(enum log_level level UNUSED,

8
cli/test/run-large-input.c

@ -2,6 +2,7 @@
#include <assert.h>
#include <common/amount.h>
#include <common/bigsize.h>
#include <common/channel_id.h>
#include <common/json_stream.h>
#include <common/wireaddr.h>
#include <fcntl.h>
@ -63,6 +64,10 @@ size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED)
/* Generated stub for fmt_wireaddr_without_port */
char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr *a UNNEEDED)
{ fprintf(stderr, "fmt_wireaddr_without_port called!\n"); abort(); }
/* Generated stub for fromwire_channel_id */
void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "fromwire_channel_id called!\n"); abort(); }
/* Generated stub for json_add_member */
void json_add_member(struct json_stream *js UNNEEDED,
const char *fieldname UNNEEDED,
@ -85,6 +90,9 @@ void json_object_end(struct json_stream *js UNNEEDED)
/* Generated stub for json_object_start */
void json_object_start(struct json_stream *ks UNNEEDED, const char *fieldname UNNEEDED)
{ fprintf(stderr, "json_object_start called!\n"); abort(); }
/* Generated stub for towire_channel_id */
void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "towire_channel_id called!\n"); abort(); }
/* Generated stub for version_and_exit */
char *version_and_exit(const void *unused UNNEEDED)
{ fprintf(stderr, "version_and_exit called!\n"); abort(); }

8
cli/test/run-remove-hint.c

@ -2,6 +2,7 @@
#include <assert.h>
#include <common/amount.h>
#include <common/bigsize.h>
#include <common/channel_id.h>
#include <common/json_stream.h>
#include <common/wireaddr.h>
#include <fcntl.h>
@ -66,6 +67,10 @@ size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED)
/* Generated stub for fmt_wireaddr_without_port */
char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr *a UNNEEDED)
{ fprintf(stderr, "fmt_wireaddr_without_port called!\n"); abort(); }
/* Generated stub for fromwire_channel_id */
void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "fromwire_channel_id called!\n"); abort(); }
/* Generated stub for json_add_member */
void json_add_member(struct json_stream *js UNNEEDED,
const char *fieldname UNNEEDED,
@ -88,6 +93,9 @@ void json_object_end(struct json_stream *js UNNEEDED)
/* Generated stub for json_object_start */
void json_object_start(struct json_stream *ks UNNEEDED, const char *fieldname UNNEEDED)
{ fprintf(stderr, "json_object_start called!\n"); abort(); }
/* Generated stub for towire_channel_id */
void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "towire_channel_id called!\n"); abort(); }
/* Generated stub for version_and_exit */
char *version_and_exit(const void *unused UNNEEDED)
{ fprintf(stderr, "version_and_exit called!\n"); abort(); }

1
closingd/Makefile

@ -46,6 +46,7 @@ CLOSINGD_COMMON_OBJS := \
common/base32.o \
common/bigsize.o \
common/bip32.o \
common/channel_id.o \
common/close_tx.o \
common/crypto_state.o \
common/crypto_sync.o \

1
common/Makefile

@ -10,6 +10,7 @@ COMMON_SRC_NOGEN := \
common/blinding.c \
common/bolt11.c \
common/channel_config.c \
common/channel_id.c \
common/coin_mvt.c \
common/close_tx.c \
common/configdir.c \

26
common/channel_id.c

@ -0,0 +1,26 @@
#include <bitcoin/tx.h>
#include <common/channel_id.h>
#include <common/type_to_string.h>
#include <wire/wire.h>
void derive_channel_id(struct channel_id *channel_id,
const struct bitcoin_txid *txid, u16 txout)
{
BUILD_ASSERT(sizeof(*channel_id) == sizeof(*txid));
memcpy(channel_id, txid, sizeof(*channel_id));
channel_id->id[sizeof(*channel_id)-2] ^= txout >> 8;
channel_id->id[sizeof(*channel_id)-1] ^= txout;
}
void towire_channel_id(u8 **pptr, const struct channel_id *channel_id)
{
towire(pptr, channel_id, sizeof(*channel_id));
}
void fromwire_channel_id(const u8 **cursor, size_t *max,
struct channel_id *channel_id)
{
fromwire(cursor, max, channel_id, sizeof(*channel_id));
}
REGISTER_TYPE_TO_HEXSTR(channel_id);

29
common/channel_id.h

@ -0,0 +1,29 @@
#ifndef LIGHTNING_COMMON_CHANNEL_ID_H
#define LIGHTNING_COMMON_CHANNEL_ID_H
#include "config.h"
#include <ccan/short_types/short_types.h>
#include <ccan/structeq/structeq.h>
struct bitcoin_txid;
/* BOLT #2:
*
* This message introduces the `channel_id` to identify the channel. It's
* derived from the funding transaction by combining the `funding_txid` and
* the `funding_output_index`, using big-endian exclusive-OR
* (i.e. `funding_output_index` alters the last 2 bytes).
*/
struct channel_id {
u8 id[32];
};
/* Define channel_id_eq (no padding) */
STRUCTEQ_DEF(channel_id, 0, id);
void derive_channel_id(struct channel_id *channel_id,
const struct bitcoin_txid *txid, u16 txout);
/* Marshalling/unmarshalling functions */
void towire_channel_id(u8 **pptr, const struct channel_id *channel_id);
void fromwire_channel_id(const u8 **cursor, size_t *max,
struct channel_id *channel_id);
#endif /* LIGHTNING_COMMON_CHANNEL_ID_H */

1
common/coin_mvt.h

@ -7,6 +7,7 @@
#include <ccan/short_types/short_types.h>
#include <ccan/tal/tal.h>
#include <common/amount.h>
#include <common/channel_id.h>
#include <stdbool.h>
#include <wire/wire.h>

1
common/json_helpers.c

@ -2,6 +2,7 @@
#include <bitcoin/short_channel_id.h>
#include <ccan/ccan/str/hex/hex.h>
#include <common/amount.h>
#include <common/channel_id.h>
#include <common/json_helpers.h>
#include <common/node_id.h>
#include <errno.h>

1
common/json_tok.c

@ -3,6 +3,7 @@
#include <ccan/str/hex/hex.h>
#include <ccan/tal/str/str.h>
#include <common/amount.h>
#include <common/channel_id.h>
#include <common/json_command.h>
#include <common/json_helpers.h>
#include <common/json_tok.h>

1
common/peer_status_wire.csv

@ -1,3 +1,4 @@
#include <common/channel_id.h>
#include <common/per_peer_state.h>
# An error occurred: if error_for_them, that to go to them.

Can't render this file because it has a wrong number of fields in line 3.

1
connectd/Makefile

@ -44,6 +44,7 @@ CONNECTD_COMMON_OBJS := \
common/bech32_util.o \
common/bigsize.o \
common/bip32.o \
common/channel_id.o \
common/crypto_state.o \
common/cryptomsg.o \
common/daemon.o \

1
devtools/Makefile

@ -17,6 +17,7 @@ DEVTOOLS_COMMON_OBJS := \
common/bech32_util.o \
common/bigsize.o \
common/bolt11.o \
common/channel_id.o \
common/crypto_state.o \
common/decode_array.o \
common/features.o \

1
gossipd/Makefile

@ -46,6 +46,7 @@ GOSSIPD_COMMON_OBJS := \
common/bech32_util.o \
common/bigsize.o \
common/bip32.o \
common/channel_id.o \
common/crypto_state.o \
common/cryptomsg.o \
common/daemon.o \

7
gossipd/test/run-bench-find_route.c

@ -37,6 +37,10 @@ bool cupdate_different(struct gossip_store *gs UNNEEDED,
/* Generated stub for fmt_wireaddr_without_port */
char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr *a UNNEEDED)
{ fprintf(stderr, "fmt_wireaddr_without_port called!\n"); abort(); }
/* Generated stub for fromwire_channel_id */
void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "fromwire_channel_id called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_channel_amount */
bool fromwire_gossip_store_channel_amount(const void *p UNNEEDED, struct amount_sat *satoshis UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_channel_amount called!\n"); abort(); }
@ -96,6 +100,9 @@ char *sanitize_error(const tal_t *ctx UNNEEDED, const u8 *errmsg UNNEEDED,
void status_failed(enum status_failreason code UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "status_failed called!\n"); abort(); }
/* Generated stub for towire_channel_id */
void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "towire_channel_id called!\n"); abort(); }
/* Generated stub for towire_errorfmt */
u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,

7
gossipd/test/run-crc32_of_update.c

@ -31,6 +31,10 @@ struct peer *find_peer(struct daemon *daemon UNNEEDED, const struct node_id *id
/* Generated stub for fmt_wireaddr_without_port */
char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr *a UNNEEDED)
{ fprintf(stderr, "fmt_wireaddr_without_port called!\n"); abort(); }
/* Generated stub for fromwire_channel_id */
void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "fromwire_channel_id called!\n"); abort(); }
/* Generated stub for fromwire_gossip_dev_set_max_scids_encode_size */
bool fromwire_gossip_dev_set_max_scids_encode_size(const void *p UNNEEDED, u32 *max UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_dev_set_max_scids_encode_size called!\n"); abort(); }
@ -118,6 +122,9 @@ void status_fmt(enum log_level level UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "status_fmt called!\n"); abort(); }
/* Generated stub for towire_channel_id */
void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "towire_channel_id called!\n"); abort(); }
/* Generated stub for towire_errorfmt */
u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,

7
gossipd/test/run-extended-info.c

@ -36,6 +36,10 @@ struct short_channel_id *decode_short_ids(const tal_t *ctx UNNEEDED, const u8 *e
/* Generated stub for fmt_wireaddr_without_port */
char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr *a UNNEEDED)
{ fprintf(stderr, "fmt_wireaddr_without_port called!\n"); abort(); }
/* Generated stub for fromwire_channel_id */
void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "fromwire_channel_id called!\n"); abort(); }
/* Generated stub for fromwire_gossip_dev_set_max_scids_encode_size */
bool fromwire_gossip_dev_set_max_scids_encode_size(const void *p UNNEEDED, u32 *max UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_dev_set_max_scids_encode_size called!\n"); abort(); }
@ -88,6 +92,9 @@ void queue_peer_from_store(struct peer *peer UNNEEDED,
/* Generated stub for queue_peer_msg */
void queue_peer_msg(struct peer *peer UNNEEDED, const u8 *msg TAKES UNNEEDED)
{ fprintf(stderr, "queue_peer_msg called!\n"); abort(); }
/* Generated stub for towire_channel_id */
void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "towire_channel_id called!\n"); abort(); }
/* Generated stub for towire_errorfmt */
u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,

7
gossipd/test/run-find_route-specific.c

@ -24,6 +24,10 @@ bool cupdate_different(struct gossip_store *gs UNNEEDED,
/* Generated stub for fmt_wireaddr_without_port */
char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr *a UNNEEDED)
{ fprintf(stderr, "fmt_wireaddr_without_port called!\n"); abort(); }
/* Generated stub for fromwire_channel_id */
void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "fromwire_channel_id called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_channel_amount */
bool fromwire_gossip_store_channel_amount(const void *p UNNEEDED, struct amount_sat *satoshis UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_channel_amount called!\n"); abort(); }
@ -83,6 +87,9 @@ char *sanitize_error(const tal_t *ctx UNNEEDED, const u8 *errmsg UNNEEDED,
void status_failed(enum status_failreason code UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "status_failed called!\n"); abort(); }
/* Generated stub for towire_channel_id */
void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "towire_channel_id called!\n"); abort(); }
/* Generated stub for towire_errorfmt */
u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,

7
gossipd/test/run-find_route.c

@ -24,6 +24,10 @@ bool cupdate_different(struct gossip_store *gs UNNEEDED,
/* Generated stub for fmt_wireaddr_without_port */
char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr *a UNNEEDED)
{ fprintf(stderr, "fmt_wireaddr_without_port called!\n"); abort(); }
/* Generated stub for fromwire_channel_id */
void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "fromwire_channel_id called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_channel_amount */
bool fromwire_gossip_store_channel_amount(const void *p UNNEEDED, struct amount_sat *satoshis UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_channel_amount called!\n"); abort(); }
@ -83,6 +87,9 @@ char *sanitize_error(const tal_t *ctx UNNEEDED, const u8 *errmsg UNNEEDED,
void status_failed(enum status_failreason code UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "status_failed called!\n"); abort(); }
/* Generated stub for towire_channel_id */
void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "towire_channel_id called!\n"); abort(); }
/* Generated stub for towire_errorfmt */
u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,

7
gossipd/test/run-next_block_range.c

@ -10,6 +10,10 @@
/* Generated stub for fmt_wireaddr_without_port */
char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr *a UNNEEDED)
{ fprintf(stderr, "fmt_wireaddr_without_port called!\n"); abort(); }
/* Generated stub for fromwire_channel_id */
void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "fromwire_channel_id called!\n"); abort(); }
/* Generated stub for json_add_member */
void json_add_member(struct json_stream *js UNNEEDED,
const char *fieldname UNNEEDED,
@ -73,6 +77,9 @@ void status_fmt(enum log_level level UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "status_fmt called!\n"); abort(); }
/* Generated stub for towire_channel_id */
void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "towire_channel_id called!\n"); abort(); }
/* Generated stub for would_ratelimit_cupdate */
bool would_ratelimit_cupdate(struct routing_state *rstate UNNEEDED,
const struct half_chan *hc UNNEEDED,

7
gossipd/test/run-overlong.c

@ -24,6 +24,10 @@ bool cupdate_different(struct gossip_store *gs UNNEEDED,
/* Generated stub for fmt_wireaddr_without_port */
char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr *a UNNEEDED)
{ fprintf(stderr, "fmt_wireaddr_without_port called!\n"); abort(); }
/* Generated stub for fromwire_channel_id */
void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "fromwire_channel_id called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_channel_amount */
bool fromwire_gossip_store_channel_amount(const void *p UNNEEDED, struct amount_sat *satoshis UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_channel_amount called!\n"); abort(); }
@ -83,6 +87,9 @@ char *sanitize_error(const tal_t *ctx UNNEEDED, const u8 *errmsg UNNEEDED,
void status_failed(enum status_failreason code UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "status_failed called!\n"); abort(); }
/* Generated stub for towire_channel_id */
void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "towire_channel_id called!\n"); abort(); }
/* Generated stub for towire_errorfmt */
u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,

7
gossipd/test/run-txout_failure.c

@ -12,6 +12,10 @@ bool cupdate_different(struct gossip_store *gs UNNEEDED,
/* Generated stub for fmt_wireaddr_without_port */
char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr *a UNNEEDED)
{ fprintf(stderr, "fmt_wireaddr_without_port called!\n"); abort(); }
/* Generated stub for fromwire_channel_id */
void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "fromwire_channel_id called!\n"); abort(); }
/* Generated stub for fromwire_gossipd_local_add_channel */
bool fromwire_gossipd_local_add_channel(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct node_id *remote_node_id UNNEEDED, struct amount_sat *satoshis UNNEEDED, u8 **features UNNEEDED)
{ fprintf(stderr, "fromwire_gossipd_local_add_channel called!\n"); abort(); }
@ -95,6 +99,9 @@ void status_fmt(enum log_level level UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "status_fmt called!\n"); abort(); }
/* Generated stub for towire_channel_id */
void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "towire_channel_id called!\n"); abort(); }
/* Generated stub for towire_errorfmt */
u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,

1
hsmd/Makefile

@ -16,6 +16,7 @@ HSMD_COMMON_OBJS := \
common/amount.o \
common/bigsize.o \
common/bip32.o \
common/channel_id.o \
common/daemon.o \
common/daemon_conn.o \
common/derive_basepoints.o \

1
lightningd/Makefile

@ -24,6 +24,7 @@ LIGHTNINGD_COMMON_OBJS := \
common/bip32.o \
common/blinding.o \
common/bolt11.o \
common/channel_id.o \
common/channel_config.o \
common/coin_mvt.o \
common/configdir.o \

1
lightningd/json.c

@ -7,6 +7,7 @@
#include <ccan/str/hex/hex.h>
#include <ccan/tal/str/str.h>
#include <common/bech32.h>
#include <common/channel_id.h>
#include <common/json.h>
#include <common/json_command.h>
#include <common/json_helpers.h>

1
lightningd/options.c

@ -10,6 +10,7 @@
#include <ccan/tal/path/path.h>
#include <ccan/tal/str/str.h>
#include <common/base64.h>
#include <common/channel_id.h>
#include <common/derive_basepoints.h>
#include <common/features.h>
#include <common/json_command.h>

7
lightningd/test/run-find_my_abspath.c

@ -81,6 +81,10 @@ void free_htlcs(struct lightningd *ld UNNEEDED, const struct channel *channel UN
/* Generated stub for free_unreleased_txs */
void free_unreleased_txs(struct wallet *w UNNEEDED)
{ fprintf(stderr, "free_unreleased_txs called!\n"); abort(); }
/* Generated stub for fromwire_channel_id */
void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "fromwire_channel_id called!\n"); abort(); }
/* Generated stub for fromwire_status_fail */
bool fromwire_status_fail(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, enum status_failreason *failreason UNNEEDED, wirestring **desc UNNEEDED)
{ fprintf(stderr, "fromwire_status_fail called!\n"); abort(); }
@ -213,6 +217,9 @@ void setup_topology(struct chain_topology *topology UNNEEDED, struct timers *tim
/* Generated stub for timer_expired */
void timer_expired(tal_t *ctx UNNEEDED, struct timer *timer UNNEEDED)
{ fprintf(stderr, "timer_expired called!\n"); abort(); }
/* Generated stub for towire_channel_id */
void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "towire_channel_id called!\n"); abort(); }
/* Generated stub for txfilter_add_derkey */
void txfilter_add_derkey(struct txfilter *filter UNNEEDED,
const u8 derkey[PUBKEY_CMPR_LEN])

11
lightningd/test/run-invoice-select-inchan.c

@ -81,6 +81,10 @@ void connect_succeeded(struct lightningd *ld UNNEEDED, const struct peer *peer U
void delay_then_reconnect(struct channel *channel UNNEEDED, u32 seconds_delay UNNEEDED,
const struct wireaddr_internal *addrhint TAKES UNNEEDED)
{ fprintf(stderr, "delay_then_reconnect called!\n"); abort(); }
/* Generated stub for derive_channel_id */
void derive_channel_id(struct channel_id *channel_id UNNEEDED,
const struct bitcoin_txid *txid UNNEEDED, u16 txout UNNEEDED)
{ fprintf(stderr, "derive_channel_id called!\n"); abort(); }
/* Generated stub for dup_fee_states */
struct fee_states *dup_fee_states(const tal_t *ctx UNNEEDED,
const struct fee_states *fee_states TAKES UNNEEDED)
@ -110,6 +114,10 @@ char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr
/* Generated stub for fromwire_channel_dev_memleak_reply */
bool fromwire_channel_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNEEDED)
{ fprintf(stderr, "fromwire_channel_dev_memleak_reply called!\n"); abort(); }
/* Generated stub for fromwire_channel_id */
void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "fromwire_channel_id called!\n"); abort(); }
/* Generated stub for fromwire_connect_peer_connected */
bool fromwire_connect_peer_connected(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct node_id *id UNNEEDED, struct wireaddr_internal *addr UNNEEDED, struct per_peer_state **pps UNNEEDED, u8 **features UNNEEDED)
{ fprintf(stderr, "fromwire_connect_peer_connected called!\n"); abort(); }
@ -402,6 +410,9 @@ u8 *towire_channel_dev_memleak(const tal_t *ctx UNNEEDED)
/* Generated stub for towire_channel_dev_reenable_commit */
u8 *towire_channel_dev_reenable_commit(const tal_t *ctx UNNEEDED)
{ fprintf(stderr, "towire_channel_dev_reenable_commit called!\n"); abort(); }
/* Generated stub for towire_channel_id */
void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "towire_channel_id called!\n"); abort(); }
/* Generated stub for towire_channel_send_shutdown */
u8 *towire_channel_send_shutdown(const tal_t *ctx UNNEEDED, const u8 *shutdown_scriptpubkey UNNEEDED)
{ fprintf(stderr, "towire_channel_send_shutdown called!\n"); abort(); }

7
lightningd/test/run-jsonrpc.c

@ -27,6 +27,10 @@ const char *feerate_name(enum feerate feerate UNNEEDED)
/* Generated stub for fmt_wireaddr_without_port */
char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr *a UNNEEDED)
{ fprintf(stderr, "fmt_wireaddr_without_port called!\n"); abort(); }
/* Generated stub for fromwire_channel_id */
void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "fromwire_channel_id called!\n"); abort(); }
/* Generated stub for json_to_pubkey */
bool json_to_pubkey(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
struct pubkey *pubkey UNNEEDED)
@ -104,6 +108,9 @@ struct command_result *param_tok(struct command *cmd UNNEEDED, const char *name
bool plugin_hook_call_(struct lightningd *ld UNNEEDED, const struct plugin_hook *hook UNNEEDED,
tal_t *cb_arg STEALS UNNEEDED)
{ fprintf(stderr, "plugin_hook_call_ called!\n"); abort(); }
/* Generated stub for towire_channel_id */
void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "towire_channel_id called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
bool deprecated_apis;

7
lightningd/test/run-log-pruning.c

@ -25,6 +25,10 @@ struct command_result *command_success(struct command *cmd UNNEEDED,
/* Generated stub for fmt_wireaddr_without_port */
char *fmt_wireaddr_without_port(const tal_t *ctx UNNEEDED, const struct wireaddr *a UNNEEDED)
{ fprintf(stderr, "fmt_wireaddr_without_port called!\n"); abort(); }
/* Generated stub for fromwire_channel_id */
void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "fromwire_channel_id called!\n"); abort(); }
/* Generated stub for json_add_member */
void json_add_member(struct json_stream *js UNNEEDED,
const char *fieldname UNNEEDED,
@ -64,6 +68,9 @@ void notify_warning(struct lightningd *ld UNNEEDED, struct log_entry *l UNNEEDED
bool param(struct command *cmd UNNEEDED, const char *buffer UNNEEDED,
const jsmntok_t params[] UNNEEDED, ...)
{ fprintf(stderr, "param called!\n"); abort(); }
/* Generated stub for towire_channel_id */
void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "towire_channel_id called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
int main(void)

1
onchaind/Makefile

@ -51,6 +51,7 @@ ONCHAIND_COMMON_OBJS := \
common/bigsize.o \
common/bip32.o \
common/coin_mvt.o \
common/channel_id.o \
common/daemon.o \
common/daemon_conn.o \
common/derive_basepoints.o \

1
openingd/Makefile

@ -40,6 +40,7 @@ OPENINGD_COMMON_OBJS := \
common/bigsize.o \
common/bip32.o \
common/channel_config.o \
common/channel_id.o \
common/crypto_state.o \
common/crypto_sync.o \
common/cryptomsg.o \

1
openingd/opening_wire.csv

@ -1,5 +1,6 @@
#include <common/cryptomsg.h>
#include <common/channel_config.h>
#include <common/channel_id.h>
#include <common/derive_basepoints.h>
#include <common/features.h>
#include <common/per_peer_state.h>

Can't render this file because it has a wrong number of fields in line 7.

4
wallet/test/run-wallet.c

@ -98,6 +98,10 @@ struct onionreply *create_onionreply(const tal_t *ctx UNNEEDED,
void delay_then_reconnect(struct channel *channel UNNEEDED, u32 seconds_delay UNNEEDED,
const struct wireaddr_internal *addrhint TAKES UNNEEDED)
{ fprintf(stderr, "delay_then_reconnect called!\n"); abort(); }
/* Generated stub for derive_channel_id */
void derive_channel_id(struct channel_id *channel_id UNNEEDED,
const struct bitcoin_txid *txid UNNEEDED, u16 txout UNNEEDED)
{ fprintf(stderr, "derive_channel_id called!\n"); abort(); }
/* Generated stub for ecdh */
void ecdh(const struct pubkey *point UNNEEDED, struct secret *ss UNNEEDED)
{ fprintf(stderr, "ecdh called!\n"); abort(); }

2
wire/Makefile

@ -74,7 +74,7 @@ wire/gen_peer_wire_csv wire/gen_onion_wire_csv: config.vars
# for testing and to prevent compile error about them being unused.
# This will be easier if test vectors are moved to separate files.
wire/gen_peer_wire.h: wire/gen_peer_wire_csv $(WIRE_BOLT_DEPS) wire/Makefile
$(BOLT_GEN) -s --expose-tlv-type=n1 --expose-tlv-type=n2 --page header $@ wire_type < $< > $@
$(BOLT_GEN) --include='common/channel_id.h' -s --expose-tlv-type=n1 --expose-tlv-type=n2 --page header $@ wire_type < $< > $@
wire/gen_peer_wire.c: wire/gen_peer_wire_csv $(WIRE_BOLT_DEPS) wire/Makefile
$(BOLT_GEN) -s --expose-tlv-type=n1 --expose-tlv-type=n2 --page impl ${@:.c=.h} wire_type < $< > $@

24
wire/fromwire.c

@ -242,12 +242,6 @@ void fromwire_secp256k1_ecdsa_recoverable_signature(const u8 **cursor,
fromwire_fail(cursor, max);
}
void fromwire_channel_id(const u8 **cursor, size_t *max,
struct channel_id *channel_id)
{
fromwire(cursor, max, channel_id, sizeof(*channel_id));
}
void fromwire_short_channel_id(const u8 **cursor, size_t *max,
struct short_channel_id *short_channel_id)
{
@ -347,24 +341,6 @@ char *fromwire_wirestring(const tal_t *ctx, const u8 **cursor, size_t *max)
return NULL;
}
REGISTER_TYPE_TO_HEXSTR(channel_id);
/* BOLT #2:
*
* This message introduces the `channel_id` to identify the channel. It's
* derived from the funding transaction by combining the `funding_txid` and
* the `funding_output_index`, using big-endian exclusive-OR
* (i.e. `funding_output_index` alters the last 2 bytes).
*/
void derive_channel_id(struct channel_id *channel_id,
const struct bitcoin_txid *txid, u16 txout)
{
BUILD_ASSERT(sizeof(*channel_id) == sizeof(*txid));
memcpy(channel_id, txid, sizeof(*channel_id));
channel_id->id[sizeof(*channel_id)-2] ^= txout >> 8;
channel_id->id[sizeof(*channel_id)-1] ^= txout;
}
struct bitcoin_tx *fromwire_bitcoin_tx(const tal_t *ctx,
const u8 **cursor, size_t *max)
{

7
wire/test/run-peer-wire.c

@ -34,6 +34,13 @@ bool amount_sat_eq(struct amount_sat a UNNEEDED, struct amount_sat b UNNEEDED)
struct amount_sat a UNNEEDED,
struct amount_sat b UNNEEDED)
{ fprintf(stderr, "amount_sat_sub called!\n"); abort(); }
/* Generated stub for fromwire_channel_id */
void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "fromwire_channel_id called!\n"); abort(); }
/* Generated stub for towire_channel_id */
void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "towire_channel_id called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
/* memsetting pubkeys doesn't work */

7
wire/test/run-tlvstream.c

@ -17,6 +17,13 @@ static const char *reason;
#include <wire/towire.c>
/* AUTOGENERATED MOCKS START */
/* Generated stub for fromwire_channel_id */
void fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "fromwire_channel_id called!\n"); abort(); }
/* Generated stub for towire_channel_id */
void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "towire_channel_id called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */

5
wire/towire.c

@ -150,11 +150,6 @@ void towire_secp256k1_ecdsa_recoverable_signature(u8 **pptr,
towire_u8(pptr, recid);
}
void towire_channel_id(u8 **pptr, const struct channel_id *channel_id)
{
towire(pptr, channel_id, sizeof(*channel_id));
}
void towire_short_channel_id(u8 **pptr,
const struct short_channel_id *short_channel_id)
{

11
wire/wire.h

@ -18,11 +18,6 @@
#include <secp256k1_recovery.h>
#include <stdlib.h>
struct channel_id {
u8 id[32];
};
/* Define channel_id_eq (no padding) */
STRUCTEQ_DEF(channel_id, 0, id);
struct bitcoin_blkid;
struct bitcoin_signature;
@ -41,9 +36,6 @@ typedef bigsize varint;
#define fromwire_varint fromwire_bigsize
#define towire_varint towire_bigsize
void derive_channel_id(struct channel_id *channel_id,
const struct bitcoin_txid *txid, u16 txout);
/* Read the type; returns -1 if not long enough. cursor is a tal ptr. */
int fromwire_peektype(const u8 *cursor);
const void *fromwire_fail(const u8 **cursor, size_t *max);
@ -57,7 +49,6 @@ void towire_secp256k1_ecdsa_signature(u8 **pptr,
const secp256k1_ecdsa_signature *signature);
void towire_secp256k1_ecdsa_recoverable_signature(u8 **pptr,
const secp256k1_ecdsa_recoverable_signature *rsig);
void towire_channel_id(u8 **pptr, const struct channel_id *channel_id);
void towire_short_channel_id(u8 **pptr,
const struct short_channel_id *short_channel_id);
void towire_short_channel_id_dir(u8 **pptr,
@ -114,8 +105,6 @@ void fromwire_secp256k1_ecdsa_signature(const u8 **cursor, size_t *max,
void fromwire_secp256k1_ecdsa_recoverable_signature(const u8 **cursor,
size_t *max,
secp256k1_ecdsa_recoverable_signature *rsig);
void fromwire_channel_id(const u8 **cursor, size_t *max,
struct channel_id *channel_id);
void fromwire_short_channel_id(const u8 **cursor, size_t *max,
struct short_channel_id *short_channel_id);
void fromwire_short_channel_id_dir(const u8 **cursor, size_t *max,

Loading…
Cancel
Save