Browse Source

Makefile: commit and preserve all the wiregenerated files.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: Build: we no longer require extra Python modules to build.
bump-pyln-proto
Rusty Russell 4 years ago
committed by neil saitug
parent
commit
3c6af3efb4
  1. 1
      .gitignore
  2. 3
      Makefile
  3. 1188
      channeld/channeld_wiregen.c
  4. 233
      channeld/channeld_wiregen.h
  5. 203
      closingd/closingd_wiregen.c
  6. 59
      closingd/closingd_wiregen.h
  7. 84
      common/peer_status_wiregen.c
  8. 38
      common/peer_status_wiregen.h
  9. 195
      common/status_wiregen.c
  10. 57
      common/status_wiregen.h
  11. 165
      connectd/connectd_gossipd_wiregen.c
  12. 58
      connectd/connectd_gossipd_wiregen.h
  13. 408
      connectd/connectd_wiregen.c
  14. 107
      connectd/connectd_wiregen.h
  15. 121
      gossipd/gossip_store_wiregen.c
  16. 47
      gossipd/gossip_store_wiregen.h
  17. 230
      gossipd/gossipd_peerd_wiregen.c
  18. 80
      gossipd/gossipd_peerd_wiregen.h
  19. 861
      gossipd/gossipd_wiregen.c
  20. 203
      gossipd/gossipd_wiregen.h
  21. 1218
      hsmd/hsmd_wiregen.c
  22. 275
      hsmd/hsmd_wiregen.h
  23. 630
      onchaind/onchaind_wiregen.c
  24. 159
      onchaind/onchaind_wiregen.h
  25. 583
      openingd/openingd_wiregen.c
  26. 125
      openingd/openingd_wiregen.h
  27. 1645
      wallet/db_postgres_sqlgen.c
  28. 1645
      wallet/db_sqlite3_sqlgen.c
  29. 1084
      wallet/statements_gettextgen.po
  30. 104
      wire/common_wiregen.c
  31. 45
      wire/common_wiregen.h
  32. 657
      wire/onion_printgen.c
  33. 61
      wire/onion_printgen.h
  34. 841
      wire/onion_wiregen.c
  35. 211
      wire/onion_wiregen.h
  36. 2040
      wire/peer_printgen.c
  37. 74
      wire/peer_printgen.h
  38. 2754
      wire/peer_wiregen.c
  39. 599
      wire/peer_wiregen.h

1
.gitignore

@ -8,7 +8,6 @@
*.gcno
*.dSYM
*.rej
*.po
*.pyc
.cppcheck-suppress
.mypy_cache

3
Makefile

@ -297,6 +297,9 @@ ALL_GEN_HEADERS := $(filter gen%.h %printgen.h %wiregen.h,$(ALL_C_HEADERS))
ALL_GEN_SOURCES := $(filter gen%.c %printgen.c %wiregen.c,$(ALL_C_SOURCES))
ALL_NONGEN_SRCFILES := $(filter-out gen%.h %printgen.h %wiregen.h,$(ALL_C_HEADERS)) $(filter-out gen%.c %printgen.c %wiregen.c,$(ALL_C_SOURCES))
# Don't delete these intermediaries.
.PRECIOUS: $(ALL_GEN_HEADERS) $(ALL_GEN_SOURCES)
# Every single object file.
ALL_OBJS := $(ALL_C_SOURCES:.c=.o)

1188
channeld/channeld_wiregen.c

File diff suppressed because it is too large

233
channeld/channeld_wiregen.h

@ -0,0 +1,233 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the _csv file it was generated from. */
/* Original template can be found at tools/gen/header_template */
#ifndef LIGHTNING_CHANNELD_CHANNELD_WIREGEN_H
#define LIGHTNING_CHANNELD_CHANNELD_WIREGEN_H
#include <ccan/tal/tal.h>
#include <wire/tlvstream.h>
#include <wire/wire.h>
#include <common/cryptomsg.h>
#include <common/channel_config.h>
#include <common/derive_basepoints.h>
#include <common/features.h>
#include <common/fee_states.h>
#include <common/per_peer_state.h>
#include <bitcoin/preimage.h>
#include <common/penalty_base.h>
#include <common/htlc_wire.h>
enum channeld_wire {
/* Begin! (passes gossipd-client fd) */
WIRE_CHANNELD_INIT = 1000,
/* master->channeld funding hit new depth(funding locked if >= lock depth) */
WIRE_CHANNELD_FUNDING_DEPTH = 1002,
/* Tell channel to offer this htlc */
WIRE_CHANNELD_OFFER_HTLC = 1004,
/* Reply; synchronous since IDs have to increment. */
WIRE_CHANNELD_OFFER_HTLC_REPLY = 1104,
/* Main daemon found out the preimage for an HTLC */
WIRE_CHANNELD_FULFILL_HTLC = 1005,
/* Main daemon says HTLC failed */
WIRE_CHANNELD_FAIL_HTLC = 1006,
/* When we receive funding_locked. */
WIRE_CHANNELD_GOT_FUNDING_LOCKED = 1019,
/* When we send a commitment_signed message */
WIRE_CHANNELD_SENDING_COMMITSIG = 1020,
/* Wait for reply */
WIRE_CHANNELD_SENDING_COMMITSIG_REPLY = 1120,
/* When we have a commitment_signed message */
WIRE_CHANNELD_GOT_COMMITSIG = 1021,
/* Wait for reply */
WIRE_CHANNELD_GOT_COMMITSIG_REPLY = 1121,
WIRE_CHANNELD_GOT_REVOKE = 1022,
/* Wait for reply */
/* (eg. if we sent another commitment_signed */
WIRE_CHANNELD_GOT_REVOKE_REPLY = 1122,
/* Tell peer to shut down channel. */
WIRE_CHANNELD_SEND_SHUTDOWN = 1023,
/* Peer told us that channel is shutting down */
WIRE_CHANNELD_GOT_SHUTDOWN = 1024,
/* Shutdown is complete */
WIRE_CHANNELD_SHUTDOWN_COMPLETE = 1025,
/* Re-enable commit timer. */
WIRE_CHANNELD_DEV_REENABLE_COMMIT = 1026,
WIRE_CHANNELD_DEV_REENABLE_COMMIT_REPLY = 1126,
WIRE_CHANNELD_FEERATES = 1027,
/* master -> channeld: do you have a memleak? */
WIRE_CHANNELD_DEV_MEMLEAK = 1033,
WIRE_CHANNELD_DEV_MEMLEAK_REPLY = 1133,
/* Peer presented proof it was from the future. */
WIRE_CHANNELD_FAIL_FALLEN_BEHIND = 1028,
/* Handle a channel specific feerate base ppm configuration */
WIRE_CHANNELD_SPECIFIC_FEERATES = 1029,
/* When we receive announcement_signatures for channel announce */
WIRE_CHANNELD_GOT_ANNOUNCEMENT = 1017,
/* Ask channeld to send a error message. Used in forgetting channel case. */
WIRE_CHANNELD_SEND_ERROR = 1008,
/* Tell master channeld has sent the error message. */
WIRE_CHANNELD_SEND_ERROR_REPLY = 1108,
/* Tell lightningd we got a onion message (for us */
WIRE_GOT_ONIONMSG_TO_US = 1142,
WIRE_GOT_ONIONMSG_FORWARD = 1143,
/* Lightningd tells us to send a onion message. */
WIRE_SEND_ONIONMSG = 1040,
};
const char *channeld_wire_name(int e);
/**
* Determine whether a given message type is defined as a message.
*
* Returns true if the message type is part of the message definitions we have
* generated parsers for, false if it is a custom message that cannot be
* handled internally.
*/
bool channeld_wire_is_defined(u16 type);
/* WIRE: CHANNELD_INIT */
/* Begin! (passes gossipd-client fd) */
u8 *towire_channeld_init(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_features, const struct bitcoin_txid *funding_txid, u16 funding_txout, struct amount_sat funding_satoshi, u32 minimum_depth, const struct channel_config *our_config, const struct channel_config *their_config, const struct fee_states *fee_states, u32 feerate_min, u32 feerate_max, u32 feerate_penalty, const struct bitcoin_signature *first_commit_sig, const struct per_peer_state *per_peer_state, const struct pubkey *remote_fundingkey, const struct basepoints *remote_basepoints, const struct pubkey *remote_per_commit, const struct pubkey *old_remote_per_commit, enum side opener, u32 fee_base, u32 fee_proportional, struct amount_msat local_msatoshi, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, const struct node_id *local_node_id, const struct node_id *remote_node_id, u32 commit_msec, u16 cltv_delta, bool last_was_revoke, const struct changed_htlc *last_sent_commit, u64 next_index_local, u64 next_index_remote, u64 revocations_received, u64 next_htlc_id, const struct existing_htlc **htlcs, bool local_funding_locked, bool remote_funding_locked, const struct short_channel_id *funding_short_id, bool reestablish, bool send_shutdown, bool remote_shutdown_received, const u8 *final_scriptpubkey, u8 flags, const u8 *init_peer_pkt, bool reached_announce_depth, const struct secret *last_remote_secret, const u8 *their_features, const u8 *upfront_shutdown_script, const secp256k1_ecdsa_signature *remote_ann_node_sig, const secp256k1_ecdsa_signature *remote_ann_bitcoin_sig, bool option_static_remotekey, bool option_anchor_outputs, bool dev_fast_gossip, bool dev_fail_process_onionpacket, const struct penalty_base *pbases);
bool fromwire_channeld_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_features, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct amount_sat *funding_satoshi, u32 *minimum_depth, struct channel_config *our_config, struct channel_config *their_config, struct fee_states **fee_states, u32 *feerate_min, u32 *feerate_max, u32 *feerate_penalty, struct bitcoin_signature *first_commit_sig, struct per_peer_state **per_peer_state, struct pubkey *remote_fundingkey, struct basepoints *remote_basepoints, struct pubkey *remote_per_commit, struct pubkey *old_remote_per_commit, enum side *opener, u32 *fee_base, u32 *fee_proportional, struct amount_msat *local_msatoshi, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, struct node_id *local_node_id, struct node_id *remote_node_id, u32 *commit_msec, u16 *cltv_delta, bool *last_was_revoke, struct changed_htlc **last_sent_commit, u64 *next_index_local, u64 *next_index_remote, u64 *revocations_received, u64 *next_htlc_id, struct existing_htlc ***htlcs, bool *local_funding_locked, bool *remote_funding_locked, struct short_channel_id *funding_short_id, bool *reestablish, bool *send_shutdown, bool *remote_shutdown_received, u8 **final_scriptpubkey, u8 *flags, u8 **init_peer_pkt, bool *reached_announce_depth, struct secret *last_remote_secret, u8 **their_features, u8 **upfront_shutdown_script, secp256k1_ecdsa_signature **remote_ann_node_sig, secp256k1_ecdsa_signature **remote_ann_bitcoin_sig, bool *option_static_remotekey, bool *option_anchor_outputs, bool *dev_fast_gossip, bool *dev_fail_process_onionpacket, struct penalty_base **pbases);
/* WIRE: CHANNELD_FUNDING_DEPTH */
/* master->channeld funding hit new depth(funding locked if >= lock depth) */
u8 *towire_channeld_funding_depth(const tal_t *ctx, const struct short_channel_id *short_channel_id, u32 depth);
bool fromwire_channeld_funding_depth(const tal_t *ctx, const void *p, struct short_channel_id **short_channel_id, u32 *depth);
/* WIRE: CHANNELD_OFFER_HTLC */
/* Tell channel to offer this htlc */
u8 *towire_channeld_offer_htlc(const tal_t *ctx, struct amount_msat amount_msat, u32 cltv_expiry, const struct sha256 *payment_hash, const u8 onion_routing_packet[1366], const struct pubkey *blinding);
bool fromwire_channeld_offer_htlc(const tal_t *ctx, const void *p, struct amount_msat *amount_msat, u32 *cltv_expiry, struct sha256 *payment_hash, u8 onion_routing_packet[1366], struct pubkey **blinding);
/* WIRE: CHANNELD_OFFER_HTLC_REPLY */
/* Reply; synchronous since IDs have to increment. */
u8 *towire_channeld_offer_htlc_reply(const tal_t *ctx, u64 id, const u8 *failuremsg, const wirestring *failurestr);
bool fromwire_channeld_offer_htlc_reply(const tal_t *ctx, const void *p, u64 *id, u8 **failuremsg, wirestring **failurestr);
/* WIRE: CHANNELD_FULFILL_HTLC */
/* Main daemon found out the preimage for an HTLC */
u8 *towire_channeld_fulfill_htlc(const tal_t *ctx, const struct fulfilled_htlc *fulfilled_htlc);
bool fromwire_channeld_fulfill_htlc(const void *p, struct fulfilled_htlc *fulfilled_htlc);
/* WIRE: CHANNELD_FAIL_HTLC */
/* Main daemon says HTLC failed */
u8 *towire_channeld_fail_htlc(const tal_t *ctx, const struct failed_htlc *failed_htlc);
bool fromwire_channeld_fail_htlc(const tal_t *ctx, const void *p, struct failed_htlc **failed_htlc);
/* WIRE: CHANNELD_GOT_FUNDING_LOCKED */
/* When we receive funding_locked. */
u8 *towire_channeld_got_funding_locked(const tal_t *ctx, const struct pubkey *next_per_commit_point);
bool fromwire_channeld_got_funding_locked(const void *p, struct pubkey *next_per_commit_point);
/* WIRE: CHANNELD_SENDING_COMMITSIG */
/* When we send a commitment_signed message */
u8 *towire_channeld_sending_commitsig(const tal_t *ctx, u64 commitnum, const struct penalty_base *pbase, const struct fee_states *fee_states, const struct changed_htlc *changed, const struct bitcoin_signature *commit_sig, const struct bitcoin_signature *htlc_sigs);
bool fromwire_channeld_sending_commitsig(const tal_t *ctx, const void *p, u64 *commitnum, struct penalty_base **pbase, struct fee_states **fee_states, struct changed_htlc **changed, struct bitcoin_signature *commit_sig, struct bitcoin_signature **htlc_sigs);
/* WIRE: CHANNELD_SENDING_COMMITSIG_REPLY */
/* Wait for reply */
u8 *towire_channeld_sending_commitsig_reply(const tal_t *ctx);
bool fromwire_channeld_sending_commitsig_reply(const void *p);
/* WIRE: CHANNELD_GOT_COMMITSIG */
/* When we have a commitment_signed message */
u8 *towire_channeld_got_commitsig(const tal_t *ctx, u64 commitnum, const struct fee_states *fee_states, const struct bitcoin_signature *signature, const struct bitcoin_signature *htlc_signature, const struct added_htlc *added, const struct fulfilled_htlc *fulfilled, const struct failed_htlc **failed, const struct changed_htlc *changed, const struct bitcoin_tx *tx);
bool fromwire_channeld_got_commitsig(const tal_t *ctx, const void *p, u64 *commitnum, struct fee_states **fee_states, struct bitcoin_signature *signature, struct bitcoin_signature **htlc_signature, struct added_htlc **added, struct fulfilled_htlc **fulfilled, struct failed_htlc ***failed, struct changed_htlc **changed, struct bitcoin_tx **tx);
/* WIRE: CHANNELD_GOT_COMMITSIG_REPLY */
/* Wait for reply */
u8 *towire_channeld_got_commitsig_reply(const tal_t *ctx);
bool fromwire_channeld_got_commitsig_reply(const void *p);
/* WIRE: CHANNELD_GOT_REVOKE */
u8 *towire_channeld_got_revoke(const tal_t *ctx, u64 revokenum, const struct secret *per_commitment_secret, const struct pubkey *next_per_commit_point, const struct fee_states *fee_states, const struct changed_htlc *changed, const struct penalty_base *pbase, const struct bitcoin_tx *penalty_tx);
bool fromwire_channeld_got_revoke(const tal_t *ctx, const void *p, u64 *revokenum, struct secret *per_commitment_secret, struct pubkey *next_per_commit_point, struct fee_states **fee_states, struct changed_htlc **changed, struct penalty_base **pbase, struct bitcoin_tx **penalty_tx);
/* WIRE: CHANNELD_GOT_REVOKE_REPLY */
/* Wait for reply */
/* (eg. if we sent another commitment_signed */
u8 *towire_channeld_got_revoke_reply(const tal_t *ctx);
bool fromwire_channeld_got_revoke_reply(const void *p);
/* WIRE: CHANNELD_SEND_SHUTDOWN */
/* Tell peer to shut down channel. */
u8 *towire_channeld_send_shutdown(const tal_t *ctx, const u8 *shutdown_scriptpubkey);
bool fromwire_channeld_send_shutdown(const tal_t *ctx, const void *p, u8 **shutdown_scriptpubkey);
/* WIRE: CHANNELD_GOT_SHUTDOWN */
/* Peer told us that channel is shutting down */
u8 *towire_channeld_got_shutdown(const tal_t *ctx, const u8 *scriptpubkey);
bool fromwire_channeld_got_shutdown(const tal_t *ctx, const void *p, u8 **scriptpubkey);
/* WIRE: CHANNELD_SHUTDOWN_COMPLETE */
/* Shutdown is complete */
u8 *towire_channeld_shutdown_complete(const tal_t *ctx, const struct per_peer_state *per_peer_state);
bool fromwire_channeld_shutdown_complete(const tal_t *ctx, const void *p, struct per_peer_state **per_peer_state);
/* WIRE: CHANNELD_DEV_REENABLE_COMMIT */
/* Re-enable commit timer. */
u8 *towire_channeld_dev_reenable_commit(const tal_t *ctx);
bool fromwire_channeld_dev_reenable_commit(const void *p);
/* WIRE: CHANNELD_DEV_REENABLE_COMMIT_REPLY */
u8 *towire_channeld_dev_reenable_commit_reply(const tal_t *ctx);
bool fromwire_channeld_dev_reenable_commit_reply(const void *p);
/* WIRE: CHANNELD_FEERATES */
u8 *towire_channeld_feerates(const tal_t *ctx, u32 feerate, u32 min_feerate, u32 max_feerate, u32 penalty_feerate);
bool fromwire_channeld_feerates(const void *p, u32 *feerate, u32 *min_feerate, u32 *max_feerate, u32 *penalty_feerate);
/* WIRE: CHANNELD_DEV_MEMLEAK */
/* master -> channeld: do you have a memleak? */
u8 *towire_channeld_dev_memleak(const tal_t *ctx);
bool fromwire_channeld_dev_memleak(const void *p);
/* WIRE: CHANNELD_DEV_MEMLEAK_REPLY */
u8 *towire_channeld_dev_memleak_reply(const tal_t *ctx, bool leak);
bool fromwire_channeld_dev_memleak_reply(const void *p, bool *leak);
/* WIRE: CHANNELD_FAIL_FALLEN_BEHIND */
/* Peer presented proof it was from the future. */
u8 *towire_channeld_fail_fallen_behind(const tal_t *ctx, const struct pubkey *remote_per_commitment_point);
bool fromwire_channeld_fail_fallen_behind(const tal_t *ctx, const void *p, struct pubkey **remote_per_commitment_point);
/* WIRE: CHANNELD_SPECIFIC_FEERATES */
/* Handle a channel specific feerate base ppm configuration */
u8 *towire_channeld_specific_feerates(const tal_t *ctx, u32 feerate_base, u32 feerate_ppm);
bool fromwire_channeld_specific_feerates(const void *p, u32 *feerate_base, u32 *feerate_ppm);
/* WIRE: CHANNELD_GOT_ANNOUNCEMENT */
/* When we receive announcement_signatures for channel announce */
u8 *towire_channeld_got_announcement(const tal_t *ctx, const secp256k1_ecdsa_signature *remote_ann_node_sig, const secp256k1_ecdsa_signature *remote_ann_bitcoin_sig);
bool fromwire_channeld_got_announcement(const void *p, secp256k1_ecdsa_signature *remote_ann_node_sig, secp256k1_ecdsa_signature *remote_ann_bitcoin_sig);
/* WIRE: CHANNELD_SEND_ERROR */
/* Ask channeld to send a error message. Used in forgetting channel case. */
u8 *towire_channeld_send_error(const tal_t *ctx, const wirestring *reason);
bool fromwire_channeld_send_error(const tal_t *ctx, const void *p, wirestring **reason);
/* WIRE: CHANNELD_SEND_ERROR_REPLY */
/* Tell master channeld has sent the error message. */
u8 *towire_channeld_send_error_reply(const tal_t *ctx);
bool fromwire_channeld_send_error_reply(const void *p);
/* WIRE: GOT_ONIONMSG_TO_US */
/* Tell lightningd we got a onion message (for us */
u8 *towire_got_onionmsg_to_us(const tal_t *ctx, const struct pubkey *reply_blinding, const struct onionmsg_path **reply_path);
bool fromwire_got_onionmsg_to_us(const tal_t *ctx, const void *p, struct pubkey **reply_blinding, struct onionmsg_path ***reply_path);
/* WIRE: GOT_ONIONMSG_FORWARD */
u8 *towire_got_onionmsg_forward(const tal_t *ctx, const struct short_channel_id *next_scid, const struct node_id *next_node_id, const struct pubkey *next_blinding, const u8 next_onion[1366]);
bool fromwire_got_onionmsg_forward(const tal_t *ctx, const void *p, struct short_channel_id **next_scid, struct node_id **next_node_id, struct pubkey **next_blinding, u8 next_onion[1366]);
/* WIRE: SEND_ONIONMSG */
/* Lightningd tells us to send a onion message. */
u8 *towire_send_onionmsg(const tal_t *ctx, const u8 onion[1366], const struct pubkey *blinding);
bool fromwire_send_onionmsg(const tal_t *ctx, const void *p, u8 onion[1366], struct pubkey **blinding);
#endif /* LIGHTNING_CHANNELD_CHANNELD_WIREGEN_H */
// SHA256STAMP:exp-0-1b6f8d6af6aeb028ca014ecd646ecff1fc72b6b47f4ae04a0d6b24b92efb6eda

203
closingd/closingd_wiregen.c

@ -0,0 +1,203 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the .csv file it was generated from. */
/* Original template can be found at tools/gen/impl_template */
#include <closingd/closingd_wiregen.h>
#include <assert.h>
#include <ccan/array_size/array_size.h>
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/utils.h>
#include <stdio.h>
#ifndef SUPERVERBOSE
#define SUPERVERBOSE(...)
#endif
const char *closingd_wire_name(int e)
{
static char invalidbuf[sizeof("INVALID ") + STR_MAX_CHARS(e)];
switch ((enum closingd_wire)e) {
case WIRE_CLOSINGD_INIT: return "WIRE_CLOSINGD_INIT";
case WIRE_CLOSINGD_RECEIVED_SIGNATURE: return "WIRE_CLOSINGD_RECEIVED_SIGNATURE";
case WIRE_CLOSINGD_RECEIVED_SIGNATURE_REPLY: return "WIRE_CLOSINGD_RECEIVED_SIGNATURE_REPLY";
case WIRE_CLOSINGD_COMPLETE: return "WIRE_CLOSINGD_COMPLETE";
}
snprintf(invalidbuf, sizeof(invalidbuf), "INVALID %i", e);
return invalidbuf;
}
bool closingd_wire_is_defined(u16 type)
{
switch ((enum closingd_wire)type) {
case WIRE_CLOSINGD_INIT:;
case WIRE_CLOSINGD_RECEIVED_SIGNATURE:;
case WIRE_CLOSINGD_RECEIVED_SIGNATURE_REPLY:;
case WIRE_CLOSINGD_COMPLETE:;
return true;
}
return false;
}
/* WIRE: CLOSINGD_INIT */
/* Begin! (passes peer fd */
u8 *towire_closingd_init(const tal_t *ctx, const struct chainparams *chainparams, const struct per_peer_state *pps, const struct bitcoin_txid *funding_txid, u16 funding_txout, struct amount_sat funding_satoshi, const struct pubkey *local_fundingkey, const struct pubkey *remote_fundingkey, enum side opener, struct amount_sat local_sat, struct amount_sat remote_sat, struct amount_sat our_dust_limit, struct amount_sat min_fee_satoshi, struct amount_sat fee_limit_satoshi, struct amount_sat initial_fee_satoshi, const u8 *local_scriptpubkey, const u8 *remote_scriptpubkey, u64 fee_negotiation_step, u8 fee_negotiation_step_unit, bool reconnected, u64 next_index_local, u64 next_index_remote, u64 revocations_received, const u8 *channel_reestablish, const struct secret *last_remote_secret, bool dev_fast_gossip)
{
u16 local_scriptpubkey_len = tal_count(local_scriptpubkey);
u16 remote_scriptpubkey_len = tal_count(remote_scriptpubkey);
u16 channel_reestablish_len = tal_count(channel_reestablish);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_CLOSINGD_INIT);
towire_chainparams(&p, chainparams);
towire_per_peer_state(&p, pps);
towire_bitcoin_txid(&p, funding_txid);
towire_u16(&p, funding_txout);
towire_amount_sat(&p, funding_satoshi);
towire_pubkey(&p, local_fundingkey);
towire_pubkey(&p, remote_fundingkey);
towire_side(&p, opener);
towire_amount_sat(&p, local_sat);
towire_amount_sat(&p, remote_sat);
towire_amount_sat(&p, our_dust_limit);
towire_amount_sat(&p, min_fee_satoshi);
towire_amount_sat(&p, fee_limit_satoshi);
towire_amount_sat(&p, initial_fee_satoshi);
towire_u16(&p, local_scriptpubkey_len);
towire_u8_array(&p, local_scriptpubkey, local_scriptpubkey_len);
towire_u16(&p, remote_scriptpubkey_len);
towire_u8_array(&p, remote_scriptpubkey, remote_scriptpubkey_len);
towire_u64(&p, fee_negotiation_step);
towire_u8(&p, fee_negotiation_step_unit);
towire_bool(&p, reconnected);
towire_u64(&p, next_index_local);
towire_u64(&p, next_index_remote);
towire_u64(&p, revocations_received);
towire_u16(&p, channel_reestablish_len);
towire_u8_array(&p, channel_reestablish, channel_reestablish_len);
towire_secret(&p, last_remote_secret);
towire_bool(&p, dev_fast_gossip);
return memcheck(p, tal_count(p));
}
bool fromwire_closingd_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct per_peer_state **pps, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct amount_sat *funding_satoshi, struct pubkey *local_fundingkey, struct pubkey *remote_fundingkey, enum side *opener, struct amount_sat *local_sat, struct amount_sat *remote_sat, struct amount_sat *our_dust_limit, struct amount_sat *min_fee_satoshi, struct amount_sat *fee_limit_satoshi, struct amount_sat *initial_fee_satoshi, u8 **local_scriptpubkey, u8 **remote_scriptpubkey, u64 *fee_negotiation_step, u8 *fee_negotiation_step_unit, bool *reconnected, u64 *next_index_local, u64 *next_index_remote, u64 *revocations_received, u8 **channel_reestablish, struct secret *last_remote_secret, bool *dev_fast_gossip)
{
u16 local_scriptpubkey_len;
u16 remote_scriptpubkey_len;
u16 channel_reestablish_len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_CLOSINGD_INIT)
return false;
fromwire_chainparams(&cursor, &plen, chainparams);
*pps = fromwire_per_peer_state(ctx, &cursor, &plen);
fromwire_bitcoin_txid(&cursor, &plen, funding_txid);
*funding_txout = fromwire_u16(&cursor, &plen);
*funding_satoshi = fromwire_amount_sat(&cursor, &plen);
fromwire_pubkey(&cursor, &plen, local_fundingkey);
fromwire_pubkey(&cursor, &plen, remote_fundingkey);
*opener = fromwire_side(&cursor, &plen);
*local_sat = fromwire_amount_sat(&cursor, &plen);
*remote_sat = fromwire_amount_sat(&cursor, &plen);
*our_dust_limit = fromwire_amount_sat(&cursor, &plen);
*min_fee_satoshi = fromwire_amount_sat(&cursor, &plen);
*fee_limit_satoshi = fromwire_amount_sat(&cursor, &plen);
*initial_fee_satoshi = fromwire_amount_sat(&cursor, &plen);
local_scriptpubkey_len = fromwire_u16(&cursor, &plen);
// 2nd case local_scriptpubkey
*local_scriptpubkey = local_scriptpubkey_len ? tal_arr(ctx, u8, local_scriptpubkey_len) : NULL;
fromwire_u8_array(&cursor, &plen, *local_scriptpubkey, local_scriptpubkey_len);
remote_scriptpubkey_len = fromwire_u16(&cursor, &plen);
// 2nd case remote_scriptpubkey
*remote_scriptpubkey = remote_scriptpubkey_len ? tal_arr(ctx, u8, remote_scriptpubkey_len) : NULL;
fromwire_u8_array(&cursor, &plen, *remote_scriptpubkey, remote_scriptpubkey_len);
*fee_negotiation_step = fromwire_u64(&cursor, &plen);
*fee_negotiation_step_unit = fromwire_u8(&cursor, &plen);
*reconnected = fromwire_bool(&cursor, &plen);
*next_index_local = fromwire_u64(&cursor, &plen);
*next_index_remote = fromwire_u64(&cursor, &plen);
*revocations_received = fromwire_u64(&cursor, &plen);
channel_reestablish_len = fromwire_u16(&cursor, &plen);
// 2nd case channel_reestablish
*channel_reestablish = channel_reestablish_len ? tal_arr(ctx, u8, channel_reestablish_len) : NULL;
fromwire_u8_array(&cursor, &plen, *channel_reestablish, channel_reestablish_len);
fromwire_secret(&cursor, &plen, last_remote_secret);
*dev_fast_gossip = fromwire_bool(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: CLOSINGD_RECEIVED_SIGNATURE */
/* We received an offer */
u8 *towire_closingd_received_signature(const tal_t *ctx, const struct bitcoin_signature *signature, const struct bitcoin_tx *tx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_CLOSINGD_RECEIVED_SIGNATURE);
towire_bitcoin_signature(&p, signature);
towire_bitcoin_tx(&p, tx);
return memcheck(p, tal_count(p));
}
bool fromwire_closingd_received_signature(const tal_t *ctx, const void *p, struct bitcoin_signature *signature, struct bitcoin_tx **tx)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_CLOSINGD_RECEIVED_SIGNATURE)
return false;
fromwire_bitcoin_signature(&cursor, &plen, signature);
*tx = fromwire_bitcoin_tx(ctx, &cursor, &plen);
return cursor != NULL;
}
/* WIRE: CLOSINGD_RECEIVED_SIGNATURE_REPLY */
u8 *towire_closingd_received_signature_reply(const tal_t *ctx, const struct bitcoin_txid *closing_txid)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_CLOSINGD_RECEIVED_SIGNATURE_REPLY);
towire_bitcoin_txid(&p, closing_txid);
return memcheck(p, tal_count(p));
}
bool fromwire_closingd_received_signature_reply(const void *p, struct bitcoin_txid *closing_txid)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_CLOSINGD_RECEIVED_SIGNATURE_REPLY)
return false;
fromwire_bitcoin_txid(&cursor, &plen, closing_txid);
return cursor != NULL;
}
/* WIRE: CLOSINGD_COMPLETE */
/* Negotiations complete */
u8 *towire_closingd_complete(const tal_t *ctx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_CLOSINGD_COMPLETE);
return memcheck(p, tal_count(p));
}
bool fromwire_closingd_complete(const void *p)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_CLOSINGD_COMPLETE)
return false;
return cursor != NULL;
}
// SHA256STAMP:exp-0-b2eb7dca2466d016dd438807ca18e00f21b0dd59cfa74fe2875b3b57ef831d0f

59
closingd/closingd_wiregen.h

@ -0,0 +1,59 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the _csv file it was generated from. */
/* Original template can be found at tools/gen/header_template */
#ifndef LIGHTNING_CLOSINGD_CLOSINGD_WIREGEN_H
#define LIGHTNING_CLOSINGD_CLOSINGD_WIREGEN_H
#include <ccan/tal/tal.h>
#include <wire/tlvstream.h>
#include <wire/wire.h>
#include <bitcoin/tx.h>
#include <common/cryptomsg.h>
#include <common/htlc_wire.h>
#include <common/per_peer_state.h>
enum closingd_wire {
/* Begin! (passes peer fd */
WIRE_CLOSINGD_INIT = 2001,
/* We received an offer */
WIRE_CLOSINGD_RECEIVED_SIGNATURE = 2002,
WIRE_CLOSINGD_RECEIVED_SIGNATURE_REPLY = 2102,
/* Negotiations complete */
WIRE_CLOSINGD_COMPLETE = 2004,
};
const char *closingd_wire_name(int e);
/**
* Determine whether a given message type is defined as a message.
*
* Returns true if the message type is part of the message definitions we have
* generated parsers for, false if it is a custom message that cannot be
* handled internally.
*/
bool closingd_wire_is_defined(u16 type);
/* WIRE: CLOSINGD_INIT */
/* Begin! (passes peer fd */
u8 *towire_closingd_init(const tal_t *ctx, const struct chainparams *chainparams, const struct per_peer_state *pps, const struct bitcoin_txid *funding_txid, u16 funding_txout, struct amount_sat funding_satoshi, const struct pubkey *local_fundingkey, const struct pubkey *remote_fundingkey, enum side opener, struct amount_sat local_sat, struct amount_sat remote_sat, struct amount_sat our_dust_limit, struct amount_sat min_fee_satoshi, struct amount_sat fee_limit_satoshi, struct amount_sat initial_fee_satoshi, const u8 *local_scriptpubkey, const u8 *remote_scriptpubkey, u64 fee_negotiation_step, u8 fee_negotiation_step_unit, bool reconnected, u64 next_index_local, u64 next_index_remote, u64 revocations_received, const u8 *channel_reestablish, const struct secret *last_remote_secret, bool dev_fast_gossip);
bool fromwire_closingd_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct per_peer_state **pps, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct amount_sat *funding_satoshi, struct pubkey *local_fundingkey, struct pubkey *remote_fundingkey, enum side *opener, struct amount_sat *local_sat, struct amount_sat *remote_sat, struct amount_sat *our_dust_limit, struct amount_sat *min_fee_satoshi, struct amount_sat *fee_limit_satoshi, struct amount_sat *initial_fee_satoshi, u8 **local_scriptpubkey, u8 **remote_scriptpubkey, u64 *fee_negotiation_step, u8 *fee_negotiation_step_unit, bool *reconnected, u64 *next_index_local, u64 *next_index_remote, u64 *revocations_received, u8 **channel_reestablish, struct secret *last_remote_secret, bool *dev_fast_gossip);
/* WIRE: CLOSINGD_RECEIVED_SIGNATURE */
/* We received an offer */
u8 *towire_closingd_received_signature(const tal_t *ctx, const struct bitcoin_signature *signature, const struct bitcoin_tx *tx);
bool fromwire_closingd_received_signature(const tal_t *ctx, const void *p, struct bitcoin_signature *signature, struct bitcoin_tx **tx);
/* WIRE: CLOSINGD_RECEIVED_SIGNATURE_REPLY */
u8 *towire_closingd_received_signature_reply(const tal_t *ctx, const struct bitcoin_txid *closing_txid);
bool fromwire_closingd_received_signature_reply(const void *p, struct bitcoin_txid *closing_txid);
/* WIRE: CLOSINGD_COMPLETE */
/* Negotiations complete */
u8 *towire_closingd_complete(const tal_t *ctx);
bool fromwire_closingd_complete(const void *p);
#endif /* LIGHTNING_CLOSINGD_CLOSINGD_WIREGEN_H */
// SHA256STAMP:exp-0-b2eb7dca2466d016dd438807ca18e00f21b0dd59cfa74fe2875b3b57ef831d0f

84
common/peer_status_wiregen.c

@ -0,0 +1,84 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the .csv file it was generated from. */
/* Original template can be found at tools/gen/impl_template */
#include <common/peer_status_wiregen.h>
#include <assert.h>
#include <ccan/array_size/array_size.h>
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/utils.h>
#include <stdio.h>
#ifndef SUPERVERBOSE
#define SUPERVERBOSE(...)
#endif
const char *peer_status_wire_name(int e)
{
static char invalidbuf[sizeof("INVALID ") + STR_MAX_CHARS(e)];
switch ((enum peer_status_wire)e) {
case WIRE_STATUS_PEER_ERROR: return "WIRE_STATUS_PEER_ERROR";
}
snprintf(invalidbuf, sizeof(invalidbuf), "INVALID %i", e);
return invalidbuf;
}
bool peer_status_wire_is_defined(u16 type)
{
switch ((enum peer_status_wire)type) {
case WIRE_STATUS_PEER_ERROR:;
return true;
}
return false;
}
/* WIRE: STATUS_PEER_ERROR */
/* An error occurred: if error_for_them */
u8 *towire_status_peer_error(const tal_t *ctx, const struct channel_id *channel, const wirestring *desc, bool soft_error, const struct per_peer_state *pps, const u8 *error_for_them)
{
u16 len = tal_count(error_for_them);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_STATUS_PEER_ERROR);
/* This is implied if error_for_them */
towire_channel_id(&p, channel);
towire_wirestring(&p, desc);
/* Take a deep breath */
towire_bool(&p, soft_error);
towire_per_peer_state(&p, pps);
towire_u16(&p, len);
towire_u8_array(&p, error_for_them, len);
return memcheck(p, tal_count(p));
}
bool fromwire_status_peer_error(const tal_t *ctx, const void *p, struct channel_id *channel, wirestring **desc, bool *soft_error, struct per_peer_state **pps, u8 **error_for_them)
{
u16 len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_STATUS_PEER_ERROR)
return false;
/* This is implied if error_for_them */
fromwire_channel_id(&cursor, &plen, channel);
*desc = fromwire_wirestring(ctx, &cursor, &plen);
/* Take a deep breath */
*soft_error = fromwire_bool(&cursor, &plen);
*pps = fromwire_per_peer_state(ctx, &cursor, &plen);
len = fromwire_u16(&cursor, &plen);
// 2nd case error_for_them
*error_for_them = len ? tal_arr(ctx, u8, len) : NULL;
fromwire_u8_array(&cursor, &plen, *error_for_them, len);
return cursor != NULL;
}
// SHA256STAMP:exp-0-447e0325cb958a5eab33bc5a220a3cbf671d7a39edb7f9c3065ea04a8545cbd1

38
common/peer_status_wiregen.h

@ -0,0 +1,38 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the _csv file it was generated from. */
/* Original template can be found at tools/gen/header_template */
#ifndef LIGHTNING_COMMON_PEER_STATUS_WIREGEN_H
#define LIGHTNING_COMMON_PEER_STATUS_WIREGEN_H
#include <ccan/tal/tal.h>
#include <wire/tlvstream.h>
#include <wire/wire.h>
#include <common/channel_id.h>
#include <common/per_peer_state.h>
enum peer_status_wire {
/* An error occurred: if error_for_them */
WIRE_STATUS_PEER_ERROR = 0xFFF4,
};
const char *peer_status_wire_name(int e);
/**
* Determine whether a given message type is defined as a message.
*
* Returns true if the message type is part of the message definitions we have
* generated parsers for, false if it is a custom message that cannot be
* handled internally.
*/
bool peer_status_wire_is_defined(u16 type);
/* WIRE: STATUS_PEER_ERROR */
/* An error occurred: if error_for_them */
u8 *towire_status_peer_error(const tal_t *ctx, const struct channel_id *channel, const wirestring *desc, bool soft_error, const struct per_peer_state *pps, const u8 *error_for_them);
bool fromwire_status_peer_error(const tal_t *ctx, const void *p, struct channel_id *channel, wirestring **desc, bool *soft_error, struct per_peer_state **pps, u8 **error_for_them);
#endif /* LIGHTNING_COMMON_PEER_STATUS_WIREGEN_H */
// SHA256STAMP:exp-0-56acee14dc485105152d9cd4d3015fa6d2f7ce1883d49ccece82e068b7f1af13

195
common/status_wiregen.c

@ -0,0 +1,195 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the .csv file it was generated from. */
/* Original template can be found at tools/gen/impl_template */
#include <common/status_wiregen.h>
#include <assert.h>
#include <ccan/array_size/array_size.h>
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/utils.h>
#include <stdio.h>
#ifndef SUPERVERBOSE
#define SUPERVERBOSE(...)
#endif
const char *status_wire_name(int e)
{
static char invalidbuf[sizeof("INVALID ") + STR_MAX_CHARS(e)];
switch ((enum status_wire)e) {
case WIRE_STATUS_LOG: return "WIRE_STATUS_LOG";
case WIRE_STATUS_IO: return "WIRE_STATUS_IO";
case WIRE_STATUS_FAIL: return "WIRE_STATUS_FAIL";
case WIRE_STATUS_PEER_CONNECTION_LOST: return "WIRE_STATUS_PEER_CONNECTION_LOST";
case WIRE_STATUS_PEER_BILLBOARD: return "WIRE_STATUS_PEER_BILLBOARD";
}
snprintf(invalidbuf, sizeof(invalidbuf), "INVALID %i", e);
return invalidbuf;
}
bool status_wire_is_defined(u16 type)
{
switch ((enum status_wire)type) {
case WIRE_STATUS_LOG:;
case WIRE_STATUS_IO:;
case WIRE_STATUS_FAIL:;
case WIRE_STATUS_PEER_CONNECTION_LOST:;
case WIRE_STATUS_PEER_BILLBOARD:;
return true;
}
return false;
}
/* WIRE: STATUS_LOG */
u8 *towire_status_log(const tal_t *ctx, enum log_level level, const struct node_id *peer, const wirestring *entry)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_STATUS_LOG);
towire_log_level(&p, level);
if (!peer)
towire_bool(&p, false);
else {
towire_bool(&p, true);
towire_node_id(&p, peer);
}
towire_wirestring(&p, entry);
return memcheck(p, tal_count(p));
}
bool fromwire_status_log(const tal_t *ctx, const void *p, enum log_level *level, struct node_id **peer, wirestring **entry)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_STATUS_LOG)
return false;
*level = fromwire_log_level(&cursor, &plen);
if (!fromwire_bool(&cursor, &plen))
*peer = NULL;
else {
*peer = tal(ctx, struct node_id);
fromwire_node_id(&cursor, &plen, *peer);
}
*entry = fromwire_wirestring(ctx, &cursor, &plen);
return cursor != NULL;
}
/* WIRE: STATUS_IO */
u8 *towire_status_io(const tal_t *ctx, enum log_level iodir, const struct node_id *peer, const wirestring *who, const u8 *data)
{
u16 len = tal_count(data);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_STATUS_IO);
towire_log_level(&p, iodir);
if (!peer)
towire_bool(&p, false);
else {
towire_bool(&p, true);
towire_node_id(&p, peer);
}
towire_wirestring(&p, who);
towire_u16(&p, len);
towire_u8_array(&p, data, len);
return memcheck(p, tal_count(p));
}
bool fromwire_status_io(const tal_t *ctx, const void *p, enum log_level *iodir, struct node_id **peer, wirestring **who, u8 **data)
{
u16 len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_STATUS_IO)
return false;
*iodir = fromwire_log_level(&cursor, &plen);
if (!fromwire_bool(&cursor, &plen))
*peer = NULL;
else {
*peer = tal(ctx, struct node_id);
fromwire_node_id(&cursor, &plen, *peer);
}
*who = fromwire_wirestring(ctx, &cursor, &plen);
len = fromwire_u16(&cursor, &plen);
// 2nd case data
*data = len ? tal_arr(ctx, u8, len) : NULL;
fromwire_u8_array(&cursor, &plen, *data, len);
return cursor != NULL;
}
/* WIRE: STATUS_FAIL */
u8 *towire_status_fail(const tal_t *ctx, enum status_failreason failreason, const wirestring *desc)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_STATUS_FAIL);
towire_status_failreason(&p, failreason);
towire_wirestring(&p, desc);
return memcheck(p, tal_count(p));
}
bool fromwire_status_fail(const tal_t *ctx, const void *p, enum status_failreason *failreason, wirestring **desc)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_STATUS_FAIL)
return false;
*failreason = fromwire_status_failreason(&cursor, &plen);
*desc = fromwire_wirestring(ctx, &cursor, &plen);
return cursor != NULL;
}
/* WIRE: STATUS_PEER_CONNECTION_LOST */
u8 *towire_status_peer_connection_lost(const tal_t *ctx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_STATUS_PEER_CONNECTION_LOST);
return memcheck(p, tal_count(p));
}
bool fromwire_status_peer_connection_lost(const void *p)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_STATUS_PEER_CONNECTION_LOST)
return false;
return cursor != NULL;
}
/* WIRE: STATUS_PEER_BILLBOARD */
u8 *towire_status_peer_billboard(const tal_t *ctx, bool perm, const wirestring *happenings)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_STATUS_PEER_BILLBOARD);
towire_bool(&p, perm);
towire_wirestring(&p, happenings);
return memcheck(p, tal_count(p));
}
bool fromwire_status_peer_billboard(const tal_t *ctx, const void *p, bool *perm, wirestring **happenings)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_STATUS_PEER_BILLBOARD)
return false;
*perm = fromwire_bool(&cursor, &plen);
*happenings = fromwire_wirestring(ctx, &cursor, &plen);
return cursor != NULL;
}
// SHA256STAMP:exp-0-4d2dbdbf0583d8c35594ef3c14ec80fc1ad4e8d00ee8f1dca0c57293ac41d17e

57
common/status_wiregen.h

@ -0,0 +1,57 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the _csv file it was generated from. */
/* Original template can be found at tools/gen/header_template */
#ifndef LIGHTNING_COMMON_STATUS_WIREGEN_H
#define LIGHTNING_COMMON_STATUS_WIREGEN_H
#include <ccan/tal/tal.h>
#include <wire/tlvstream.h>
#include <wire/wire.h>
#include <common/per_peer_state.h>
#include <common/node_id.h>
#include <common/status_wire.h>
enum status_wire {
WIRE_STATUS_LOG = 0xFFF0,
WIRE_STATUS_IO = 0xFFF1,
WIRE_STATUS_FAIL = 0xFFF2,
WIRE_STATUS_PEER_CONNECTION_LOST = 0xFFF3,
WIRE_STATUS_PEER_BILLBOARD = 0xFFF5,
};
const char *status_wire_name(int e);
/**
* Determine whether a given message type is defined as a message.
*
* Returns true if the message type is part of the message definitions we have
* generated parsers for, false if it is a custom message that cannot be
* handled internally.
*/
bool status_wire_is_defined(u16 type);
/* WIRE: STATUS_LOG */
u8 *towire_status_log(const tal_t *ctx, enum log_level level, const struct node_id *peer, const wirestring *entry);
bool fromwire_status_log(const tal_t *ctx, const void *p, enum log_level *level, struct node_id **peer, wirestring **entry);
/* WIRE: STATUS_IO */
u8 *towire_status_io(const tal_t *ctx, enum log_level iodir, const struct node_id *peer, const wirestring *who, const u8 *data);
bool fromwire_status_io(const tal_t *ctx, const void *p, enum log_level *iodir, struct node_id **peer, wirestring **who, u8 **data);
/* WIRE: STATUS_FAIL */
u8 *towire_status_fail(const tal_t *ctx, enum status_failreason failreason, const wirestring *desc);
bool fromwire_status_fail(const tal_t *ctx, const void *p, enum status_failreason *failreason, wirestring **desc);
/* WIRE: STATUS_PEER_CONNECTION_LOST */
u8 *towire_status_peer_connection_lost(const tal_t *ctx);
bool fromwire_status_peer_connection_lost(const void *p);
/* WIRE: STATUS_PEER_BILLBOARD */
u8 *towire_status_peer_billboard(const tal_t *ctx, bool perm, const wirestring *happenings);
bool fromwire_status_peer_billboard(const tal_t *ctx, const void *p, bool *perm, wirestring **happenings);
#endif /* LIGHTNING_COMMON_STATUS_WIREGEN_H */
// SHA256STAMP:exp-0-6b371939fcb8fc39758a17167e1b95bae1ac2cf61f207e530711aeba6838eb4f

165
connectd/connectd_gossipd_wiregen.c

@ -0,0 +1,165 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the .csv file it was generated from. */
/* Original template can be found at tools/gen/impl_template */
#include <connectd/connectd_gossipd_wiregen.h>
#include <assert.h>
#include <ccan/array_size/array_size.h>
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/utils.h>
#include <stdio.h>
#ifndef SUPERVERBOSE
#define SUPERVERBOSE(...)
#endif
const char *connectd_gossipd_wire_name(int e)
{
static char invalidbuf[sizeof("INVALID ") + STR_MAX_CHARS(e)];
switch ((enum connectd_gossipd_wire)e) {
case WIRE_GOSSIPD_NEW_PEER: return "WIRE_GOSSIPD_NEW_PEER";
case WIRE_GOSSIPD_NEW_PEER_REPLY: return "WIRE_GOSSIPD_NEW_PEER_REPLY";
case WIRE_GOSSIPD_GET_ADDRS: return "WIRE_GOSSIPD_GET_ADDRS";
case WIRE_GOSSIPD_GET_ADDRS_REPLY: return "WIRE_GOSSIPD_GET_ADDRS_REPLY";
}
snprintf(invalidbuf, sizeof(invalidbuf), "INVALID %i", e);
return invalidbuf;
}
bool connectd_gossipd_wire_is_defined(u16 type)
{
switch ((enum connectd_gossipd_wire)type) {
case WIRE_GOSSIPD_NEW_PEER:;
case WIRE_GOSSIPD_NEW_PEER_REPLY:;
case WIRE_GOSSIPD_GET_ADDRS:;
case WIRE_GOSSIPD_GET_ADDRS_REPLY:;
return true;
}
return false;
}
/* WIRE: GOSSIPD_NEW_PEER */
/* Communication between gossipd and connectd. */
u8 *towire_gossipd_new_peer(const tal_t *ctx, const struct node_id *id, bool gossip_queries_feature, bool initial_routing_sync)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_NEW_PEER);
towire_node_id(&p, id);
/* Did we negotiate LOCAL_GOSSIP_QUERIES? */
towire_bool(&p, gossip_queries_feature);
/* Did they offer LOCAL_INITIAL_ROUTING_SYNC? */
towire_bool(&p, initial_routing_sync);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_new_peer(const void *p, struct node_id *id, bool *gossip_queries_feature, bool *initial_routing_sync)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_NEW_PEER)
return false;
fromwire_node_id(&cursor, &plen, id);
/* Did we negotiate LOCAL_GOSSIP_QUERIES? */
*gossip_queries_feature = fromwire_bool(&cursor, &plen);
/* Did they offer LOCAL_INITIAL_ROUTING_SYNC? */
*initial_routing_sync = fromwire_bool(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: GOSSIPD_NEW_PEER_REPLY */
/* if success: + gossip fd and gossip_store fd */
u8 *towire_gossipd_new_peer_reply(const tal_t *ctx, bool success, const struct gossip_state *gs)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_NEW_PEER_REPLY);
towire_bool(&p, success);
if (!gs)
towire_bool(&p, false);
else {
towire_bool(&p, true);
towire_gossip_state(&p, gs);
}
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_new_peer_reply(const tal_t *ctx, const void *p, bool *success, struct gossip_state **gs)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_NEW_PEER_REPLY)
return false;
*success = fromwire_bool(&cursor, &plen);
if (!fromwire_bool(&cursor, &plen))
*gs = NULL;
else {
*gs = tal(ctx, struct gossip_state);
fromwire_gossip_state(&cursor, &plen, *gs);
}
return cursor != NULL;
}
/* WIRE: GOSSIPD_GET_ADDRS */
/* Connectd asks gossipd for any known addresses for that node. */
u8 *towire_gossipd_get_addrs(const tal_t *ctx, const struct node_id *id)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_GET_ADDRS);
towire_node_id(&p, id);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_get_addrs(const void *p, struct node_id *id)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_GET_ADDRS)
return false;
fromwire_node_id(&cursor, &plen, id);
return cursor != NULL;
}
/* WIRE: GOSSIPD_GET_ADDRS_REPLY */
u8 *towire_gossipd_get_addrs_reply(const tal_t *ctx, const struct wireaddr *addrs)
{
u16 num = tal_count(addrs);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_GET_ADDRS_REPLY);
towire_u16(&p, num);
for (size_t i = 0; i < num; i++)
towire_wireaddr(&p, addrs + i);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_get_addrs_reply(const tal_t *ctx, const void *p, struct wireaddr **addrs)
{
u16 num;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_GET_ADDRS_REPLY)
return false;
num = fromwire_u16(&cursor, &plen);
// 2nd case addrs
*addrs = num ? tal_arr(ctx, struct wireaddr, num) : NULL;
for (size_t i = 0; i < num; i++)
fromwire_wireaddr(&cursor, &plen, *addrs + i);
return cursor != NULL;
}
// SHA256STAMP:exp-0-bd0f96afda71fed3790c8a0a1596bafff24b5b7b648d68e7c31d5e44970cda47

58
connectd/connectd_gossipd_wiregen.h

@ -0,0 +1,58 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the _csv file it was generated from. */
/* Original template can be found at tools/gen/header_template */
#ifndef LIGHTNING_CONNECTD_CONNECTD_GOSSIPD_WIREGEN_H
#define LIGHTNING_CONNECTD_CONNECTD_GOSSIPD_WIREGEN_H
#include <ccan/tal/tal.h>
#include <wire/tlvstream.h>
#include <wire/wire.h>
#include <common/node_id.h>
#include <common/per_peer_state.h>
#include <common/wireaddr.h>
enum connectd_gossipd_wire {
/* Communication between gossipd and connectd. */
WIRE_GOSSIPD_NEW_PEER = 4000,
/* if success: + gossip fd and gossip_store fd */
WIRE_GOSSIPD_NEW_PEER_REPLY = 4100,
/* Connectd asks gossipd for any known addresses for that node. */
WIRE_GOSSIPD_GET_ADDRS = 4001,
WIRE_GOSSIPD_GET_ADDRS_REPLY = 4101,
};
const char *connectd_gossipd_wire_name(int e);
/**
* Determine whether a given message type is defined as a message.
*
* Returns true if the message type is part of the message definitions we have
* generated parsers for, false if it is a custom message that cannot be
* handled internally.
*/
bool connectd_gossipd_wire_is_defined(u16 type);
/* WIRE: GOSSIPD_NEW_PEER */
/* Communication between gossipd and connectd. */
u8 *towire_gossipd_new_peer(const tal_t *ctx, const struct node_id *id, bool gossip_queries_feature, bool initial_routing_sync);
bool fromwire_gossipd_new_peer(const void *p, struct node_id *id, bool *gossip_queries_feature, bool *initial_routing_sync);
/* WIRE: GOSSIPD_NEW_PEER_REPLY */
/* if success: + gossip fd and gossip_store fd */
u8 *towire_gossipd_new_peer_reply(const tal_t *ctx, bool success, const struct gossip_state *gs);
bool fromwire_gossipd_new_peer_reply(const tal_t *ctx, const void *p, bool *success, struct gossip_state **gs);
/* WIRE: GOSSIPD_GET_ADDRS */
/* Connectd asks gossipd for any known addresses for that node. */
u8 *towire_gossipd_get_addrs(const tal_t *ctx, const struct node_id *id);
bool fromwire_gossipd_get_addrs(const void *p, struct node_id *id);
/* WIRE: GOSSIPD_GET_ADDRS_REPLY */
u8 *towire_gossipd_get_addrs_reply(const tal_t *ctx, const struct wireaddr *addrs);
bool fromwire_gossipd_get_addrs_reply(const tal_t *ctx, const void *p, struct wireaddr **addrs);
#endif /* LIGHTNING_CONNECTD_CONNECTD_GOSSIPD_WIREGEN_H */
// SHA256STAMP:exp-0-bd0f96afda71fed3790c8a0a1596bafff24b5b7b648d68e7c31d5e44970cda47

408
connectd/connectd_wiregen.c

@ -0,0 +1,408 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the .csv file it was generated from. */
/* Original template can be found at tools/gen/impl_template */
#include <connectd/connectd_wiregen.h>
#include <assert.h>
#include <ccan/array_size/array_size.h>
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/utils.h>
#include <stdio.h>
#ifndef SUPERVERBOSE
#define SUPERVERBOSE(...)
#endif
const char *connectd_wire_name(int e)
{
static char invalidbuf[sizeof("INVALID ") + STR_MAX_CHARS(e)];
switch ((enum connectd_wire)e) {
case WIRE_CONNECTD_INIT: return "WIRE_CONNECTD_INIT";
case WIRE_CONNECTD_INIT_REPLY: return "WIRE_CONNECTD_INIT_REPLY";
case WIRE_CONNECTD_ACTIVATE: return "WIRE_CONNECTD_ACTIVATE";
case WIRE_CONNECTD_ACTIVATE_REPLY: return "WIRE_CONNECTD_ACTIVATE_REPLY";
case WIRE_CONNECTD_RECONNECTED: return "WIRE_CONNECTD_RECONNECTED";
case WIRE_CONNECTD_CONNECT_TO_PEER: return "WIRE_CONNECTD_CONNECT_TO_PEER";
case WIRE_CONNECTD_CONNECT_FAILED: return "WIRE_CONNECTD_CONNECT_FAILED";
case WIRE_CONNECTD_PEER_CONNECTED: return "WIRE_CONNECTD_PEER_CONNECTED";
case WIRE_CONNECTD_PEER_DISCONNECTED: return "WIRE_CONNECTD_PEER_DISCONNECTED";
case WIRE_CONNECTD_DEV_MEMLEAK: return "WIRE_CONNECTD_DEV_MEMLEAK";
case WIRE_CONNECTD_DEV_MEMLEAK_REPLY: return "WIRE_CONNECTD_DEV_MEMLEAK_REPLY";
}
snprintf(invalidbuf, sizeof(invalidbuf), "INVALID %i", e);
return invalidbuf;
}
bool connectd_wire_is_defined(u16 type)
{
switch ((enum connectd_wire)type) {
case WIRE_CONNECTD_INIT:;
case WIRE_CONNECTD_INIT_REPLY:;
case WIRE_CONNECTD_ACTIVATE:;
case WIRE_CONNECTD_ACTIVATE_REPLY:;
case WIRE_CONNECTD_RECONNECTED:;
case WIRE_CONNECTD_CONNECT_TO_PEER:;
case WIRE_CONNECTD_CONNECT_FAILED:;
case WIRE_CONNECTD_PEER_CONNECTED:;
case WIRE_CONNECTD_PEER_DISCONNECTED:;
case WIRE_CONNECTD_DEV_MEMLEAK:;
case WIRE_CONNECTD_DEV_MEMLEAK_REPLY:;
return true;
}
return false;
}
/* WIRE: CONNECTD_INIT */
u8 *towire_connectd_init(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_features, const struct node_id *id, const struct wireaddr_internal *wireaddrs, const enum addr_listen_announce *listen_announce, const struct wireaddr *tor_proxyaddr, bool use_tor_proxy_always, bool dev_allow_localhost, bool use_dns, const wirestring *tor_password, bool use_v3_autotor)
{
u16 num_wireaddrs = tal_count(listen_announce);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_CONNECTD_INIT);
towire_chainparams(&p, chainparams);
towire_feature_set(&p, our_features);
towire_node_id(&p, id);
towire_u16(&p, num_wireaddrs);
for (size_t i = 0; i < num_wireaddrs; i++)
towire_wireaddr_internal(&p, wireaddrs + i);
for (size_t i = 0; i < num_wireaddrs; i++)
towire_addr_listen_announce(&p, listen_announce[i]);
if (!tor_proxyaddr)
towire_bool(&p, false);
else {
towire_bool(&p, true);
towire_wireaddr(&p, tor_proxyaddr);
}
towire_bool(&p, use_tor_proxy_always);
towire_bool(&p, dev_allow_localhost);
towire_bool(&p, use_dns);
towire_wirestring(&p, tor_password);
towire_bool(&p, use_v3_autotor);
return memcheck(p, tal_count(p));
}
bool fromwire_connectd_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_features, struct node_id *id, struct wireaddr_internal **wireaddrs, enum addr_listen_announce **listen_announce, struct wireaddr **tor_proxyaddr, bool *use_tor_proxy_always, bool *dev_allow_localhost, bool *use_dns, wirestring **tor_password, bool *use_v3_autotor)
{
u16 num_wireaddrs;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_CONNECTD_INIT)
return false;
fromwire_chainparams(&cursor, &plen, chainparams);
*our_features = fromwire_feature_set(ctx, &cursor, &plen);
fromwire_node_id(&cursor, &plen, id);
num_wireaddrs = fromwire_u16(&cursor, &plen);
// 2nd case wireaddrs
*wireaddrs = num_wireaddrs ? tal_arr(ctx, struct wireaddr_internal, num_wireaddrs) : NULL;
for (size_t i = 0; i < num_wireaddrs; i++)
fromwire_wireaddr_internal(&cursor, &plen, *wireaddrs + i);
// 2nd case listen_announce
*listen_announce = num_wireaddrs ? tal_arr(ctx, enum addr_listen_announce, num_wireaddrs) : NULL;
for (size_t i = 0; i < num_wireaddrs; i++)
(*listen_announce)[i] = fromwire_addr_listen_announce(&cursor, &plen);
if (!fromwire_bool(&cursor, &plen))
*tor_proxyaddr = NULL;
else {
*tor_proxyaddr = tal(ctx, struct wireaddr);
fromwire_wireaddr(&cursor, &plen, *tor_proxyaddr);
}
*use_tor_proxy_always = fromwire_bool(&cursor, &plen);
*dev_allow_localhost = fromwire_bool(&cursor, &plen);
*use_dns = fromwire_bool(&cursor, &plen);
*tor_password = fromwire_wirestring(ctx, &cursor, &plen);
*use_v3_autotor = fromwire_bool(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: CONNECTD_INIT_REPLY */
/* Connectd->master */
u8 *towire_connectd_init_reply(const tal_t *ctx, const struct wireaddr_internal *bindings, const struct wireaddr *announcable)
{
u16 num_bindings = tal_count(bindings);
u16 num_announcable = tal_count(announcable);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_CONNECTD_INIT_REPLY);
towire_u16(&p, num_bindings);
for (size_t i = 0; i < num_bindings; i++)
towire_wireaddr_internal(&p, bindings + i);
towire_u16(&p, num_announcable);
for (size_t i = 0; i < num_announcable; i++)
towire_wireaddr(&p, announcable + i);
return memcheck(p, tal_count(p));
}
bool fromwire_connectd_init_reply(const tal_t *ctx, const void *p, struct wireaddr_internal **bindings, struct wireaddr **announcable)
{
u16 num_bindings;
u16 num_announcable;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_CONNECTD_INIT_REPLY)
return false;
num_bindings = fromwire_u16(&cursor, &plen);
// 2nd case bindings
*bindings = num_bindings ? tal_arr(ctx, struct wireaddr_internal, num_bindings) : NULL;
for (size_t i = 0; i < num_bindings; i++)
fromwire_wireaddr_internal(&cursor, &plen, *bindings + i);
num_announcable = fromwire_u16(&cursor, &plen);
// 2nd case announcable
*announcable = num_announcable ? tal_arr(ctx, struct wireaddr, num_announcable) : NULL;
for (size_t i = 0; i < num_announcable; i++)
fromwire_wireaddr(&cursor, &plen, *announcable + i);
return cursor != NULL;
}
/* WIRE: CONNECTD_ACTIVATE */
/* Activate the connect daemon */
u8 *towire_connectd_activate(const tal_t *ctx, bool listen)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_CONNECTD_ACTIVATE);
/* Do we listen? */
towire_bool(&p, listen);
return memcheck(p, tal_count(p));
}
bool fromwire_connectd_activate(const void *p, bool *listen)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_CONNECTD_ACTIVATE)
return false;
/* Do we listen? */
*listen = fromwire_bool(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: CONNECTD_ACTIVATE_REPLY */
/* Connectd->master */
u8 *towire_connectd_activate_reply(const tal_t *ctx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_CONNECTD_ACTIVATE_REPLY);
return memcheck(p, tal_count(p));
}
bool fromwire_connectd_activate_reply(const void *p)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_CONNECTD_ACTIVATE_REPLY)
return false;
return cursor != NULL;
}
/* WIRE: CONNECTD_RECONNECTED */
/* connectd->master: disconnect this peer please (due to reconnect). */
u8 *towire_connectd_reconnected(const tal_t *ctx, const struct node_id *id)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_CONNECTD_RECONNECTED);
towire_node_id(&p, id);
return memcheck(p, tal_count(p));
}
bool fromwire_connectd_reconnected(const void *p, struct node_id *id)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_CONNECTD_RECONNECTED)
return false;
fromwire_node_id(&cursor, &plen, id);
return cursor != NULL;
}
/* WIRE: CONNECTD_CONNECT_TO_PEER */
/* Master -> connectd: connect to a peer. */
u8 *towire_connectd_connect_to_peer(const tal_t *ctx, const struct node_id *id, u32 seconds_waited, const struct wireaddr_internal *addrhint)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_CONNECTD_CONNECT_TO_PEER);
towire_node_id(&p, id);
towire_u32(&p, seconds_waited);
if (!addrhint)
towire_bool(&p, false);
else {
towire_bool(&p, true);
towire_wireaddr_internal(&p, addrhint);
}
return memcheck(p, tal_count(p));
}
bool fromwire_connectd_connect_to_peer(const tal_t *ctx, const void *p, struct node_id *id, u32 *seconds_waited, struct wireaddr_internal **addrhint)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_CONNECTD_CONNECT_TO_PEER)
return false;
fromwire_node_id(&cursor, &plen, id);
*seconds_waited = fromwire_u32(&cursor, &plen);
if (!fromwire_bool(&cursor, &plen))
*addrhint = NULL;
else {
*addrhint = tal(ctx, struct wireaddr_internal);
fromwire_wireaddr_internal(&cursor, &plen, *addrhint);
}
return cursor != NULL;
}
/* WIRE: CONNECTD_CONNECT_FAILED */
/* Connectd->master: connect failed. */
u8 *towire_connectd_connect_failed(const tal_t *ctx, const struct node_id *id, errcode_t failcode, const wirestring *failreason, u32 seconds_to_delay, const struct wireaddr_internal *addrhint)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_CONNECTD_CONNECT_FAILED);
towire_node_id(&p, id);
towire_errcode_t(&p, failcode);
towire_wirestring(&p, failreason);
towire_u32(&p, seconds_to_delay);
if (!addrhint)
towire_bool(&p, false);
else {
towire_bool(&p, true);
towire_wireaddr_internal(&p, addrhint);
}
return memcheck(p, tal_count(p));
}
bool fromwire_connectd_connect_failed(const tal_t *ctx, const void *p, struct node_id *id, errcode_t *failcode, wirestring **failreason, u32 *seconds_to_delay, struct wireaddr_internal **addrhint)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_CONNECTD_CONNECT_FAILED)
return false;
fromwire_node_id(&cursor, &plen, id);
*failcode = fromwire_errcode_t(&cursor, &plen);
*failreason = fromwire_wirestring(ctx, &cursor, &plen);
*seconds_to_delay = fromwire_u32(&cursor, &plen);
if (!fromwire_bool(&cursor, &plen))
*addrhint = NULL;
else {
*addrhint = tal(ctx, struct wireaddr_internal);
fromwire_wireaddr_internal(&cursor, &plen, *addrhint);
}
return cursor != NULL;
}
/* WIRE: CONNECTD_PEER_CONNECTED */
/* Connectd -> master: we got a peer. Three fds: peer */
u8 *towire_connectd_peer_connected(const tal_t *ctx, const struct node_id *id, const struct wireaddr_internal *addr, const struct per_peer_state *pps, const u8 *features)
{
u16 flen = tal_count(features);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_CONNECTD_PEER_CONNECTED);
towire_node_id(&p, id);
towire_wireaddr_internal(&p, addr);
towire_per_peer_state(&p, pps);
towire_u16(&p, flen);
towire_u8_array(&p, features, flen);
return memcheck(p, tal_count(p));
}
bool fromwire_connectd_peer_connected(const tal_t *ctx, const void *p, struct node_id *id, struct wireaddr_internal *addr, struct per_peer_state **pps, u8 **features)
{
u16 flen;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_CONNECTD_PEER_CONNECTED)
return false;
fromwire_node_id(&cursor, &plen, id);
fromwire_wireaddr_internal(&cursor, &plen, addr);
*pps = fromwire_per_peer_state(ctx, &cursor, &plen);
flen = fromwire_u16(&cursor, &plen);
// 2nd case features
*features = flen ? tal_arr(ctx, u8, flen) : NULL;
fromwire_u8_array(&cursor, &plen, *features, flen);
return cursor != NULL;
}
/* WIRE: CONNECTD_PEER_DISCONNECTED */
/* master -> connectd: peer has disconnected. */
u8 *towire_connectd_peer_disconnected(const tal_t *ctx, const struct node_id *id)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_CONNECTD_PEER_DISCONNECTED);
towire_node_id(&p, id);
return memcheck(p, tal_count(p));
}
bool fromwire_connectd_peer_disconnected(const void *p, struct node_id *id)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_CONNECTD_PEER_DISCONNECTED)
return false;
fromwire_node_id(&cursor, &plen, id);
return cursor != NULL;
}
/* WIRE: CONNECTD_DEV_MEMLEAK */
/* master -> connectd: do you have a memleak? */
u8 *towire_connectd_dev_memleak(const tal_t *ctx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_CONNECTD_DEV_MEMLEAK);
return memcheck(p, tal_count(p));
}
bool fromwire_connectd_dev_memleak(const void *p)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_CONNECTD_DEV_MEMLEAK)
return false;
return cursor != NULL;
}
/* WIRE: CONNECTD_DEV_MEMLEAK_REPLY */
u8 *towire_connectd_dev_memleak_reply(const tal_t *ctx, bool leak)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_CONNECTD_DEV_MEMLEAK_REPLY);
towire_bool(&p, leak);
return memcheck(p, tal_count(p));
}
bool fromwire_connectd_dev_memleak_reply(const void *p, bool *leak)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_CONNECTD_DEV_MEMLEAK_REPLY)
return false;
*leak = fromwire_bool(&cursor, &plen);
return cursor != NULL;
}
// SHA256STAMP:exp-0-ccc7cf60dccc364d13a7516e726d17d3f90664d91d4fc845ac77c23d4af298f5

107
connectd/connectd_wiregen.h

@ -0,0 +1,107 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the _csv file it was generated from. */
/* Original template can be found at tools/gen/header_template */
#ifndef LIGHTNING_CONNECTD_CONNECTD_WIREGEN_H
#define LIGHTNING_CONNECTD_CONNECTD_WIREGEN_H
#include <ccan/tal/tal.h>
#include <wire/tlvstream.h>
#include <wire/wire.h>
#include <common/cryptomsg.h>
#include <common/features.h>
#include <common/per_peer_state.h>
#include <common/wireaddr.h>
#include <lightningd/gossip_msg.h>
enum connectd_wire {
WIRE_CONNECTD_INIT = 2000,
/* Connectd->master */
WIRE_CONNECTD_INIT_REPLY = 2100,
/* Activate the connect daemon */
WIRE_CONNECTD_ACTIVATE = 2025,
/* Connectd->master */
WIRE_CONNECTD_ACTIVATE_REPLY = 2125,
/* connectd->master: disconnect this peer please (due to reconnect). */
WIRE_CONNECTD_RECONNECTED = 2112,
/* Master -> connectd: connect to a peer. */
WIRE_CONNECTD_CONNECT_TO_PEER = 2001,
/* Connectd->master: connect failed. */
WIRE_CONNECTD_CONNECT_FAILED = 2020,
/* Connectd -> master: we got a peer. Three fds: peer */
WIRE_CONNECTD_PEER_CONNECTED = 2002,
/* master -> connectd: peer has disconnected. */
WIRE_CONNECTD_PEER_DISCONNECTED = 2015,
/* master -> connectd: do you have a memleak? */
WIRE_CONNECTD_DEV_MEMLEAK = 2033,
WIRE_CONNECTD_DEV_MEMLEAK_REPLY = 2133,
};
const char *connectd_wire_name(int e);
/**
* Determine whether a given message type is defined as a message.
*
* Returns true if the message type is part of the message definitions we have
* generated parsers for, false if it is a custom message that cannot be
* handled internally.
*/
bool connectd_wire_is_defined(u16 type);
/* WIRE: CONNECTD_INIT */
u8 *towire_connectd_init(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_features, const struct node_id *id, const struct wireaddr_internal *wireaddrs, const enum addr_listen_announce *listen_announce, const struct wireaddr *tor_proxyaddr, bool use_tor_proxy_always, bool dev_allow_localhost, bool use_dns, const wirestring *tor_password, bool use_v3_autotor);
bool fromwire_connectd_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_features, struct node_id *id, struct wireaddr_internal **wireaddrs, enum addr_listen_announce **listen_announce, struct wireaddr **tor_proxyaddr, bool *use_tor_proxy_always, bool *dev_allow_localhost, bool *use_dns, wirestring **tor_password, bool *use_v3_autotor);
/* WIRE: CONNECTD_INIT_REPLY */
/* Connectd->master */
u8 *towire_connectd_init_reply(const tal_t *ctx, const struct wireaddr_internal *bindings, const struct wireaddr *announcable);
bool fromwire_connectd_init_reply(const tal_t *ctx, const void *p, struct wireaddr_internal **bindings, struct wireaddr **announcable);
/* WIRE: CONNECTD_ACTIVATE */
/* Activate the connect daemon */
u8 *towire_connectd_activate(const tal_t *ctx, bool listen);
bool fromwire_connectd_activate(const void *p, bool *listen);
/* WIRE: CONNECTD_ACTIVATE_REPLY */
/* Connectd->master */
u8 *towire_connectd_activate_reply(const tal_t *ctx);
bool fromwire_connectd_activate_reply(const void *p);
/* WIRE: CONNECTD_RECONNECTED */
/* connectd->master: disconnect this peer please (due to reconnect). */
u8 *towire_connectd_reconnected(const tal_t *ctx, const struct node_id *id);
bool fromwire_connectd_reconnected(const void *p, struct node_id *id);
/* WIRE: CONNECTD_CONNECT_TO_PEER */
/* Master -> connectd: connect to a peer. */
u8 *towire_connectd_connect_to_peer(const tal_t *ctx, const struct node_id *id, u32 seconds_waited, const struct wireaddr_internal *addrhint);
bool fromwire_connectd_connect_to_peer(const tal_t *ctx, const void *p, struct node_id *id, u32 *seconds_waited, struct wireaddr_internal **addrhint);
/* WIRE: CONNECTD_CONNECT_FAILED */
/* Connectd->master: connect failed. */
u8 *towire_connectd_connect_failed(const tal_t *ctx, const struct node_id *id, errcode_t failcode, const wirestring *failreason, u32 seconds_to_delay, const struct wireaddr_internal *addrhint);
bool fromwire_connectd_connect_failed(const tal_t *ctx, const void *p, struct node_id *id, errcode_t *failcode, wirestring **failreason, u32 *seconds_to_delay, struct wireaddr_internal **addrhint);
/* WIRE: CONNECTD_PEER_CONNECTED */
/* Connectd -> master: we got a peer. Three fds: peer */
u8 *towire_connectd_peer_connected(const tal_t *ctx, const struct node_id *id, const struct wireaddr_internal *addr, const struct per_peer_state *pps, const u8 *features);
bool fromwire_connectd_peer_connected(const tal_t *ctx, const void *p, struct node_id *id, struct wireaddr_internal *addr, struct per_peer_state **pps, u8 **features);
/* WIRE: CONNECTD_PEER_DISCONNECTED */
/* master -> connectd: peer has disconnected. */
u8 *towire_connectd_peer_disconnected(const tal_t *ctx, const struct node_id *id);
bool fromwire_connectd_peer_disconnected(const void *p, struct node_id *id);
/* WIRE: CONNECTD_DEV_MEMLEAK */
/* master -> connectd: do you have a memleak? */
u8 *towire_connectd_dev_memleak(const tal_t *ctx);
bool fromwire_connectd_dev_memleak(const void *p);
/* WIRE: CONNECTD_DEV_MEMLEAK_REPLY */
u8 *towire_connectd_dev_memleak_reply(const tal_t *ctx, bool leak);
bool fromwire_connectd_dev_memleak_reply(const void *p, bool *leak);
#endif /* LIGHTNING_CONNECTD_CONNECTD_WIREGEN_H */
// SHA256STAMP:exp-0-ccc7cf60dccc364d13a7516e726d17d3f90664d91d4fc845ac77c23d4af298f5

121
gossipd/gossip_store_wiregen.c

@ -0,0 +1,121 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the .csv file it was generated from. */
/* Original template can be found at tools/gen/impl_template */
#include <gossipd/gossip_store_wiregen.h>
#include <assert.h>
#include <ccan/array_size/array_size.h>
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/utils.h>
#include <stdio.h>
#ifndef SUPERVERBOSE
#define SUPERVERBOSE(...)
#endif
/* gossip_store messages: messages persisted in the gossip_store */
/* We store raw messages here */
/* 256/257/258 or gossipd_local_add_channel (3503) */
const char *gossip_store_wire_name(int e)
{
static char invalidbuf[sizeof("INVALID ") + STR_MAX_CHARS(e)];
switch ((enum gossip_store_wire)e) {
case WIRE_GOSSIP_STORE_CHANNEL_AMOUNT: return "WIRE_GOSSIP_STORE_CHANNEL_AMOUNT";
case WIRE_GOSSIP_STORE_PRIVATE_UPDATE: return "WIRE_GOSSIP_STORE_PRIVATE_UPDATE";
case WIRE_GOSSIP_STORE_DELETE_CHAN: return "WIRE_GOSSIP_STORE_DELETE_CHAN";
}
snprintf(invalidbuf, sizeof(invalidbuf), "INVALID %i", e);
return invalidbuf;
}
bool gossip_store_wire_is_defined(u16 type)
{
switch ((enum gossip_store_wire)type) {
case WIRE_GOSSIP_STORE_CHANNEL_AMOUNT:;
case WIRE_GOSSIP_STORE_PRIVATE_UPDATE:;
case WIRE_GOSSIP_STORE_DELETE_CHAN:;
return true;
}
return false;
}
/* WIRE: GOSSIP_STORE_CHANNEL_AMOUNT */
/* This always follows the channel_announce. */
u8 *towire_gossip_store_channel_amount(const tal_t *ctx, struct amount_sat satoshis)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIP_STORE_CHANNEL_AMOUNT);
towire_amount_sat(&p, satoshis);
return memcheck(p, tal_count(p));
}
bool fromwire_gossip_store_channel_amount(const void *p, struct amount_sat *satoshis)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIP_STORE_CHANNEL_AMOUNT)
return false;
*satoshis = fromwire_amount_sat(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: GOSSIP_STORE_PRIVATE_UPDATE */
u8 *towire_gossip_store_private_update(const tal_t *ctx, const u8 *update)
{
u16 len = tal_count(update);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIP_STORE_PRIVATE_UPDATE);
towire_u16(&p, len);
towire_u8_array(&p, update, len);
return memcheck(p, tal_count(p));
}
bool fromwire_gossip_store_private_update(const tal_t *ctx, const void *p, u8 **update)
{
u16 len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIP_STORE_PRIVATE_UPDATE)
return false;
len = fromwire_u16(&cursor, &plen);
// 2nd case update
*update = len ? tal_arr(ctx, u8, len) : NULL;
fromwire_u8_array(&cursor, &plen, *update, len);
return cursor != NULL;
}
/* WIRE: GOSSIP_STORE_DELETE_CHAN */
u8 *towire_gossip_store_delete_chan(const tal_t *ctx, const struct short_channel_id *scid)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIP_STORE_DELETE_CHAN);
towire_short_channel_id(&p, scid);
return memcheck(p, tal_count(p));
}
bool fromwire_gossip_store_delete_chan(const void *p, struct short_channel_id *scid)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIP_STORE_DELETE_CHAN)
return false;
fromwire_short_channel_id(&cursor, &plen, scid);
return cursor != NULL;
}
// SHA256STAMP:exp-0-184dda49fa00adc7b82ffc843580a139d17d915c890228fc1a2a8a4383e016ae

47
gossipd/gossip_store_wiregen.h

@ -0,0 +1,47 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the _csv file it was generated from. */
/* Original template can be found at tools/gen/header_template */
#ifndef LIGHTNING_GOSSIPD_GOSSIP_STORE_WIREGEN_H
#define LIGHTNING_GOSSIPD_GOSSIP_STORE_WIREGEN_H
#include <ccan/tal/tal.h>
#include <wire/tlvstream.h>
#include <wire/wire.h>
#include <common/amount.h>
enum gossip_store_wire {
/* This always follows the channel_announce. */
WIRE_GOSSIP_STORE_CHANNEL_AMOUNT = 4101,
WIRE_GOSSIP_STORE_PRIVATE_UPDATE = 4102,
WIRE_GOSSIP_STORE_DELETE_CHAN = 4103,
};
const char *gossip_store_wire_name(int e);
/**
* Determine whether a given message type is defined as a message.
*
* Returns true if the message type is part of the message definitions we have
* generated parsers for, false if it is a custom message that cannot be
* handled internally.
*/
bool gossip_store_wire_is_defined(u16 type);
/* WIRE: GOSSIP_STORE_CHANNEL_AMOUNT */
/* This always follows the channel_announce. */
u8 *towire_gossip_store_channel_amount(const tal_t *ctx, struct amount_sat satoshis);
bool fromwire_gossip_store_channel_amount(const void *p, struct amount_sat *satoshis);
/* WIRE: GOSSIP_STORE_PRIVATE_UPDATE */
u8 *towire_gossip_store_private_update(const tal_t *ctx, const u8 *update);
bool fromwire_gossip_store_private_update(const tal_t *ctx, const void *p, u8 **update);
/* WIRE: GOSSIP_STORE_DELETE_CHAN */
u8 *towire_gossip_store_delete_chan(const tal_t *ctx, const struct short_channel_id *scid);
bool fromwire_gossip_store_delete_chan(const void *p, struct short_channel_id *scid);
#endif /* LIGHTNING_GOSSIPD_GOSSIP_STORE_WIREGEN_H */
// SHA256STAMP:exp-0-184dda49fa00adc7b82ffc843580a139d17d915c890228fc1a2a8a4383e016ae

230
gossipd/gossipd_peerd_wiregen.c

@ -0,0 +1,230 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the .csv file it was generated from. */
/* Original template can be found at tools/gen/impl_template */
#include <gossipd/gossipd_peerd_wiregen.h>
#include <assert.h>
#include <ccan/array_size/array_size.h>
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/utils.h>
#include <stdio.h>
#ifndef SUPERVERBOSE
#define SUPERVERBOSE(...)
#endif
/* These must be distinct from WIRE_CHANNEL_ANNOUNCEMENT etc. gossip msgs! */
const char *gossipd_peerd_wire_name(int e)
{
static char invalidbuf[sizeof("INVALID ") + STR_MAX_CHARS(e)];
switch ((enum gossipd_peerd_wire)e) {
case WIRE_GOSSIPD_GET_UPDATE: return "WIRE_GOSSIPD_GET_UPDATE";
case WIRE_GOSSIPD_GET_UPDATE_REPLY: return "WIRE_GOSSIPD_GET_UPDATE_REPLY";
case WIRE_GOSSIPD_LOCAL_ADD_CHANNEL: return "WIRE_GOSSIPD_LOCAL_ADD_CHANNEL";
case WIRE_GOSSIPD_LOCAL_CHANNEL_UPDATE: return "WIRE_GOSSIPD_LOCAL_CHANNEL_UPDATE";
case WIRE_GOSSIPD_NEW_STORE_FD: return "WIRE_GOSSIPD_NEW_STORE_FD";
case WIRE_GOSSIPD_LOCAL_CHANNEL_ANNOUNCEMENT: return "WIRE_GOSSIPD_LOCAL_CHANNEL_ANNOUNCEMENT";
}
snprintf(invalidbuf, sizeof(invalidbuf), "INVALID %i", e);
return invalidbuf;
}
bool gossipd_peerd_wire_is_defined(u16 type)
{
switch ((enum gossipd_peerd_wire)type) {
case WIRE_GOSSIPD_GET_UPDATE:;
case WIRE_GOSSIPD_GET_UPDATE_REPLY:;
case WIRE_GOSSIPD_LOCAL_ADD_CHANNEL:;
case WIRE_GOSSIPD_LOCAL_CHANNEL_UPDATE:;
case WIRE_GOSSIPD_NEW_STORE_FD:;
case WIRE_GOSSIPD_LOCAL_CHANNEL_ANNOUNCEMENT:;
return true;
}
return false;
}
/* WIRE: GOSSIPD_GET_UPDATE */
/* Channel daemon can ask for updates for a specific channel */
/* errors. */
u8 *towire_gossipd_get_update(const tal_t *ctx, const struct short_channel_id *short_channel_id)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_GET_UPDATE);
towire_short_channel_id(&p, short_channel_id);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_get_update(const void *p, struct short_channel_id *short_channel_id)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_GET_UPDATE)
return false;
fromwire_short_channel_id(&cursor, &plen, short_channel_id);
return cursor != NULL;
}
/* WIRE: GOSSIPD_GET_UPDATE_REPLY */
/* If channel isn't known */
u8 *towire_gossipd_get_update_reply(const tal_t *ctx, const u8 *update)
{
u16 len = tal_count(update);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_GET_UPDATE_REPLY);
towire_u16(&p, len);
towire_u8_array(&p, update, len);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_get_update_reply(const tal_t *ctx, const void *p, u8 **update)
{
u16 len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_GET_UPDATE_REPLY)
return false;
len = fromwire_u16(&cursor, &plen);
// 2nd case update
*update = len ? tal_arr(ctx, u8, len) : NULL;
fromwire_u8_array(&cursor, &plen, *update, len);
return cursor != NULL;
}
/* WIRE: GOSSIPD_LOCAL_ADD_CHANNEL */
/* Both sides have seen the funding tx being locked */
/* yet reached the announcement depth. So we add the channel locally so */
/* we (and peer) can update it already. */
u8 *towire_gossipd_local_add_channel(const tal_t *ctx, const struct short_channel_id *short_channel_id, const struct node_id *remote_node_id, struct amount_sat satoshis, const u8 *features)
{
u16 flen = tal_count(features);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_LOCAL_ADD_CHANNEL);
towire_short_channel_id(&p, short_channel_id);
towire_node_id(&p, remote_node_id);
towire_amount_sat(&p, satoshis);
towire_u16(&p, flen);
towire_u8_array(&p, features, flen);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_local_add_channel(const tal_t *ctx, const void *p, struct short_channel_id *short_channel_id, struct node_id *remote_node_id, struct amount_sat *satoshis, u8 **features)
{
u16 flen;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_LOCAL_ADD_CHANNEL)
return false;
fromwire_short_channel_id(&cursor, &plen, short_channel_id);
fromwire_node_id(&cursor, &plen, remote_node_id);
*satoshis = fromwire_amount_sat(&cursor, &plen);
flen = fromwire_u16(&cursor, &plen);
// 2nd case features
*features = flen ? tal_arr(ctx, u8, flen) : NULL;
fromwire_u8_array(&cursor, &plen, *features, flen);
return cursor != NULL;
}
/* WIRE: GOSSIPD_LOCAL_CHANNEL_UPDATE */
/* Send this channel_update. */
u8 *towire_gossipd_local_channel_update(const tal_t *ctx, const struct short_channel_id *short_channel_id, bool disable, u16 cltv_expiry_delta, struct amount_msat htlc_minimum_msat, u32 fee_base_msat, u32 fee_proportional_millionths, struct amount_msat htlc_maximum_msat)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_LOCAL_CHANNEL_UPDATE);
towire_short_channel_id(&p, short_channel_id);
towire_bool(&p, disable);
towire_u16(&p, cltv_expiry_delta);
towire_amount_msat(&p, htlc_minimum_msat);
towire_u32(&p, fee_base_msat);
towire_u32(&p, fee_proportional_millionths);
towire_amount_msat(&p, htlc_maximum_msat);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_local_channel_update(const void *p, struct short_channel_id *short_channel_id, bool *disable, u16 *cltv_expiry_delta, struct amount_msat *htlc_minimum_msat, u32 *fee_base_msat, u32 *fee_proportional_millionths, struct amount_msat *htlc_maximum_msat)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_LOCAL_CHANNEL_UPDATE)
return false;
fromwire_short_channel_id(&cursor, &plen, short_channel_id);
*disable = fromwire_bool(&cursor, &plen);
*cltv_expiry_delta = fromwire_u16(&cursor, &plen);
*htlc_minimum_msat = fromwire_amount_msat(&cursor, &plen);
*fee_base_msat = fromwire_u32(&cursor, &plen);
*fee_proportional_millionths = fromwire_u32(&cursor, &plen);
*htlc_maximum_msat = fromwire_amount_msat(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: GOSSIPD_NEW_STORE_FD */
/* Update your gossip_store fd: + gossip_store_fd */
u8 *towire_gossipd_new_store_fd(const tal_t *ctx, u64 offset_shorter)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_NEW_STORE_FD);
/* How much shorter the new store is */
towire_u64(&p, offset_shorter);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_new_store_fd(const void *p, u64 *offset_shorter)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_NEW_STORE_FD)
return false;
/* How much shorter the new store is */
*offset_shorter = fromwire_u64(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: GOSSIPD_LOCAL_CHANNEL_ANNOUNCEMENT */
/* Send this channel_announcement */
u8 *towire_gossipd_local_channel_announcement(const tal_t *ctx, const u8 *cannount)
{
u16 len = tal_count(cannount);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_LOCAL_CHANNEL_ANNOUNCEMENT);
towire_u16(&p, len);
towire_u8_array(&p, cannount, len);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_local_channel_announcement(const tal_t *ctx, const void *p, u8 **cannount)
{
u16 len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_LOCAL_CHANNEL_ANNOUNCEMENT)
return false;
len = fromwire_u16(&cursor, &plen);
// 2nd case cannount
*cannount = len ? tal_arr(ctx, u8, len) : NULL;
fromwire_u8_array(&cursor, &plen, *cannount, len);
return cursor != NULL;
}
// SHA256STAMP:exp-0-c3a2252dbb4648cc0fb0766797d4e69fd7afd59565f133bb6c24df54b5c42ad6

80
gossipd/gossipd_peerd_wiregen.h

@ -0,0 +1,80 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the _csv file it was generated from. */
/* Original template can be found at tools/gen/header_template */
#ifndef LIGHTNING_GOSSIPD_GOSSIPD_PEERD_WIREGEN_H
#define LIGHTNING_GOSSIPD_GOSSIPD_PEERD_WIREGEN_H
#include <ccan/tal/tal.h>
#include <wire/tlvstream.h>
#include <wire/wire.h>
#include <bitcoin/short_channel_id.h>
#include <common/amount.h>
#include <common/node_id.h>
enum gossipd_peerd_wire {
/* Channel daemon can ask for updates for a specific channel */
/* errors. */
WIRE_GOSSIPD_GET_UPDATE = 3501,
/* If channel isn't known */
WIRE_GOSSIPD_GET_UPDATE_REPLY = 3601,
/* Both sides have seen the funding tx being locked */
/* yet reached the announcement depth. So we add the channel locally so */
/* we (and peer) can update it already. */
WIRE_GOSSIPD_LOCAL_ADD_CHANNEL = 3503,
/* Send this channel_update. */
WIRE_GOSSIPD_LOCAL_CHANNEL_UPDATE = 3504,
/* Update your gossip_store fd: + gossip_store_fd */
WIRE_GOSSIPD_NEW_STORE_FD = 3505,
/* Send this channel_announcement */
WIRE_GOSSIPD_LOCAL_CHANNEL_ANNOUNCEMENT = 3506,
};
const char *gossipd_peerd_wire_name(int e);
/**
* Determine whether a given message type is defined as a message.
*
* Returns true if the message type is part of the message definitions we have
* generated parsers for, false if it is a custom message that cannot be
* handled internally.
*/
bool gossipd_peerd_wire_is_defined(u16 type);
/* WIRE: GOSSIPD_GET_UPDATE */
/* Channel daemon can ask for updates for a specific channel */
/* errors. */
u8 *towire_gossipd_get_update(const tal_t *ctx, const struct short_channel_id *short_channel_id);
bool fromwire_gossipd_get_update(const void *p, struct short_channel_id *short_channel_id);
/* WIRE: GOSSIPD_GET_UPDATE_REPLY */
/* If channel isn't known */
u8 *towire_gossipd_get_update_reply(const tal_t *ctx, const u8 *update);
bool fromwire_gossipd_get_update_reply(const tal_t *ctx, const void *p, u8 **update);
/* WIRE: GOSSIPD_LOCAL_ADD_CHANNEL */
/* Both sides have seen the funding tx being locked */
/* yet reached the announcement depth. So we add the channel locally so */
/* we (and peer) can update it already. */
u8 *towire_gossipd_local_add_channel(const tal_t *ctx, const struct short_channel_id *short_channel_id, const struct node_id *remote_node_id, struct amount_sat satoshis, const u8 *features);
bool fromwire_gossipd_local_add_channel(const tal_t *ctx, const void *p, struct short_channel_id *short_channel_id, struct node_id *remote_node_id, struct amount_sat *satoshis, u8 **features);
/* WIRE: GOSSIPD_LOCAL_CHANNEL_UPDATE */
/* Send this channel_update. */
u8 *towire_gossipd_local_channel_update(const tal_t *ctx, const struct short_channel_id *short_channel_id, bool disable, u16 cltv_expiry_delta, struct amount_msat htlc_minimum_msat, u32 fee_base_msat, u32 fee_proportional_millionths, struct amount_msat htlc_maximum_msat);
bool fromwire_gossipd_local_channel_update(const void *p, struct short_channel_id *short_channel_id, bool *disable, u16 *cltv_expiry_delta, struct amount_msat *htlc_minimum_msat, u32 *fee_base_msat, u32 *fee_proportional_millionths, struct amount_msat *htlc_maximum_msat);
/* WIRE: GOSSIPD_NEW_STORE_FD */
/* Update your gossip_store fd: + gossip_store_fd */
u8 *towire_gossipd_new_store_fd(const tal_t *ctx, u64 offset_shorter);
bool fromwire_gossipd_new_store_fd(const void *p, u64 *offset_shorter);
/* WIRE: GOSSIPD_LOCAL_CHANNEL_ANNOUNCEMENT */
/* Send this channel_announcement */
u8 *towire_gossipd_local_channel_announcement(const tal_t *ctx, const u8 *cannount);
bool fromwire_gossipd_local_channel_announcement(const tal_t *ctx, const void *p, u8 **cannount);
#endif /* LIGHTNING_GOSSIPD_GOSSIPD_PEERD_WIREGEN_H */
// SHA256STAMP:exp-0-c3a2252dbb4648cc0fb0766797d4e69fd7afd59565f133bb6c24df54b5c42ad6

861
gossipd/gossipd_wiregen.c

@ -0,0 +1,861 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the .csv file it was generated from. */
/* Original template can be found at tools/gen/impl_template */
#include <gossipd/gossipd_wiregen.h>
#include <assert.h>
#include <ccan/array_size/array_size.h>
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/utils.h>
#include <stdio.h>
#ifndef SUPERVERBOSE
#define SUPERVERBOSE(...)
#endif
const char *gossipd_wire_name(int e)
{
static char invalidbuf[sizeof("INVALID ") + STR_MAX_CHARS(e)];
switch ((enum gossipd_wire)e) {
case WIRE_GOSSIPD_INIT: return "WIRE_GOSSIPD_INIT";
case WIRE_GOSSIPD_DEV_SET_TIME: return "WIRE_GOSSIPD_DEV_SET_TIME";
case WIRE_GOSSIPD_GETNODES_REQUEST: return "WIRE_GOSSIPD_GETNODES_REQUEST";
case WIRE_GOSSIPD_GETNODES_REPLY: return "WIRE_GOSSIPD_GETNODES_REPLY";
case WIRE_GOSSIPD_GETROUTE_REQUEST: return "WIRE_GOSSIPD_GETROUTE_REQUEST";
case WIRE_GOSSIPD_GETROUTE_REPLY: return "WIRE_GOSSIPD_GETROUTE_REPLY";
case WIRE_GOSSIPD_GETCHANNELS_REQUEST: return "WIRE_GOSSIPD_GETCHANNELS_REQUEST";
case WIRE_GOSSIPD_GETCHANNELS_REPLY: return "WIRE_GOSSIPD_GETCHANNELS_REPLY";
case WIRE_GOSSIPD_PING: return "WIRE_GOSSIPD_PING";
case WIRE_GOSSIPD_PING_REPLY: return "WIRE_GOSSIPD_PING_REPLY";
case WIRE_GOSSIPD_DEV_SET_MAX_SCIDS_ENCODE_SIZE: return "WIRE_GOSSIPD_DEV_SET_MAX_SCIDS_ENCODE_SIZE";
case WIRE_GOSSIPD_GET_STRIPPED_CUPDATE: return "WIRE_GOSSIPD_GET_STRIPPED_CUPDATE";
case WIRE_GOSSIPD_GET_STRIPPED_CUPDATE_REPLY: return "WIRE_GOSSIPD_GET_STRIPPED_CUPDATE_REPLY";
case WIRE_GOSSIPD_LOCAL_CHANNEL_CLOSE: return "WIRE_GOSSIPD_LOCAL_CHANNEL_CLOSE";
case WIRE_GOSSIPD_GET_TXOUT: return "WIRE_GOSSIPD_GET_TXOUT";
case WIRE_GOSSIPD_GET_TXOUT_REPLY: return "WIRE_GOSSIPD_GET_TXOUT_REPLY";
case WIRE_GOSSIPD_PAYMENT_FAILURE: return "WIRE_GOSSIPD_PAYMENT_FAILURE";
case WIRE_GOSSIPD_OUTPOINT_SPENT: return "WIRE_GOSSIPD_OUTPOINT_SPENT";
case WIRE_GOSSIPD_DEV_SUPPRESS: return "WIRE_GOSSIPD_DEV_SUPPRESS";
case WIRE_GOSSIPD_DEV_MEMLEAK: return "WIRE_GOSSIPD_DEV_MEMLEAK";
case WIRE_GOSSIPD_DEV_MEMLEAK_REPLY: return "WIRE_GOSSIPD_DEV_MEMLEAK_REPLY";
case WIRE_GOSSIPD_DEV_COMPACT_STORE: return "WIRE_GOSSIPD_DEV_COMPACT_STORE";
case WIRE_GOSSIPD_DEV_COMPACT_STORE_REPLY: return "WIRE_GOSSIPD_DEV_COMPACT_STORE_REPLY";
case WIRE_GOSSIPD_GET_INCOMING_CHANNELS: return "WIRE_GOSSIPD_GET_INCOMING_CHANNELS";
case WIRE_GOSSIPD_GET_INCOMING_CHANNELS_REPLY: return "WIRE_GOSSIPD_GET_INCOMING_CHANNELS_REPLY";
case WIRE_GOSSIPD_NEW_BLOCKHEIGHT: return "WIRE_GOSSIPD_NEW_BLOCKHEIGHT";
}
snprintf(invalidbuf, sizeof(invalidbuf), "INVALID %i", e);
return invalidbuf;
}
bool gossipd_wire_is_defined(u16 type)
{
switch ((enum gossipd_wire)type) {
case WIRE_GOSSIPD_INIT:;
case WIRE_GOSSIPD_DEV_SET_TIME:;
case WIRE_GOSSIPD_GETNODES_REQUEST:;
case WIRE_GOSSIPD_GETNODES_REPLY:;
case WIRE_GOSSIPD_GETROUTE_REQUEST:;
case WIRE_GOSSIPD_GETROUTE_REPLY:;
case WIRE_GOSSIPD_GETCHANNELS_REQUEST:;
case WIRE_GOSSIPD_GETCHANNELS_REPLY:;
case WIRE_GOSSIPD_PING:;
case WIRE_GOSSIPD_PING_REPLY:;
case WIRE_GOSSIPD_DEV_SET_MAX_SCIDS_ENCODE_SIZE:;
case WIRE_GOSSIPD_GET_STRIPPED_CUPDATE:;
case WIRE_GOSSIPD_GET_STRIPPED_CUPDATE_REPLY:;
case WIRE_GOSSIPD_LOCAL_CHANNEL_CLOSE:;
case WIRE_GOSSIPD_GET_TXOUT:;
case WIRE_GOSSIPD_GET_TXOUT_REPLY:;
case WIRE_GOSSIPD_PAYMENT_FAILURE:;
case WIRE_GOSSIPD_OUTPOINT_SPENT:;
case WIRE_GOSSIPD_DEV_SUPPRESS:;
case WIRE_GOSSIPD_DEV_MEMLEAK:;
case WIRE_GOSSIPD_DEV_MEMLEAK_REPLY:;
case WIRE_GOSSIPD_DEV_COMPACT_STORE:;
case WIRE_GOSSIPD_DEV_COMPACT_STORE_REPLY:;
case WIRE_GOSSIPD_GET_INCOMING_CHANNELS:;
case WIRE_GOSSIPD_GET_INCOMING_CHANNELS_REPLY:;
case WIRE_GOSSIPD_NEW_BLOCKHEIGHT:;
return true;
}
return false;
}
/* WIRE: GOSSIPD_INIT */
/* Initialize the gossip daemon. */
u8 *towire_gossipd_init(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_features, const struct node_id *id, const u8 rgb[3], const u8 alias[32], const struct wireaddr *announcable, u32 *dev_gossip_time, bool dev_fast_gossip, bool dev_fast_gossip_prune)
{
u16 num_announcable = tal_count(announcable);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_INIT);
towire_chainparams(&p, chainparams);
towire_feature_set(&p, our_features);
towire_node_id(&p, id);
towire_u8_array(&p, rgb, 3);
towire_u8_array(&p, alias, 32);
towire_u16(&p, num_announcable);
for (size_t i = 0; i < num_announcable; i++)
towire_wireaddr(&p, announcable + i);
if (!dev_gossip_time)
towire_bool(&p, false);
else {
towire_bool(&p, true);
towire_u32(&p, *dev_gossip_time);
}
towire_bool(&p, dev_fast_gossip);
towire_bool(&p, dev_fast_gossip_prune);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_features, struct node_id *id, u8 rgb[3], u8 alias[32], struct wireaddr **announcable, u32 **dev_gossip_time, bool *dev_fast_gossip, bool *dev_fast_gossip_prune)
{
u16 num_announcable;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_INIT)
return false;
fromwire_chainparams(&cursor, &plen, chainparams);
*our_features = fromwire_feature_set(ctx, &cursor, &plen);
fromwire_node_id(&cursor, &plen, id);
fromwire_u8_array(&cursor, &plen, rgb, 3);
fromwire_u8_array(&cursor, &plen, alias, 32);
num_announcable = fromwire_u16(&cursor, &plen);
// 2nd case announcable
*announcable = num_announcable ? tal_arr(ctx, struct wireaddr, num_announcable) : NULL;
for (size_t i = 0; i < num_announcable; i++)
fromwire_wireaddr(&cursor, &plen, *announcable + i);
if (!fromwire_bool(&cursor, &plen))
*dev_gossip_time = NULL;
else {
*dev_gossip_time = tal(ctx, u32);
**dev_gossip_time = fromwire_u32(&cursor, &plen);
}
*dev_fast_gossip = fromwire_bool(&cursor, &plen);
*dev_fast_gossip_prune = fromwire_bool(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: GOSSIPD_DEV_SET_TIME */
/* In developer mode */
u8 *towire_gossipd_dev_set_time(const tal_t *ctx, u32 dev_gossip_time)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_DEV_SET_TIME);
towire_u32(&p, dev_gossip_time);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_dev_set_time(const void *p, u32 *dev_gossip_time)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_DEV_SET_TIME)
return false;
*dev_gossip_time = fromwire_u32(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: GOSSIPD_GETNODES_REQUEST */
/* Pass JSON-RPC getnodes call through */
u8 *towire_gossipd_getnodes_request(const tal_t *ctx, const struct node_id *id)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_GETNODES_REQUEST);
if (!id)
towire_bool(&p, false);
else {
towire_bool(&p, true);
towire_node_id(&p, id);
}
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_getnodes_request(const tal_t *ctx, const void *p, struct node_id **id)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_GETNODES_REQUEST)
return false;
if (!fromwire_bool(&cursor, &plen))
*id = NULL;
else {
*id = tal(ctx, struct node_id);
fromwire_node_id(&cursor, &plen, *id);
}
return cursor != NULL;
}
/* WIRE: GOSSIPD_GETNODES_REPLY */
u8 *towire_gossipd_getnodes_reply(const tal_t *ctx, const struct gossip_getnodes_entry **nodes)
{
u32 num_nodes = tal_count(nodes);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_GETNODES_REPLY);
towire_u32(&p, num_nodes);
for (size_t i = 0; i < num_nodes; i++)
towire_gossip_getnodes_entry(&p, nodes[i]);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_getnodes_reply(const tal_t *ctx, const void *p, struct gossip_getnodes_entry ***nodes)
{
u32 num_nodes;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_GETNODES_REPLY)
return false;
num_nodes = fromwire_u32(&cursor, &plen);
// 2nd case nodes
*nodes = num_nodes ? tal_arr(ctx, struct gossip_getnodes_entry *, num_nodes) : NULL;
for (size_t i = 0; i < num_nodes; i++)
(*nodes)[i] = fromwire_gossip_getnodes_entry(*nodes, &cursor, &plen);
return cursor != NULL;
}
/* WIRE: GOSSIPD_GETROUTE_REQUEST */
/* Pass JSON-RPC getroute call through */
u8 *towire_gossipd_getroute_request(const tal_t *ctx, const struct node_id *source, const struct node_id *destination, struct amount_msat msatoshi, u64 riskfactor_millionths, u32 final_cltv, u64 fuzz_millionths, const struct exclude_entry **excluded, u32 max_hops)
{
u16 num_excluded = tal_count(excluded);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_GETROUTE_REQUEST);
/* Source defaults to "us" */
if (!source)
towire_bool(&p, false);
else {
towire_bool(&p, true);
towire_node_id(&p, source);
}
towire_node_id(&p, destination);
towire_amount_msat(&p, msatoshi);
towire_u64(&p, riskfactor_millionths);
towire_u32(&p, final_cltv);
towire_u64(&p, fuzz_millionths);
towire_u16(&p, num_excluded);
for (size_t i = 0; i < num_excluded; i++)
towire_exclude_entry(&p, excluded[i]);
towire_u32(&p, max_hops);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_getroute_request(const tal_t *ctx, const void *p, struct node_id **source, struct node_id *destination, struct amount_msat *msatoshi, u64 *riskfactor_millionths, u32 *final_cltv, u64 *fuzz_millionths, struct exclude_entry ***excluded, u32 *max_hops)
{
u16 num_excluded;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_GETROUTE_REQUEST)
return false;
/* Source defaults to "us" */
if (!fromwire_bool(&cursor, &plen))
*source = NULL;
else {
*source = tal(ctx, struct node_id);
fromwire_node_id(&cursor, &plen, *source);
}
fromwire_node_id(&cursor, &plen, destination);
*msatoshi = fromwire_amount_msat(&cursor, &plen);
*riskfactor_millionths = fromwire_u64(&cursor, &plen);
*final_cltv = fromwire_u32(&cursor, &plen);
*fuzz_millionths = fromwire_u64(&cursor, &plen);
num_excluded = fromwire_u16(&cursor, &plen);
// 2nd case excluded
*excluded = num_excluded ? tal_arr(ctx, struct exclude_entry *, num_excluded) : NULL;
for (size_t i = 0; i < num_excluded; i++)
(*excluded)[i] = fromwire_exclude_entry(*excluded, &cursor, &plen);
*max_hops = fromwire_u32(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: GOSSIPD_GETROUTE_REPLY */
u8 *towire_gossipd_getroute_reply(const tal_t *ctx, const struct route_hop **hops)
{
u16 num_hops = tal_count(hops);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_GETROUTE_REPLY);
towire_u16(&p, num_hops);
for (size_t i = 0; i < num_hops; i++)
towire_route_hop(&p, hops[i]);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_getroute_reply(const tal_t *ctx, const void *p, struct route_hop ***hops)
{
u16 num_hops;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_GETROUTE_REPLY)
return false;
num_hops = fromwire_u16(&cursor, &plen);
// 2nd case hops
*hops = num_hops ? tal_arr(ctx, struct route_hop *, num_hops) : NULL;
for (size_t i = 0; i < num_hops; i++)
(*hops)[i] = fromwire_route_hop(*hops, &cursor, &plen);
return cursor != NULL;
}
/* WIRE: GOSSIPD_GETCHANNELS_REQUEST */
u8 *towire_gossipd_getchannels_request(const tal_t *ctx, const struct short_channel_id *short_channel_id, const struct node_id *source, const struct short_channel_id *prev)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_GETCHANNELS_REQUEST);
if (!short_channel_id)
towire_bool(&p, false);
else {
towire_bool(&p, true);
towire_short_channel_id(&p, short_channel_id);
}
if (!source)
towire_bool(&p, false);
else {
towire_bool(&p, true);
towire_node_id(&p, source);
}
if (!prev)
towire_bool(&p, false);
else {
towire_bool(&p, true);
towire_short_channel_id(&p, prev);
}
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_getchannels_request(const tal_t *ctx, const void *p, struct short_channel_id **short_channel_id, struct node_id **source, struct short_channel_id **prev)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_GETCHANNELS_REQUEST)
return false;
if (!fromwire_bool(&cursor, &plen))
*short_channel_id = NULL;
else {
*short_channel_id = tal(ctx, struct short_channel_id);
fromwire_short_channel_id(&cursor, &plen, *short_channel_id);
}
if (!fromwire_bool(&cursor, &plen))
*source = NULL;
else {
*source = tal(ctx, struct node_id);
fromwire_node_id(&cursor, &plen, *source);
}
if (!fromwire_bool(&cursor, &plen))
*prev = NULL;
else {
*prev = tal(ctx, struct short_channel_id);
fromwire_short_channel_id(&cursor, &plen, *prev);
}
return cursor != NULL;
}
/* WIRE: GOSSIPD_GETCHANNELS_REPLY */
u8 *towire_gossipd_getchannels_reply(const tal_t *ctx, bool complete, const struct gossip_getchannels_entry **nodes)
{
u32 num_channels = tal_count(nodes);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_GETCHANNELS_REPLY);
towire_bool(&p, complete);
towire_u32(&p, num_channels);
for (size_t i = 0; i < num_channels; i++)
towire_gossip_getchannels_entry(&p, nodes[i]);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_getchannels_reply(const tal_t *ctx, const void *p, bool *complete, struct gossip_getchannels_entry ***nodes)
{
u32 num_channels;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_GETCHANNELS_REPLY)
return false;
*complete = fromwire_bool(&cursor, &plen);
num_channels = fromwire_u32(&cursor, &plen);
// 2nd case nodes
*nodes = num_channels ? tal_arr(ctx, struct gossip_getchannels_entry *, num_channels) : NULL;
for (size_t i = 0; i < num_channels; i++)
(*nodes)[i] = fromwire_gossip_getchannels_entry(*nodes, &cursor, &plen);
return cursor != NULL;
}
/* WIRE: GOSSIPD_PING */
/* Ping/pong test. Waits for a reply if it expects one. */
u8 *towire_gossipd_ping(const tal_t *ctx, const struct node_id *id, u16 num_pong_bytes, u16 len)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_PING);
towire_node_id(&p, id);
towire_u16(&p, num_pong_bytes);
towire_u16(&p, len);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_ping(const void *p, struct node_id *id, u16 *num_pong_bytes, u16 *len)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_PING)
return false;
fromwire_node_id(&cursor, &plen, id);
*num_pong_bytes = fromwire_u16(&cursor, &plen);
*len = fromwire_u16(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: GOSSIPD_PING_REPLY */
u8 *towire_gossipd_ping_reply(const tal_t *ctx, const struct node_id *id, bool sent, u16 totlen)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_PING_REPLY);
towire_node_id(&p, id);
/* False if id in gossip_ping was unknown. */
towire_bool(&p, sent);
/* 0 == no pong expected */
towire_u16(&p, totlen);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_ping_reply(const void *p, struct node_id *id, bool *sent, u16 *totlen)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_PING_REPLY)
return false;
fromwire_node_id(&cursor, &plen, id);
/* False if id in gossip_ping was unknown. */
*sent = fromwire_bool(&cursor, &plen);
/* 0 == no pong expected */
*totlen = fromwire_u16(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: GOSSIPD_DEV_SET_MAX_SCIDS_ENCODE_SIZE */
/* Set artificial maximum reply_channel_range size. Master->gossipd */
u8 *towire_gossipd_dev_set_max_scids_encode_size(const tal_t *ctx, u32 max)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_DEV_SET_MAX_SCIDS_ENCODE_SIZE);
towire_u32(&p, max);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_dev_set_max_scids_encode_size(const void *p, u32 *max)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_DEV_SET_MAX_SCIDS_ENCODE_SIZE)
return false;
*max = fromwire_u32(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: GOSSIPD_GET_STRIPPED_CUPDATE */
/* Given a short_channel_id */
u8 *towire_gossipd_get_stripped_cupdate(const tal_t *ctx, const struct short_channel_id *channel_id)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_GET_STRIPPED_CUPDATE);
towire_short_channel_id(&p, channel_id);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_get_stripped_cupdate(const void *p, struct short_channel_id *channel_id)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_GET_STRIPPED_CUPDATE)
return false;
fromwire_short_channel_id(&cursor, &plen, channel_id);
return cursor != NULL;
}
/* WIRE: GOSSIPD_GET_STRIPPED_CUPDATE_REPLY */
u8 *towire_gossipd_get_stripped_cupdate_reply(const tal_t *ctx, const u8 *stripped_update)
{
u16 stripped_update_len = tal_count(stripped_update);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_GET_STRIPPED_CUPDATE_REPLY);
towire_u16(&p, stripped_update_len);
towire_u8_array(&p, stripped_update, stripped_update_len);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_get_stripped_cupdate_reply(const tal_t *ctx, const void *p, u8 **stripped_update)
{
u16 stripped_update_len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_GET_STRIPPED_CUPDATE_REPLY)
return false;
stripped_update_len = fromwire_u16(&cursor, &plen);
// 2nd case stripped_update
*stripped_update = stripped_update_len ? tal_arr(ctx, u8, stripped_update_len) : NULL;
fromwire_u8_array(&cursor, &plen, *stripped_update, stripped_update_len);
return cursor != NULL;
}
/* WIRE: GOSSIPD_LOCAL_CHANNEL_CLOSE */
/* gossipd->master: we're closing this channel. */
u8 *towire_gossipd_local_channel_close(const tal_t *ctx, const struct short_channel_id *short_channel_id)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_LOCAL_CHANNEL_CLOSE);
towire_short_channel_id(&p, short_channel_id);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_local_channel_close(const void *p, struct short_channel_id *short_channel_id)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_LOCAL_CHANNEL_CLOSE)
return false;
fromwire_short_channel_id(&cursor, &plen, short_channel_id);
return cursor != NULL;
}
/* WIRE: GOSSIPD_GET_TXOUT */
/* Gossipd->master get this tx output please. */
u8 *towire_gossipd_get_txout(const tal_t *ctx, const struct short_channel_id *short_channel_id)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_GET_TXOUT);
towire_short_channel_id(&p, short_channel_id);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_get_txout(const void *p, struct short_channel_id *short_channel_id)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_GET_TXOUT)
return false;
fromwire_short_channel_id(&cursor, &plen, short_channel_id);
return cursor != NULL;
}
/* WIRE: GOSSIPD_GET_TXOUT_REPLY */
/* master->gossipd here is the output */
u8 *towire_gossipd_get_txout_reply(const tal_t *ctx, const struct short_channel_id *short_channel_id, struct amount_sat satoshis, const u8 *outscript)
{
u16 len = tal_count(outscript);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_GET_TXOUT_REPLY);
towire_short_channel_id(&p, short_channel_id);
towire_amount_sat(&p, satoshis);
towire_u16(&p, len);
towire_u8_array(&p, outscript, len);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_get_txout_reply(const tal_t *ctx, const void *p, struct short_channel_id *short_channel_id, struct amount_sat *satoshis, u8 **outscript)
{
u16 len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_GET_TXOUT_REPLY)
return false;
fromwire_short_channel_id(&cursor, &plen, short_channel_id);
*satoshis = fromwire_amount_sat(&cursor, &plen);
len = fromwire_u16(&cursor, &plen);
// 2nd case outscript
*outscript = len ? tal_arr(ctx, u8, len) : NULL;
fromwire_u8_array(&cursor, &plen, *outscript, len);
return cursor != NULL;
}
/* WIRE: GOSSIPD_PAYMENT_FAILURE */
/* master->gossipd an htlc failed with this onion error. */
u8 *towire_gossipd_payment_failure(const tal_t *ctx, const u8 *error)
{
u16 len = tal_count(error);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_PAYMENT_FAILURE);
towire_u16(&p, len);
towire_u8_array(&p, error, len);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_payment_failure(const tal_t *ctx, const void *p, u8 **error)
{
u16 len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_PAYMENT_FAILURE)
return false;
len = fromwire_u16(&cursor, &plen);
// 2nd case error
*error = len ? tal_arr(ctx, u8, len) : NULL;
fromwire_u8_array(&cursor, &plen, *error, len);
return cursor != NULL;
}
/* WIRE: GOSSIPD_OUTPOINT_SPENT */
/* master -> gossipd: a potential funding outpoint was spent */
u8 *towire_gossipd_outpoint_spent(const tal_t *ctx, const struct short_channel_id *short_channel_id)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_OUTPOINT_SPENT);
towire_short_channel_id(&p, short_channel_id);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_outpoint_spent(const void *p, struct short_channel_id *short_channel_id)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_OUTPOINT_SPENT)
return false;
fromwire_short_channel_id(&cursor, &plen, short_channel_id);
return cursor != NULL;
}
/* WIRE: GOSSIPD_DEV_SUPPRESS */
/* master -> gossipd: stop gossip timers. */
u8 *towire_gossipd_dev_suppress(const tal_t *ctx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_DEV_SUPPRESS);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_dev_suppress(const void *p)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_DEV_SUPPRESS)
return false;
return cursor != NULL;
}
/* WIRE: GOSSIPD_DEV_MEMLEAK */
/* master -> gossipd: do you have a memleak? */
u8 *towire_gossipd_dev_memleak(const tal_t *ctx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_DEV_MEMLEAK);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_dev_memleak(const void *p)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_DEV_MEMLEAK)
return false;
return cursor != NULL;
}
/* WIRE: GOSSIPD_DEV_MEMLEAK_REPLY */
u8 *towire_gossipd_dev_memleak_reply(const tal_t *ctx, bool leak)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_DEV_MEMLEAK_REPLY);
towire_bool(&p, leak);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_dev_memleak_reply(const void *p, bool *leak)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_DEV_MEMLEAK_REPLY)
return false;
*leak = fromwire_bool(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: GOSSIPD_DEV_COMPACT_STORE */
/* master -> gossipd: please rewrite the gossip_store */
u8 *towire_gossipd_dev_compact_store(const tal_t *ctx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_DEV_COMPACT_STORE);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_dev_compact_store(const void *p)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_DEV_COMPACT_STORE)
return false;
return cursor != NULL;
}
/* WIRE: GOSSIPD_DEV_COMPACT_STORE_REPLY */
/* gossipd -> master: ok */
u8 *towire_gossipd_dev_compact_store_reply(const tal_t *ctx, bool success)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_DEV_COMPACT_STORE_REPLY);
towire_bool(&p, success);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_dev_compact_store_reply(const void *p, bool *success)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_DEV_COMPACT_STORE_REPLY)
return false;
*success = fromwire_bool(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: GOSSIPD_GET_INCOMING_CHANNELS */
/* master -> gossipd: get route_info for our incoming channels */
u8 *towire_gossipd_get_incoming_channels(const tal_t *ctx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_GET_INCOMING_CHANNELS);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_get_incoming_channels(const void *p)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_GET_INCOMING_CHANNELS)
return false;
return cursor != NULL;
}
/* WIRE: GOSSIPD_GET_INCOMING_CHANNELS_REPLY */
/* gossipd -> master: here they are. */
u8 *towire_gossipd_get_incoming_channels_reply(const tal_t *ctx, const struct route_info *public_route_info, const bool *public_deadends, const struct route_info *private_route_info, const bool *private_deadends)
{
u16 num_public = tal_count(public_deadends);
u16 num_private = tal_count(private_deadends);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_GET_INCOMING_CHANNELS_REPLY);
towire_u16(&p, num_public);
for (size_t i = 0; i < num_public; i++)
towire_route_info(&p, public_route_info + i);
for (size_t i = 0; i < num_public; i++)
towire_bool(&p, public_deadends[i]);
towire_u16(&p, num_private);
for (size_t i = 0; i < num_private; i++)
towire_route_info(&p, private_route_info + i);
for (size_t i = 0; i < num_private; i++)
towire_bool(&p, private_deadends[i]);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_get_incoming_channels_reply(const tal_t *ctx, const void *p, struct route_info **public_route_info, bool **public_deadends, struct route_info **private_route_info, bool **private_deadends)
{
u16 num_public;
u16 num_private;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_GET_INCOMING_CHANNELS_REPLY)
return false;
num_public = fromwire_u16(&cursor, &plen);
// 2nd case public_route_info
*public_route_info = num_public ? tal_arr(ctx, struct route_info, num_public) : NULL;
for (size_t i = 0; i < num_public; i++)
fromwire_route_info(&cursor, &plen, *public_route_info + i);
// 2nd case public_deadends
*public_deadends = num_public ? tal_arr(ctx, bool, num_public) : NULL;
for (size_t i = 0; i < num_public; i++)
(*public_deadends)[i] = fromwire_bool(&cursor, &plen);
num_private = fromwire_u16(&cursor, &plen);
// 2nd case private_route_info
*private_route_info = num_private ? tal_arr(ctx, struct route_info, num_private) : NULL;
for (size_t i = 0; i < num_private; i++)
fromwire_route_info(&cursor, &plen, *private_route_info + i);
// 2nd case private_deadends
*private_deadends = num_private ? tal_arr(ctx, bool, num_private) : NULL;
for (size_t i = 0; i < num_private; i++)
(*private_deadends)[i] = fromwire_bool(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: GOSSIPD_NEW_BLOCKHEIGHT */
/* master -> gossipd: blockheight increased. */
u8 *towire_gossipd_new_blockheight(const tal_t *ctx, u32 blockheight)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_GOSSIPD_NEW_BLOCKHEIGHT);
towire_u32(&p, blockheight);
return memcheck(p, tal_count(p));
}
bool fromwire_gossipd_new_blockheight(const void *p, u32 *blockheight)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_GOSSIPD_NEW_BLOCKHEIGHT)
return false;
*blockheight = fromwire_u32(&cursor, &plen);
return cursor != NULL;
}
// SHA256STAMP:exp-0-6790ea53b0abf99e5595d11fe496d3ac5fe5b159f15205eca4c34a96856626d8

203
gossipd/gossipd_wiregen.h

@ -0,0 +1,203 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the _csv file it was generated from. */
/* Original template can be found at tools/gen/header_template */
#ifndef LIGHTNING_GOSSIPD_GOSSIPD_WIREGEN_H
#define LIGHTNING_GOSSIPD_GOSSIPD_WIREGEN_H
#include <ccan/tal/tal.h>
#include <wire/tlvstream.h>
#include <wire/wire.h>
#include <common/cryptomsg.h>
#include <common/features.h>
#include <common/wireaddr.h>
#include <wire/onion_wiregen.h>
#include <lightningd/gossip_msg.h>
#include <common/bolt11.h>
enum gossipd_wire {
/* Initialize the gossip daemon. */
WIRE_GOSSIPD_INIT = 3000,
/* In developer mode */
WIRE_GOSSIPD_DEV_SET_TIME = 3001,
/* Pass JSON-RPC getnodes call through */
WIRE_GOSSIPD_GETNODES_REQUEST = 3005,
WIRE_GOSSIPD_GETNODES_REPLY = 3105,
/* Pass JSON-RPC getroute call through */
WIRE_GOSSIPD_GETROUTE_REQUEST = 3006,
WIRE_GOSSIPD_GETROUTE_REPLY = 3106,
WIRE_GOSSIPD_GETCHANNELS_REQUEST = 3007,
WIRE_GOSSIPD_GETCHANNELS_REPLY = 3107,
/* Ping/pong test. Waits for a reply if it expects one. */
WIRE_GOSSIPD_PING = 3008,
WIRE_GOSSIPD_PING_REPLY = 3108,
/* Set artificial maximum reply_channel_range size. Master->gossipd */
WIRE_GOSSIPD_DEV_SET_MAX_SCIDS_ENCODE_SIZE = 3030,
/* Given a short_channel_id */
WIRE_GOSSIPD_GET_STRIPPED_CUPDATE = 3010,
WIRE_GOSSIPD_GET_STRIPPED_CUPDATE_REPLY = 3110,
/* gossipd->master: we're closing this channel. */
WIRE_GOSSIPD_LOCAL_CHANNEL_CLOSE = 3027,
/* Gossipd->master get this tx output please. */
WIRE_GOSSIPD_GET_TXOUT = 3018,
/* master->gossipd here is the output */
WIRE_GOSSIPD_GET_TXOUT_REPLY = 3118,
/* master->gossipd an htlc failed with this onion error. */
WIRE_GOSSIPD_PAYMENT_FAILURE = 3021,
/* master -> gossipd: a potential funding outpoint was spent */
WIRE_GOSSIPD_OUTPOINT_SPENT = 3024,
/* master -> gossipd: stop gossip timers. */
WIRE_GOSSIPD_DEV_SUPPRESS = 3032,
/* master -> gossipd: do you have a memleak? */
WIRE_GOSSIPD_DEV_MEMLEAK = 3033,
WIRE_GOSSIPD_DEV_MEMLEAK_REPLY = 3133,
/* master -> gossipd: please rewrite the gossip_store */
WIRE_GOSSIPD_DEV_COMPACT_STORE = 3034,
/* gossipd -> master: ok */
WIRE_GOSSIPD_DEV_COMPACT_STORE_REPLY = 3134,
/* master -> gossipd: get route_info for our incoming channels */
WIRE_GOSSIPD_GET_INCOMING_CHANNELS = 3025,
/* gossipd -> master: here they are. */
WIRE_GOSSIPD_GET_INCOMING_CHANNELS_REPLY = 3125,
/* master -> gossipd: blockheight increased. */
WIRE_GOSSIPD_NEW_BLOCKHEIGHT = 3026,
};
const char *gossipd_wire_name(int e);
/**
* Determine whether a given message type is defined as a message.
*
* Returns true if the message type is part of the message definitions we have
* generated parsers for, false if it is a custom message that cannot be
* handled internally.
*/
bool gossipd_wire_is_defined(u16 type);
/* WIRE: GOSSIPD_INIT */
/* Initialize the gossip daemon. */
u8 *towire_gossipd_init(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_features, const struct node_id *id, const u8 rgb[3], const u8 alias[32], const struct wireaddr *announcable, u32 *dev_gossip_time, bool dev_fast_gossip, bool dev_fast_gossip_prune);
bool fromwire_gossipd_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_features, struct node_id *id, u8 rgb[3], u8 alias[32], struct wireaddr **announcable, u32 **dev_gossip_time, bool *dev_fast_gossip, bool *dev_fast_gossip_prune);
/* WIRE: GOSSIPD_DEV_SET_TIME */
/* In developer mode */
u8 *towire_gossipd_dev_set_time(const tal_t *ctx, u32 dev_gossip_time);
bool fromwire_gossipd_dev_set_time(const void *p, u32 *dev_gossip_time);
/* WIRE: GOSSIPD_GETNODES_REQUEST */
/* Pass JSON-RPC getnodes call through */
u8 *towire_gossipd_getnodes_request(const tal_t *ctx, const struct node_id *id);
bool fromwire_gossipd_getnodes_request(const tal_t *ctx, const void *p, struct node_id **id);
/* WIRE: GOSSIPD_GETNODES_REPLY */
u8 *towire_gossipd_getnodes_reply(const tal_t *ctx, const struct gossip_getnodes_entry **nodes);
bool fromwire_gossipd_getnodes_reply(const tal_t *ctx, const void *p, struct gossip_getnodes_entry ***nodes);
/* WIRE: GOSSIPD_GETROUTE_REQUEST */
/* Pass JSON-RPC getroute call through */
u8 *towire_gossipd_getroute_request(const tal_t *ctx, const struct node_id *source, const struct node_id *destination, struct amount_msat msatoshi, u64 riskfactor_millionths, u32 final_cltv, u64 fuzz_millionths, const struct exclude_entry **excluded, u32 max_hops);
bool fromwire_gossipd_getroute_request(const tal_t *ctx, const void *p, struct node_id **source, struct node_id *destination, struct amount_msat *msatoshi, u64 *riskfactor_millionths, u32 *final_cltv, u64 *fuzz_millionths, struct exclude_entry ***excluded, u32 *max_hops);
/* WIRE: GOSSIPD_GETROUTE_REPLY */
u8 *towire_gossipd_getroute_reply(const tal_t *ctx, const struct route_hop **hops);
bool fromwire_gossipd_getroute_reply(const tal_t *ctx, const void *p, struct route_hop ***hops);
/* WIRE: GOSSIPD_GETCHANNELS_REQUEST */
u8 *towire_gossipd_getchannels_request(const tal_t *ctx, const struct short_channel_id *short_channel_id, const struct node_id *source, const struct short_channel_id *prev);
bool fromwire_gossipd_getchannels_request(const tal_t *ctx, const void *p, struct short_channel_id **short_channel_id, struct node_id **source, struct short_channel_id **prev);
/* WIRE: GOSSIPD_GETCHANNELS_REPLY */
u8 *towire_gossipd_getchannels_reply(const tal_t *ctx, bool complete, const struct gossip_getchannels_entry **nodes);
bool fromwire_gossipd_getchannels_reply(const tal_t *ctx, const void *p, bool *complete, struct gossip_getchannels_entry ***nodes);
/* WIRE: GOSSIPD_PING */
/* Ping/pong test. Waits for a reply if it expects one. */
u8 *towire_gossipd_ping(const tal_t *ctx, const struct node_id *id, u16 num_pong_bytes, u16 len);
bool fromwire_gossipd_ping(const void *p, struct node_id *id, u16 *num_pong_bytes, u16 *len);
/* WIRE: GOSSIPD_PING_REPLY */
u8 *towire_gossipd_ping_reply(const tal_t *ctx, const struct node_id *id, bool sent, u16 totlen);
bool fromwire_gossipd_ping_reply(const void *p, struct node_id *id, bool *sent, u16 *totlen);
/* WIRE: GOSSIPD_DEV_SET_MAX_SCIDS_ENCODE_SIZE */
/* Set artificial maximum reply_channel_range size. Master->gossipd */
u8 *towire_gossipd_dev_set_max_scids_encode_size(const tal_t *ctx, u32 max);
bool fromwire_gossipd_dev_set_max_scids_encode_size(const void *p, u32 *max);
/* WIRE: GOSSIPD_GET_STRIPPED_CUPDATE */
/* Given a short_channel_id */
u8 *towire_gossipd_get_stripped_cupdate(const tal_t *ctx, const struct short_channel_id *channel_id);
bool fromwire_gossipd_get_stripped_cupdate(const void *p, struct short_channel_id *channel_id);
/* WIRE: GOSSIPD_GET_STRIPPED_CUPDATE_REPLY */
u8 *towire_gossipd_get_stripped_cupdate_reply(const tal_t *ctx, const u8 *stripped_update);
bool fromwire_gossipd_get_stripped_cupdate_reply(const tal_t *ctx, const void *p, u8 **stripped_update);
/* WIRE: GOSSIPD_LOCAL_CHANNEL_CLOSE */
/* gossipd->master: we're closing this channel. */
u8 *towire_gossipd_local_channel_close(const tal_t *ctx, const struct short_channel_id *short_channel_id);
bool fromwire_gossipd_local_channel_close(const void *p, struct short_channel_id *short_channel_id);
/* WIRE: GOSSIPD_GET_TXOUT */
/* Gossipd->master get this tx output please. */
u8 *towire_gossipd_get_txout(const tal_t *ctx, const struct short_channel_id *short_channel_id);
bool fromwire_gossipd_get_txout(const void *p, struct short_channel_id *short_channel_id);
/* WIRE: GOSSIPD_GET_TXOUT_REPLY */
/* master->gossipd here is the output */
u8 *towire_gossipd_get_txout_reply(const tal_t *ctx, const struct short_channel_id *short_channel_id, struct amount_sat satoshis, const u8 *outscript);
bool fromwire_gossipd_get_txout_reply(const tal_t *ctx, const void *p, struct short_channel_id *short_channel_id, struct amount_sat *satoshis, u8 **outscript);
/* WIRE: GOSSIPD_PAYMENT_FAILURE */
/* master->gossipd an htlc failed with this onion error. */
u8 *towire_gossipd_payment_failure(const tal_t *ctx, const u8 *error);
bool fromwire_gossipd_payment_failure(const tal_t *ctx, const void *p, u8 **error);
/* WIRE: GOSSIPD_OUTPOINT_SPENT */
/* master -> gossipd: a potential funding outpoint was spent */
u8 *towire_gossipd_outpoint_spent(const tal_t *ctx, const struct short_channel_id *short_channel_id);
bool fromwire_gossipd_outpoint_spent(const void *p, struct short_channel_id *short_channel_id);
/* WIRE: GOSSIPD_DEV_SUPPRESS */
/* master -> gossipd: stop gossip timers. */
u8 *towire_gossipd_dev_suppress(const tal_t *ctx);
bool fromwire_gossipd_dev_suppress(const void *p);
/* WIRE: GOSSIPD_DEV_MEMLEAK */
/* master -> gossipd: do you have a memleak? */
u8 *towire_gossipd_dev_memleak(const tal_t *ctx);
bool fromwire_gossipd_dev_memleak(const void *p);
/* WIRE: GOSSIPD_DEV_MEMLEAK_REPLY */
u8 *towire_gossipd_dev_memleak_reply(const tal_t *ctx, bool leak);
bool fromwire_gossipd_dev_memleak_reply(const void *p, bool *leak);
/* WIRE: GOSSIPD_DEV_COMPACT_STORE */
/* master -> gossipd: please rewrite the gossip_store */
u8 *towire_gossipd_dev_compact_store(const tal_t *ctx);
bool fromwire_gossipd_dev_compact_store(const void *p);
/* WIRE: GOSSIPD_DEV_COMPACT_STORE_REPLY */
/* gossipd -> master: ok */
u8 *towire_gossipd_dev_compact_store_reply(const tal_t *ctx, bool success);
bool fromwire_gossipd_dev_compact_store_reply(const void *p, bool *success);
/* WIRE: GOSSIPD_GET_INCOMING_CHANNELS */
/* master -> gossipd: get route_info for our incoming channels */
u8 *towire_gossipd_get_incoming_channels(const tal_t *ctx);
bool fromwire_gossipd_get_incoming_channels(const void *p);
/* WIRE: GOSSIPD_GET_INCOMING_CHANNELS_REPLY */
/* gossipd -> master: here they are. */
u8 *towire_gossipd_get_incoming_channels_reply(const tal_t *ctx, const struct route_info *public_route_info, const bool *public_deadends, const struct route_info *private_route_info, const bool *private_deadends);
bool fromwire_gossipd_get_incoming_channels_reply(const tal_t *ctx, const void *p, struct route_info **public_route_info, bool **public_deadends, struct route_info **private_route_info, bool **private_deadends);
/* WIRE: GOSSIPD_NEW_BLOCKHEIGHT */
/* master -> gossipd: blockheight increased. */
u8 *towire_gossipd_new_blockheight(const tal_t *ctx, u32 blockheight);
bool fromwire_gossipd_new_blockheight(const void *p, u32 *blockheight);
#endif /* LIGHTNING_GOSSIPD_GOSSIPD_WIREGEN_H */
// SHA256STAMP:exp-0-6790ea53b0abf99e5595d11fe496d3ac5fe5b159f15205eca4c34a96856626d8

1218
hsmd/hsmd_wiregen.c

File diff suppressed because it is too large

275
hsmd/hsmd_wiregen.h

@ -0,0 +1,275 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the _csv file it was generated from. */
/* Original template can be found at tools/gen/header_template */
#ifndef LIGHTNING_HSMD_HSMD_WIREGEN_H
#define LIGHTNING_HSMD_HSMD_WIREGEN_H
#include <ccan/tal/tal.h>
#include <wire/tlvstream.h>
#include <wire/wire.h>
#include <bitcoin/chainparams.h>
#include <common/bip32.h>
#include <common/derive_basepoints.h>
#include <common/utxo.h>
#include <bitcoin/psbt.h>
enum hsmd_wire {
/* Clients should not give a bad request but not the HSM's decision to crash. */
WIRE_HSMSTATUS_CLIENT_BAD_REQUEST = 1000,
/* Start the HSM. */
WIRE_HSMD_INIT = 11,
WIRE_HSMD_INIT_REPLY = 111,
/* Get a new HSM FD */
WIRE_HSMD_CLIENT_HSMFD = 9,
/* No content */
WIRE_HSMD_CLIENT_HSMFD_REPLY = 109,
/* Get the basepoints and funding key for this specific channel. */
WIRE_HSMD_GET_CHANNEL_BASEPOINTS = 10,
WIRE_HSMD_GET_CHANNEL_BASEPOINTS_REPLY = 110,
/* Master asks the HSM to sign a node_announcement */
WIRE_HSMD_NODE_ANNOUNCEMENT_SIG_REQ = 6,
WIRE_HSMD_NODE_ANNOUNCEMENT_SIG_REPLY = 106,
/* Sign a withdrawal request */
WIRE_HSMD_SIGN_WITHDRAWAL = 7,
WIRE_HSMD_SIGN_WITHDRAWAL_REPLY = 107,
/* Sign an invoice */
WIRE_HSMD_SIGN_INVOICE = 8,
WIRE_HSMD_SIGN_INVOICE_REPLY = 108,
/* Give me ECDH(node-id-secret */
WIRE_HSMD_ECDH_REQ = 1,
WIRE_HSMD_ECDH_RESP = 100,
WIRE_HSMD_CANNOUNCEMENT_SIG_REQ = 2,
WIRE_HSMD_CANNOUNCEMENT_SIG_REPLY = 102,
WIRE_HSMD_CUPDATE_SIG_REQ = 3,
WIRE_HSMD_CUPDATE_SIG_REPLY = 103,
/* Master asks HSM to sign a commitment transaction. */
WIRE_HSMD_SIGN_COMMITMENT_TX = 5,
WIRE_HSMD_SIGN_COMMITMENT_TX_REPLY = 105,
/* Onchaind asks HSM to sign a spend to-us. Four variants */
/* of keys is derived differently... */
/* FIXME: Have master tell hsmd the keyindex */
WIRE_HSMD_SIGN_DELAYED_PAYMENT_TO_US = 12,
WIRE_HSMD_SIGN_REMOTE_HTLC_TO_US = 13,
WIRE_HSMD_SIGN_PENALTY_TO_US = 14,
/* Onchaind asks HSM to sign a local HTLC success or HTLC timeout tx. */
WIRE_HSMD_SIGN_LOCAL_HTLC_TX = 16,
/* Openingd/channeld asks HSM to sign the other sides' commitment tx. */
WIRE_HSMD_SIGN_REMOTE_COMMITMENT_TX = 19,
/* channeld asks HSM to sign remote HTLC tx. */
WIRE_HSMD_SIGN_REMOTE_HTLC_TX = 20,
/* closingd asks HSM to sign mutual close tx. */
WIRE_HSMD_SIGN_MUTUAL_CLOSE_TX = 21,
/* Reply for all the above requests. */
WIRE_HSMD_SIGN_TX_REPLY = 112,
/* Openingd/channeld/onchaind asks for Nth per_commitment_point */
WIRE_HSMD_GET_PER_COMMITMENT_POINT = 18,
WIRE_HSMD_GET_PER_COMMITMENT_POINT_REPLY = 118,
/* master -> hsmd: do you have a memleak? */
WIRE_HSMD_DEV_MEMLEAK = 33,
WIRE_HSMD_DEV_MEMLEAK_REPLY = 133,
/* channeld asks to check if claimed future commitment_secret is correct. */
WIRE_HSMD_CHECK_FUTURE_SECRET = 22,
WIRE_HSMD_CHECK_FUTURE_SECRET_REPLY = 122,
/* lightningd asks us to sign a string. */
WIRE_HSMD_SIGN_MESSAGE = 23,
WIRE_HSMD_SIGN_MESSAGE_REPLY = 123,
/* lightningd needs to get a scriptPubkey for a utxo with closeinfo */
WIRE_HSMD_GET_OUTPUT_SCRIPTPUBKEY = 24,
WIRE_HSMD_GET_OUTPUT_SCRIPTPUBKEY_REPLY = 124,
};
const char *hsmd_wire_name(int e);
/**
* Determine whether a given message type is defined as a message.
*
* Returns true if the message type is part of the message definitions we have
* generated parsers for, false if it is a custom message that cannot be
* handled internally.
*/
bool hsmd_wire_is_defined(u16 type);
/* WIRE: HSMSTATUS_CLIENT_BAD_REQUEST */
/* Clients should not give a bad request but not the HSM's decision to crash. */
u8 *towire_hsmstatus_client_bad_request(const tal_t *ctx, const struct node_id *id, const wirestring *description, const u8 *msg);
bool fromwire_hsmstatus_client_bad_request(const tal_t *ctx, const void *p, struct node_id *id, wirestring **description, u8 **msg);
/* WIRE: HSMD_INIT */
/* Start the HSM. */
u8 *towire_hsmd_init(const tal_t *ctx, const struct bip32_key_version *bip32_key_version, const struct chainparams *chainparams, const struct secret *hsm_encryption_key, const struct privkey *dev_force_privkey, const struct secret *dev_force_bip32_seed, const struct secrets *dev_force_channel_secrets, const struct sha256 *dev_force_channel_secrets_shaseed);
bool fromwire_hsmd_init(const tal_t *ctx, const void *p, struct bip32_key_version *bip32_key_version, const struct chainparams **chainparams, struct secret **hsm_encryption_key, struct privkey **dev_force_privkey, struct secret **dev_force_bip32_seed, struct secrets **dev_force_channel_secrets, struct sha256 **dev_force_channel_secrets_shaseed);
/* WIRE: HSMD_INIT_REPLY */
u8 *towire_hsmd_init_reply(const tal_t *ctx, const struct node_id *node_id, const struct ext_key *bip32);
bool fromwire_hsmd_init_reply(const void *p, struct node_id *node_id, struct ext_key *bip32);
/* WIRE: HSMD_CLIENT_HSMFD */
/* Get a new HSM FD */
u8 *towire_hsmd_client_hsmfd(const tal_t *ctx, const struct node_id *id, u64 dbid, u64 capabilities);
bool fromwire_hsmd_client_hsmfd(const void *p, struct node_id *id, u64 *dbid, u64 *capabilities);
/* WIRE: HSMD_CLIENT_HSMFD_REPLY */
/* No content */
u8 *towire_hsmd_client_hsmfd_reply(const tal_t *ctx);
bool fromwire_hsmd_client_hsmfd_reply(const void *p);
/* WIRE: HSMD_GET_CHANNEL_BASEPOINTS */
/* Get the basepoints and funding key for this specific channel. */
u8 *towire_hsmd_get_channel_basepoints(const tal_t *ctx, const struct node_id *peerid, u64 dbid);
bool fromwire_hsmd_get_channel_basepoints(const void *p, struct node_id *peerid, u64 *dbid);
/* WIRE: HSMD_GET_CHANNEL_BASEPOINTS_REPLY */
u8 *towire_hsmd_get_channel_basepoints_reply(const tal_t *ctx, const struct basepoints *basepoints, const struct pubkey *funding_pubkey);
bool fromwire_hsmd_get_channel_basepoints_reply(const void *p, struct basepoints *basepoints, struct pubkey *funding_pubkey);
/* WIRE: HSMD_NODE_ANNOUNCEMENT_SIG_REQ */
/* Master asks the HSM to sign a node_announcement */
u8 *towire_hsmd_node_announcement_sig_req(const tal_t *ctx, const u8 *announcement);
bool fromwire_hsmd_node_announcement_sig_req(const tal_t *ctx, const void *p, u8 **announcement);
/* WIRE: HSMD_NODE_ANNOUNCEMENT_SIG_REPLY */
u8 *towire_hsmd_node_announcement_sig_reply(const tal_t *ctx, const secp256k1_ecdsa_signature *signature);
bool fromwire_hsmd_node_announcement_sig_reply(const void *p, secp256k1_ecdsa_signature *signature);
/* WIRE: HSMD_SIGN_WITHDRAWAL */
/* Sign a withdrawal request */
u8 *towire_hsmd_sign_withdrawal(const tal_t *ctx, const struct utxo **inputs, const struct wally_psbt *psbt);
bool fromwire_hsmd_sign_withdrawal(const tal_t *ctx, const void *p, struct utxo ***inputs, struct wally_psbt **psbt);
/* WIRE: HSMD_SIGN_WITHDRAWAL_REPLY */
u8 *towire_hsmd_sign_withdrawal_reply(const tal_t *ctx, const struct wally_psbt *psbt);
bool fromwire_hsmd_sign_withdrawal_reply(const tal_t *ctx, const void *p, struct wally_psbt **psbt);
/* WIRE: HSMD_SIGN_INVOICE */
/* Sign an invoice */
u8 *towire_hsmd_sign_invoice(const tal_t *ctx, const u8 *u5bytes, const u8 *hrp);
bool fromwire_hsmd_sign_invoice(const tal_t *ctx, const void *p, u8 **u5bytes, u8 **hrp);
/* WIRE: HSMD_SIGN_INVOICE_REPLY */
u8 *towire_hsmd_sign_invoice_reply(const tal_t *ctx, const secp256k1_ecdsa_recoverable_signature *sig);
bool fromwire_hsmd_sign_invoice_reply(const void *p, secp256k1_ecdsa_recoverable_signature *sig);
/* WIRE: HSMD_ECDH_REQ */
/* Give me ECDH(node-id-secret */
u8 *towire_hsmd_ecdh_req(const tal_t *ctx, const struct pubkey *point);
bool fromwire_hsmd_ecdh_req(const void *p, struct pubkey *point);
/* WIRE: HSMD_ECDH_RESP */
u8 *towire_hsmd_ecdh_resp(const tal_t *ctx, const struct secret *ss);
bool fromwire_hsmd_ecdh_resp(const void *p, struct secret *ss);
/* WIRE: HSMD_CANNOUNCEMENT_SIG_REQ */
u8 *towire_hsmd_cannouncement_sig_req(const tal_t *ctx, const u8 *ca);
bool fromwire_hsmd_cannouncement_sig_req(const tal_t *ctx, const void *p, u8 **ca);
/* WIRE: HSMD_CANNOUNCEMENT_SIG_REPLY */
u8 *towire_hsmd_cannouncement_sig_reply(const tal_t *ctx, const secp256k1_ecdsa_signature *node_signature, const secp256k1_ecdsa_signature *bitcoin_signature);
bool fromwire_hsmd_cannouncement_sig_reply(const void *p, secp256k1_ecdsa_signature *node_signature, secp256k1_ecdsa_signature *bitcoin_signature);
/* WIRE: HSMD_CUPDATE_SIG_REQ */
u8 *towire_hsmd_cupdate_sig_req(const tal_t *ctx, const u8 *cu);
bool fromwire_hsmd_cupdate_sig_req(const tal_t *ctx, const void *p, u8 **cu);
/* WIRE: HSMD_CUPDATE_SIG_REPLY */
u8 *towire_hsmd_cupdate_sig_reply(const tal_t *ctx, const u8 *cu);
bool fromwire_hsmd_cupdate_sig_reply(const tal_t *ctx, const void *p, u8 **cu);
/* WIRE: HSMD_SIGN_COMMITMENT_TX */
/* Master asks HSM to sign a commitment transaction. */
u8 *towire_hsmd_sign_commitment_tx(const tal_t *ctx, const struct node_id *peer_id, u64 channel_dbid, const struct bitcoin_tx *tx, const struct pubkey *remote_funding_key);
bool fromwire_hsmd_sign_commitment_tx(const tal_t *ctx, const void *p, struct node_id *peer_id, u64 *channel_dbid, struct bitcoin_tx **tx, struct pubkey *remote_funding_key);
/* WIRE: HSMD_SIGN_COMMITMENT_TX_REPLY */
u8 *towire_hsmd_sign_commitment_tx_reply(const tal_t *ctx, const struct bitcoin_signature *sig);
bool fromwire_hsmd_sign_commitment_tx_reply(const void *p, struct bitcoin_signature *sig);
/* WIRE: HSMD_SIGN_DELAYED_PAYMENT_TO_US */
/* Onchaind asks HSM to sign a spend to-us. Four variants */
/* of keys is derived differently... */
/* FIXME: Have master tell hsmd the keyindex */
u8 *towire_hsmd_sign_delayed_payment_to_us(const tal_t *ctx, u64 commit_num, const struct bitcoin_tx *tx, const u8 *wscript);
bool fromwire_hsmd_sign_delayed_payment_to_us(const tal_t *ctx, const void *p, u64 *commit_num, struct bitcoin_tx **tx, u8 **wscript);
/* WIRE: HSMD_SIGN_REMOTE_HTLC_TO_US */
u8 *towire_hsmd_sign_remote_htlc_to_us(const tal_t *ctx, const struct pubkey *remote_per_commitment_point, const struct bitcoin_tx *tx, const u8 *wscript, bool option_anchor_outputs);
bool fromwire_hsmd_sign_remote_htlc_to_us(const tal_t *ctx, const void *p, struct pubkey *remote_per_commitment_point, struct bitcoin_tx **tx, u8 **wscript, bool *option_anchor_outputs);
/* WIRE: HSMD_SIGN_PENALTY_TO_US */
u8 *towire_hsmd_sign_penalty_to_us(const tal_t *ctx, const struct secret *revocation_secret, const struct bitcoin_tx *tx, const u8 *wscript);
bool fromwire_hsmd_sign_penalty_to_us(const tal_t *ctx, const void *p, struct secret *revocation_secret, struct bitcoin_tx **tx, u8 **wscript);
/* WIRE: HSMD_SIGN_LOCAL_HTLC_TX */
/* Onchaind asks HSM to sign a local HTLC success or HTLC timeout tx. */
u8 *towire_hsmd_sign_local_htlc_tx(const tal_t *ctx, u64 commit_num, const struct bitcoin_tx *tx, const u8 *wscript, bool option_anchor_outputs);
bool fromwire_hsmd_sign_local_htlc_tx(const tal_t *ctx, const void *p, u64 *commit_num, struct bitcoin_tx **tx, u8 **wscript, bool *option_anchor_outputs);
/* WIRE: HSMD_SIGN_REMOTE_COMMITMENT_TX */
/* Openingd/channeld asks HSM to sign the other sides' commitment tx. */
u8 *towire_hsmd_sign_remote_commitment_tx(const tal_t *ctx, const struct bitcoin_tx *tx, const struct pubkey *remote_funding_key, const struct pubkey *remote_per_commit, bool option_static_remotekey);
bool fromwire_hsmd_sign_remote_commitment_tx(const tal_t *ctx, const void *p, struct bitcoin_tx **tx, struct pubkey *remote_funding_key, struct pubkey *remote_per_commit, bool *option_static_remotekey);
/* WIRE: HSMD_SIGN_REMOTE_HTLC_TX */
/* channeld asks HSM to sign remote HTLC tx. */
u8 *towire_hsmd_sign_remote_htlc_tx(const tal_t *ctx, const struct bitcoin_tx *tx, const u8 *wscript, const struct pubkey *remote_per_commit_point, bool option_anchor_outputs);
bool fromwire_hsmd_sign_remote_htlc_tx(const tal_t *ctx, const void *p, struct bitcoin_tx **tx, u8 **wscript, struct pubkey *remote_per_commit_point, bool *option_anchor_outputs);
/* WIRE: HSMD_SIGN_MUTUAL_CLOSE_TX */
/* closingd asks HSM to sign mutual close tx. */
u8 *towire_hsmd_sign_mutual_close_tx(const tal_t *ctx, const struct bitcoin_tx *tx, const struct pubkey *remote_funding_key);
bool fromwire_hsmd_sign_mutual_close_tx(const tal_t *ctx, const void *p, struct bitcoin_tx **tx, struct pubkey *remote_funding_key);
/* WIRE: HSMD_SIGN_TX_REPLY */
/* Reply for all the above requests. */
u8 *towire_hsmd_sign_tx_reply(const tal_t *ctx, const struct bitcoin_signature *sig);
bool fromwire_hsmd_sign_tx_reply(const void *p, struct bitcoin_signature *sig);
/* WIRE: HSMD_GET_PER_COMMITMENT_POINT */
/* Openingd/channeld/onchaind asks for Nth per_commitment_point */
u8 *towire_hsmd_get_per_commitment_point(const tal_t *ctx, u64 n);
bool fromwire_hsmd_get_per_commitment_point(const void *p, u64 *n);
/* WIRE: HSMD_GET_PER_COMMITMENT_POINT_REPLY */
u8 *towire_hsmd_get_per_commitment_point_reply(const tal_t *ctx, const struct pubkey *per_commitment_point, const struct secret *old_commitment_secret);
bool fromwire_hsmd_get_per_commitment_point_reply(const tal_t *ctx, const void *p, struct pubkey *per_commitment_point, struct secret **old_commitment_secret);
/* WIRE: HSMD_DEV_MEMLEAK */
/* master -> hsmd: do you have a memleak? */
u8 *towire_hsmd_dev_memleak(const tal_t *ctx);
bool fromwire_hsmd_dev_memleak(const void *p);
/* WIRE: HSMD_DEV_MEMLEAK_REPLY */
u8 *towire_hsmd_dev_memleak_reply(const tal_t *ctx, bool leak);
bool fromwire_hsmd_dev_memleak_reply(const void *p, bool *leak);
/* WIRE: HSMD_CHECK_FUTURE_SECRET */
/* channeld asks to check if claimed future commitment_secret is correct. */
u8 *towire_hsmd_check_future_secret(const tal_t *ctx, u64 n, const struct secret *commitment_secret);
bool fromwire_hsmd_check_future_secret(const void *p, u64 *n, struct secret *commitment_secret);
/* WIRE: HSMD_CHECK_FUTURE_SECRET_REPLY */
u8 *towire_hsmd_check_future_secret_reply(const tal_t *ctx, bool correct);
bool fromwire_hsmd_check_future_secret_reply(const void *p, bool *correct);
/* WIRE: HSMD_SIGN_MESSAGE */
/* lightningd asks us to sign a string. */
u8 *towire_hsmd_sign_message(const tal_t *ctx, const u8 *msg);
bool fromwire_hsmd_sign_message(const tal_t *ctx, const void *p, u8 **msg);
/* WIRE: HSMD_SIGN_MESSAGE_REPLY */
u8 *towire_hsmd_sign_message_reply(const tal_t *ctx, const secp256k1_ecdsa_recoverable_signature *sig);
bool fromwire_hsmd_sign_message_reply(const void *p, secp256k1_ecdsa_recoverable_signature *sig);
/* WIRE: HSMD_GET_OUTPUT_SCRIPTPUBKEY */
/* lightningd needs to get a scriptPubkey for a utxo with closeinfo */
u8 *towire_hsmd_get_output_scriptpubkey(const tal_t *ctx, u64 channel_id, const struct node_id *peer_id, const struct pubkey *commitment_point);
bool fromwire_hsmd_get_output_scriptpubkey(const tal_t *ctx, const void *p, u64 *channel_id, struct node_id *peer_id, struct pubkey **commitment_point);
/* WIRE: HSMD_GET_OUTPUT_SCRIPTPUBKEY_REPLY */
u8 *towire_hsmd_get_output_scriptpubkey_reply(const tal_t *ctx, const u8 *script);
bool fromwire_hsmd_get_output_scriptpubkey_reply(const tal_t *ctx, const void *p, u8 **script);
#endif /* LIGHTNING_HSMD_HSMD_WIREGEN_H */
// SHA256STAMP:exp-0-fd33f5b428d1806da30507ca94c8e34f3c7c0023ecf87c55aa2867a403d5a20c

630
onchaind/onchaind_wiregen.c

@ -0,0 +1,630 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the .csv file it was generated from. */
/* Original template can be found at tools/gen/impl_template */
#include <onchaind/onchaind_wiregen.h>
#include <assert.h>
#include <ccan/array_size/array_size.h>
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/utils.h>
#include <stdio.h>
#ifndef SUPERVERBOSE
#define SUPERVERBOSE(...)
#endif
const char *onchaind_wire_name(int e)
{
static char invalidbuf[sizeof("INVALID ") + STR_MAX_CHARS(e)];
switch ((enum onchaind_wire)e) {
case WIRE_ONCHAIND_INIT: return "WIRE_ONCHAIND_INIT";
case WIRE_ONCHAIND_HTLC: return "WIRE_ONCHAIND_HTLC";
case WIRE_ONCHAIND_INIT_REPLY: return "WIRE_ONCHAIND_INIT_REPLY";
case WIRE_ONCHAIND_BROADCAST_TX: return "WIRE_ONCHAIND_BROADCAST_TX";
case WIRE_ONCHAIND_SPENT: return "WIRE_ONCHAIND_SPENT";
case WIRE_ONCHAIND_DEPTH: return "WIRE_ONCHAIND_DEPTH";
case WIRE_ONCHAIND_UNWATCH_TX: return "WIRE_ONCHAIND_UNWATCH_TX";
case WIRE_ONCHAIND_KNOWN_PREIMAGE: return "WIRE_ONCHAIND_KNOWN_PREIMAGE";
case WIRE_ONCHAIND_EXTRACTED_PREIMAGE: return "WIRE_ONCHAIND_EXTRACTED_PREIMAGE";
case WIRE_ONCHAIND_MISSING_HTLC_OUTPUT: return "WIRE_ONCHAIND_MISSING_HTLC_OUTPUT";
case WIRE_ONCHAIND_HTLC_TIMEOUT: return "WIRE_ONCHAIND_HTLC_TIMEOUT";
case WIRE_ONCHAIND_ALL_IRREVOCABLY_RESOLVED: return "WIRE_ONCHAIND_ALL_IRREVOCABLY_RESOLVED";
case WIRE_ONCHAIND_ADD_UTXO: return "WIRE_ONCHAIND_ADD_UTXO";
case WIRE_ONCHAIND_DEV_MEMLEAK: return "WIRE_ONCHAIND_DEV_MEMLEAK";
case WIRE_ONCHAIND_DEV_MEMLEAK_REPLY: return "WIRE_ONCHAIND_DEV_MEMLEAK_REPLY";
case WIRE_ONCHAIND_ANNOTATE_TXOUT: return "WIRE_ONCHAIND_ANNOTATE_TXOUT";
case WIRE_ONCHAIND_ANNOTATE_TXIN: return "WIRE_ONCHAIND_ANNOTATE_TXIN";
case WIRE_ONCHAIND_NOTIFY_COIN_MVT: return "WIRE_ONCHAIND_NOTIFY_COIN_MVT";
}
snprintf(invalidbuf, sizeof(invalidbuf), "INVALID %i", e);
return invalidbuf;
}
bool onchaind_wire_is_defined(u16 type)
{
switch ((enum onchaind_wire)type) {
case WIRE_ONCHAIND_INIT:;
case WIRE_ONCHAIND_HTLC:;
case WIRE_ONCHAIND_INIT_REPLY:;
case WIRE_ONCHAIND_BROADCAST_TX:;
case WIRE_ONCHAIND_SPENT:;
case WIRE_ONCHAIND_DEPTH:;
case WIRE_ONCHAIND_UNWATCH_TX:;
case WIRE_ONCHAIND_KNOWN_PREIMAGE:;
case WIRE_ONCHAIND_EXTRACTED_PREIMAGE:;
case WIRE_ONCHAIND_MISSING_HTLC_OUTPUT:;
case WIRE_ONCHAIND_HTLC_TIMEOUT:;
case WIRE_ONCHAIND_ALL_IRREVOCABLY_RESOLVED:;
case WIRE_ONCHAIND_ADD_UTXO:;
case WIRE_ONCHAIND_DEV_MEMLEAK:;
case WIRE_ONCHAIND_DEV_MEMLEAK_REPLY:;
case WIRE_ONCHAIND_ANNOTATE_TXOUT:;
case WIRE_ONCHAIND_ANNOTATE_TXIN:;
case WIRE_ONCHAIND_NOTIFY_COIN_MVT:;
return true;
}
return false;
}
/* WIRE: ONCHAIND_INIT */
/* Begin! Here's the onchain tx which spends funding tx */
u8 *towire_onchaind_init(const tal_t *ctx, const struct shachain *shachain, const struct chainparams *chainparams, struct amount_sat funding_amount_satoshi, struct amount_msat our_msat, const struct pubkey *old_remote_per_commitment_point, const struct pubkey *remote_per_commitment_point, u32 local_to_self_delay, u32 remote_to_self_delay, u32 delayed_to_us_feerate, u32 htlc_feerate, u32 penalty_feerate, struct amount_sat local_dust_limit_satoshi, const struct bitcoin_txid *our_broadcast_txid, const u8 *local_scriptpubkey, const u8 *remote_scriptpubkey, const struct pubkey *ourwallet_pubkey, enum side opener, const struct basepoints *local_basepoints, const struct basepoints *remote_basepoints, const struct tx_parts *tx_parts, u32 locktime, u32 tx_blockheight, u32 reasonable_depth, const struct bitcoin_signature *htlc_signature, u64 num_htlcs, u32 min_possible_feerate, u32 max_possible_feerate, const struct pubkey *possible_remote_per_commit_point, const struct pubkey *local_funding_pubkey, const struct pubkey *remote_funding_pubkey, bool option_static_remotekey, bool option_anchor_outputs, bool is_replay)
{
u16 local_scriptpubkey_len = tal_count(local_scriptpubkey);
u16 remote_scriptpubkey_len = tal_count(remote_scriptpubkey);
u16 num_htlc_sigs = tal_count(htlc_signature);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_ONCHAIND_INIT);
towire_shachain(&p, shachain);
/* This needs to be set explicitly since the same message also contains a */
/* transaction that we need to parse correctly. */
towire_chainparams(&p, chainparams);
towire_amount_sat(&p, funding_amount_satoshi);
/* Our current balance (of funding amount */
towire_amount_msat(&p, our_msat);
/* Remote per commit point for committed tx. */
towire_pubkey(&p, old_remote_per_commitment_point);
/* Remote per commit point for current tx (needed if we haven't got revoke_and_ack yet). */
towire_pubkey(&p, remote_per_commitment_point);
towire_u32(&p, local_to_self_delay);
towire_u32(&p, remote_to_self_delay);
towire_u32(&p, delayed_to_us_feerate);
towire_u32(&p, htlc_feerate);
towire_u32(&p, penalty_feerate);
towire_amount_sat(&p, local_dust_limit_satoshi);
/* Gives an easy way to tell if it's our unilateral close or theirs... */
towire_bitcoin_txid(&p, our_broadcast_txid);
towire_u16(&p, local_scriptpubkey_len);
towire_u8_array(&p, local_scriptpubkey, local_scriptpubkey_len);
towire_u16(&p, remote_scriptpubkey_len);
towire_u8_array(&p, remote_scriptpubkey, remote_scriptpubkey_len);
towire_pubkey(&p, ourwallet_pubkey);
/* We need these two for commit number obscurer */
towire_side(&p, opener);
towire_basepoints(&p, local_basepoints);
towire_basepoints(&p, remote_basepoints);
towire_tx_parts(&p, tx_parts);
towire_u32(&p, locktime);
towire_u32(&p, tx_blockheight);
towire_u32(&p, reasonable_depth);
towire_u16(&p, num_htlc_sigs);
for (size_t i = 0; i < num_htlc_sigs; i++)
towire_bitcoin_signature(&p, htlc_signature + i);
towire_u64(&p, num_htlcs);
towire_u32(&p, min_possible_feerate);
towire_u32(&p, max_possible_feerate);
if (!possible_remote_per_commit_point)
towire_bool(&p, false);
else {
towire_bool(&p, true);
towire_pubkey(&p, possible_remote_per_commit_point);
}
towire_pubkey(&p, local_funding_pubkey);
towire_pubkey(&p, remote_funding_pubkey);
towire_bool(&p, option_static_remotekey);
towire_bool(&p, option_anchor_outputs);
towire_bool(&p, is_replay);
return memcheck(p, tal_count(p));
}
bool fromwire_onchaind_init(const tal_t *ctx, const void *p, struct shachain *shachain, const struct chainparams **chainparams, struct amount_sat *funding_amount_satoshi, struct amount_msat *our_msat, struct pubkey *old_remote_per_commitment_point, struct pubkey *remote_per_commitment_point, u32 *local_to_self_delay, u32 *remote_to_self_delay, u32 *delayed_to_us_feerate, u32 *htlc_feerate, u32 *penalty_feerate, struct amount_sat *local_dust_limit_satoshi, struct bitcoin_txid *our_broadcast_txid, u8 **local_scriptpubkey, u8 **remote_scriptpubkey, struct pubkey *ourwallet_pubkey, enum side *opener, struct basepoints *local_basepoints, struct basepoints *remote_basepoints, struct tx_parts **tx_parts, u32 *locktime, u32 *tx_blockheight, u32 *reasonable_depth, struct bitcoin_signature **htlc_signature, u64 *num_htlcs, u32 *min_possible_feerate, u32 *max_possible_feerate, struct pubkey **possible_remote_per_commit_point, struct pubkey *local_funding_pubkey, struct pubkey *remote_funding_pubkey, bool *option_static_remotekey, bool *option_anchor_outputs, bool *is_replay)
{
u16 local_scriptpubkey_len;
u16 remote_scriptpubkey_len;
u16 num_htlc_sigs;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_ONCHAIND_INIT)
return false;
fromwire_shachain(&cursor, &plen, shachain);
/* This needs to be set explicitly since the same message also contains a */
/* transaction that we need to parse correctly. */
fromwire_chainparams(&cursor, &plen, chainparams);
*funding_amount_satoshi = fromwire_amount_sat(&cursor, &plen);
/* Our current balance (of funding amount */
*our_msat = fromwire_amount_msat(&cursor, &plen);
/* Remote per commit point for committed tx. */
fromwire_pubkey(&cursor, &plen, old_remote_per_commitment_point);
/* Remote per commit point for current tx (needed if we haven't got revoke_and_ack yet). */
fromwire_pubkey(&cursor, &plen, remote_per_commitment_point);
*local_to_self_delay = fromwire_u32(&cursor, &plen);
*remote_to_self_delay = fromwire_u32(&cursor, &plen);
*delayed_to_us_feerate = fromwire_u32(&cursor, &plen);
*htlc_feerate = fromwire_u32(&cursor, &plen);
*penalty_feerate = fromwire_u32(&cursor, &plen);
*local_dust_limit_satoshi = fromwire_amount_sat(&cursor, &plen);
/* Gives an easy way to tell if it's our unilateral close or theirs... */
fromwire_bitcoin_txid(&cursor, &plen, our_broadcast_txid);
local_scriptpubkey_len = fromwire_u16(&cursor, &plen);
// 2nd case local_scriptpubkey
*local_scriptpubkey = local_scriptpubkey_len ? tal_arr(ctx, u8, local_scriptpubkey_len) : NULL;
fromwire_u8_array(&cursor, &plen, *local_scriptpubkey, local_scriptpubkey_len);
remote_scriptpubkey_len = fromwire_u16(&cursor, &plen);
// 2nd case remote_scriptpubkey
*remote_scriptpubkey = remote_scriptpubkey_len ? tal_arr(ctx, u8, remote_scriptpubkey_len) : NULL;
fromwire_u8_array(&cursor, &plen, *remote_scriptpubkey, remote_scriptpubkey_len);
fromwire_pubkey(&cursor, &plen, ourwallet_pubkey);
/* We need these two for commit number obscurer */
*opener = fromwire_side(&cursor, &plen);
fromwire_basepoints(&cursor, &plen, local_basepoints);
fromwire_basepoints(&cursor, &plen, remote_basepoints);
*tx_parts = fromwire_tx_parts(ctx, &cursor, &plen);
*locktime = fromwire_u32(&cursor, &plen);
*tx_blockheight = fromwire_u32(&cursor, &plen);
*reasonable_depth = fromwire_u32(&cursor, &plen);
num_htlc_sigs = fromwire_u16(&cursor, &plen);
// 2nd case htlc_signature
*htlc_signature = num_htlc_sigs ? tal_arr(ctx, struct bitcoin_signature, num_htlc_sigs) : NULL;
for (size_t i = 0; i < num_htlc_sigs; i++)
fromwire_bitcoin_signature(&cursor, &plen, *htlc_signature + i);
*num_htlcs = fromwire_u64(&cursor, &plen);
*min_possible_feerate = fromwire_u32(&cursor, &plen);
*max_possible_feerate = fromwire_u32(&cursor, &plen);
if (!fromwire_bool(&cursor, &plen))
*possible_remote_per_commit_point = NULL;
else {
*possible_remote_per_commit_point = tal(ctx, struct pubkey);
fromwire_pubkey(&cursor, &plen, *possible_remote_per_commit_point);
}
fromwire_pubkey(&cursor, &plen, local_funding_pubkey);
fromwire_pubkey(&cursor, &plen, remote_funding_pubkey);
*option_static_remotekey = fromwire_bool(&cursor, &plen);
*option_anchor_outputs = fromwire_bool(&cursor, &plen);
*is_replay = fromwire_bool(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: ONCHAIND_HTLC */
/* This is all the HTLCs: one per message */
u8 *towire_onchaind_htlc(const tal_t *ctx, const struct htlc_stub *htlc, bool tell_if_missing, bool tell_immediately)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_ONCHAIND_HTLC);
towire_htlc_stub(&p, htlc);
/* If it's not in the commitment tx */
towire_bool(&p, tell_if_missing);
towire_bool(&p, tell_immediately);
return memcheck(p, tal_count(p));
}
bool fromwire_onchaind_htlc(const void *p, struct htlc_stub *htlc, bool *tell_if_missing, bool *tell_immediately)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_ONCHAIND_HTLC)
return false;
fromwire_htlc_stub(&cursor, &plen, htlc);
/* If it's not in the commitment tx */
*tell_if_missing = fromwire_bool(&cursor, &plen);
*tell_immediately = fromwire_bool(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: ONCHAIND_INIT_REPLY */
/* This says we're ready; give us preimages. */
u8 *towire_onchaind_init_reply(const tal_t *ctx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_ONCHAIND_INIT_REPLY);
return memcheck(p, tal_count(p));
}
bool fromwire_onchaind_init_reply(const void *p)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_ONCHAIND_INIT_REPLY)
return false;
return cursor != NULL;
}
/* WIRE: ONCHAIND_BROADCAST_TX */
/* onchaind->master: Send out a tx. */
u8 *towire_onchaind_broadcast_tx(const tal_t *ctx, const struct bitcoin_tx *tx, enum wallet_tx_type type)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_ONCHAIND_BROADCAST_TX);
towire_bitcoin_tx(&p, tx);
towire_wallet_tx_type(&p, type);
return memcheck(p, tal_count(p));
}
bool fromwire_onchaind_broadcast_tx(const tal_t *ctx, const void *p, struct bitcoin_tx **tx, enum wallet_tx_type *type)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_ONCHAIND_BROADCAST_TX)
return false;
*tx = fromwire_bitcoin_tx(ctx, &cursor, &plen);
*type = fromwire_wallet_tx_type(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: ONCHAIND_SPENT */
/* master->onchaind: Notifier that an output has been spent by input_num of tx. */
u8 *towire_onchaind_spent(const tal_t *ctx, const struct tx_parts *tx, u32 input_num, u32 blockheight, bool is_replay)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_ONCHAIND_SPENT);
towire_tx_parts(&p, tx);
towire_u32(&p, input_num);
towire_u32(&p, blockheight);
towire_bool(&p, is_replay);
return memcheck(p, tal_count(p));
}
bool fromwire_onchaind_spent(const tal_t *ctx, const void *p, struct tx_parts **tx, u32 *input_num, u32 *blockheight, bool *is_replay)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_ONCHAIND_SPENT)
return false;
*tx = fromwire_tx_parts(ctx, &cursor, &plen);
*input_num = fromwire_u32(&cursor, &plen);
*blockheight = fromwire_u32(&cursor, &plen);
*is_replay = fromwire_bool(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: ONCHAIND_DEPTH */
/* master->onchaind: We will receive more than one of these */
u8 *towire_onchaind_depth(const tal_t *ctx, const struct bitcoin_txid *txid, u32 depth, bool is_replay)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_ONCHAIND_DEPTH);
towire_bitcoin_txid(&p, txid);
towire_u32(&p, depth);
towire_bool(&p, is_replay);
return memcheck(p, tal_count(p));
}
bool fromwire_onchaind_depth(const void *p, struct bitcoin_txid *txid, u32 *depth, bool *is_replay)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_ONCHAIND_DEPTH)
return false;
fromwire_bitcoin_txid(&cursor, &plen, txid);
*depth = fromwire_u32(&cursor, &plen);
*is_replay = fromwire_bool(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: ONCHAIND_UNWATCH_TX */
/* onchaind->master: We don't want to watch this tx */
u8 *towire_onchaind_unwatch_tx(const tal_t *ctx, const struct bitcoin_txid *txid)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_ONCHAIND_UNWATCH_TX);
towire_bitcoin_txid(&p, txid);
return memcheck(p, tal_count(p));
}
bool fromwire_onchaind_unwatch_tx(const void *p, struct bitcoin_txid *txid)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_ONCHAIND_UNWATCH_TX)
return false;
fromwire_bitcoin_txid(&cursor, &plen, txid);
return cursor != NULL;
}
/* WIRE: ONCHAIND_KNOWN_PREIMAGE */
/* master->onchaind: We know HTLC preimage */
u8 *towire_onchaind_known_preimage(const tal_t *ctx, const struct preimage *preimage, bool is_replay)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_ONCHAIND_KNOWN_PREIMAGE);
towire_preimage(&p, preimage);
towire_bool(&p, is_replay);
return memcheck(p, tal_count(p));
}
bool fromwire_onchaind_known_preimage(const void *p, struct preimage *preimage, bool *is_replay)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_ONCHAIND_KNOWN_PREIMAGE)
return false;
fromwire_preimage(&cursor, &plen, preimage);
*is_replay = fromwire_bool(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: ONCHAIND_EXTRACTED_PREIMAGE */
/* onchaind->master: We discovered HTLC preimage */
u8 *towire_onchaind_extracted_preimage(const tal_t *ctx, const struct preimage *preimage)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_ONCHAIND_EXTRACTED_PREIMAGE);
towire_preimage(&p, preimage);
return memcheck(p, tal_count(p));
}
bool fromwire_onchaind_extracted_preimage(const void *p, struct preimage *preimage)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_ONCHAIND_EXTRACTED_PREIMAGE)
return false;
fromwire_preimage(&cursor, &plen, preimage);
return cursor != NULL;
}
/* WIRE: ONCHAIND_MISSING_HTLC_OUTPUT */
/* onchaind->master: this HTLC was missing from commit tx. */
u8 *towire_onchaind_missing_htlc_output(const tal_t *ctx, const struct htlc_stub *htlc)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_ONCHAIND_MISSING_HTLC_OUTPUT);
towire_htlc_stub(&p, htlc);
return memcheck(p, tal_count(p));
}
bool fromwire_onchaind_missing_htlc_output(const void *p, struct htlc_stub *htlc)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_ONCHAIND_MISSING_HTLC_OUTPUT)
return false;
fromwire_htlc_stub(&cursor, &plen, htlc);
return cursor != NULL;
}
/* WIRE: ONCHAIND_HTLC_TIMEOUT */
/* onchaind->master: this HTLC has timed out (after reasonable_depth) */
u8 *towire_onchaind_htlc_timeout(const tal_t *ctx, const struct htlc_stub *htlc)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_ONCHAIND_HTLC_TIMEOUT);
towire_htlc_stub(&p, htlc);
return memcheck(p, tal_count(p));
}
bool fromwire_onchaind_htlc_timeout(const void *p, struct htlc_stub *htlc)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_ONCHAIND_HTLC_TIMEOUT)
return false;
fromwire_htlc_stub(&cursor, &plen, htlc);
return cursor != NULL;
}
/* WIRE: ONCHAIND_ALL_IRREVOCABLY_RESOLVED */
/* onchaind->master: this peer can be forgotten */
u8 *towire_onchaind_all_irrevocably_resolved(const tal_t *ctx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_ONCHAIND_ALL_IRREVOCABLY_RESOLVED);
return memcheck(p, tal_count(p));
}
bool fromwire_onchaind_all_irrevocably_resolved(const void *p)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_ONCHAIND_ALL_IRREVOCABLY_RESOLVED)
return false;
return cursor != NULL;
}
/* WIRE: ONCHAIND_ADD_UTXO */
/* onchaind->master: hey */
u8 *towire_onchaind_add_utxo(const tal_t *ctx, const struct bitcoin_txid *prev_out_tx, u32 prev_out_index, const struct pubkey *per_commit_point, struct amount_sat value, u32 blockheight, const u8 *scriptpubkey)
{
u16 len = tal_count(scriptpubkey);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_ONCHAIND_ADD_UTXO);
towire_bitcoin_txid(&p, prev_out_tx);
towire_u32(&p, prev_out_index);
if (!per_commit_point)
towire_bool(&p, false);
else {
towire_bool(&p, true);
towire_pubkey(&p, per_commit_point);
}
towire_amount_sat(&p, value);
towire_u32(&p, blockheight);
towire_u16(&p, len);
towire_u8_array(&p, scriptpubkey, len);
return memcheck(p, tal_count(p));
}
bool fromwire_onchaind_add_utxo(const tal_t *ctx, const void *p, struct bitcoin_txid *prev_out_tx, u32 *prev_out_index, struct pubkey **per_commit_point, struct amount_sat *value, u32 *blockheight, u8 **scriptpubkey)
{
u16 len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_ONCHAIND_ADD_UTXO)
return false;
fromwire_bitcoin_txid(&cursor, &plen, prev_out_tx);
*prev_out_index = fromwire_u32(&cursor, &plen);
if (!fromwire_bool(&cursor, &plen))
*per_commit_point = NULL;
else {
*per_commit_point = tal(ctx, struct pubkey);
fromwire_pubkey(&cursor, &plen, *per_commit_point);
}
*value = fromwire_amount_sat(&cursor, &plen);
*blockheight = fromwire_u32(&cursor, &plen);
len = fromwire_u16(&cursor, &plen);
// 2nd case scriptpubkey
*scriptpubkey = len ? tal_arr(ctx, u8, len) : NULL;
fromwire_u8_array(&cursor, &plen, *scriptpubkey, len);
return cursor != NULL;
}
/* WIRE: ONCHAIND_DEV_MEMLEAK */
/* master -> onchaind: do you have a memleak? */
u8 *towire_onchaind_dev_memleak(const tal_t *ctx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_ONCHAIND_DEV_MEMLEAK);
return memcheck(p, tal_count(p));
}
bool fromwire_onchaind_dev_memleak(const void *p)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_ONCHAIND_DEV_MEMLEAK)
return false;
return cursor != NULL;
}
/* WIRE: ONCHAIND_DEV_MEMLEAK_REPLY */
u8 *towire_onchaind_dev_memleak_reply(const tal_t *ctx, bool leak)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_ONCHAIND_DEV_MEMLEAK_REPLY);
towire_bool(&p, leak);
return memcheck(p, tal_count(p));
}
bool fromwire_onchaind_dev_memleak_reply(const void *p, bool *leak)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_ONCHAIND_DEV_MEMLEAK_REPLY)
return false;
*leak = fromwire_bool(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: ONCHAIND_ANNOTATE_TXOUT */
/* Tell the main daemon what we've been watching */
/* that we tracked automatically but only onchaind knows how to classify their */
/* transactions. */
u8 *towire_onchaind_annotate_txout(const tal_t *ctx, const struct bitcoin_txid *txid, u32 outnum, enum wallet_tx_type type)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_ONCHAIND_ANNOTATE_TXOUT);
towire_bitcoin_txid(&p, txid);
towire_u32(&p, outnum);
towire_wallet_tx_type(&p, type);
return memcheck(p, tal_count(p));
}
bool fromwire_onchaind_annotate_txout(const void *p, struct bitcoin_txid *txid, u32 *outnum, enum wallet_tx_type *type)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_ONCHAIND_ANNOTATE_TXOUT)
return false;
fromwire_bitcoin_txid(&cursor, &plen, txid);
*outnum = fromwire_u32(&cursor, &plen);
*type = fromwire_wallet_tx_type(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: ONCHAIND_ANNOTATE_TXIN */
u8 *towire_onchaind_annotate_txin(const tal_t *ctx, const struct bitcoin_txid *txid, u32 innum, enum wallet_tx_type type)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_ONCHAIND_ANNOTATE_TXIN);
towire_bitcoin_txid(&p, txid);
towire_u32(&p, innum);
towire_wallet_tx_type(&p, type);
return memcheck(p, tal_count(p));
}
bool fromwire_onchaind_annotate_txin(const void *p, struct bitcoin_txid *txid, u32 *innum, enum wallet_tx_type *type)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_ONCHAIND_ANNOTATE_TXIN)
return false;
fromwire_bitcoin_txid(&cursor, &plen, txid);
*innum = fromwire_u32(&cursor, &plen);
*type = fromwire_wallet_tx_type(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: ONCHAIND_NOTIFY_COIN_MVT */
u8 *towire_onchaind_notify_coin_mvt(const tal_t *ctx, const struct chain_coin_mvt *mvt)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_ONCHAIND_NOTIFY_COIN_MVT);
towire_chain_coin_mvt(&p, mvt);
return memcheck(p, tal_count(p));
}
bool fromwire_onchaind_notify_coin_mvt(const void *p, struct chain_coin_mvt *mvt)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_ONCHAIND_NOTIFY_COIN_MVT)
return false;
fromwire_chain_coin_mvt(&cursor, &plen, mvt);
return cursor != NULL;
}
// SHA256STAMP:exp-0-f2014a3431bb14b19ff6c2e2a273cfe07c58238052a6a18a62e413fc59d9cbf2

159
onchaind/onchaind_wiregen.h

@ -0,0 +1,159 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the _csv file it was generated from. */
/* Original template can be found at tools/gen/header_template */
#ifndef LIGHTNING_ONCHAIND_ONCHAIND_WIREGEN_H
#define LIGHTNING_ONCHAIND_ONCHAIND_WIREGEN_H
#include <ccan/tal/tal.h>
#include <wire/tlvstream.h>
#include <wire/wire.h>
#include <bitcoin/tx_parts.h>
#include <common/coin_mvt.h>
#include <common/derive_basepoints.h>
#include <common/htlc_wire.h>
#include <common/wallet.h>
#include <onchaind/onchaind_wire.h>
enum onchaind_wire {
/* Begin! Here's the onchain tx which spends funding tx */
WIRE_ONCHAIND_INIT = 5001,
/* This is all the HTLCs: one per message */
WIRE_ONCHAIND_HTLC = 5002,
/* This says we're ready; give us preimages. */
WIRE_ONCHAIND_INIT_REPLY = 5101,
/* onchaind->master: Send out a tx. */
WIRE_ONCHAIND_BROADCAST_TX = 5003,
/* master->onchaind: Notifier that an output has been spent by input_num of tx. */
WIRE_ONCHAIND_SPENT = 5004,
/* master->onchaind: We will receive more than one of these */
WIRE_ONCHAIND_DEPTH = 5005,
/* onchaind->master: We don't want to watch this tx */
WIRE_ONCHAIND_UNWATCH_TX = 5006,
/* master->onchaind: We know HTLC preimage */
WIRE_ONCHAIND_KNOWN_PREIMAGE = 5007,
/* onchaind->master: We discovered HTLC preimage */
WIRE_ONCHAIND_EXTRACTED_PREIMAGE = 5008,
/* onchaind->master: this HTLC was missing from commit tx. */
WIRE_ONCHAIND_MISSING_HTLC_OUTPUT = 5009,
/* onchaind->master: this HTLC has timed out (after reasonable_depth) */
WIRE_ONCHAIND_HTLC_TIMEOUT = 5010,
/* onchaind->master: this peer can be forgotten */
WIRE_ONCHAIND_ALL_IRREVOCABLY_RESOLVED = 5011,
/* onchaind->master: hey */
WIRE_ONCHAIND_ADD_UTXO = 5012,
/* master -> onchaind: do you have a memleak? */
WIRE_ONCHAIND_DEV_MEMLEAK = 5033,
WIRE_ONCHAIND_DEV_MEMLEAK_REPLY = 5133,
/* Tell the main daemon what we've been watching */
/* that we tracked automatically but only onchaind knows how to classify their */
/* transactions. */
WIRE_ONCHAIND_ANNOTATE_TXOUT = 5035,
WIRE_ONCHAIND_ANNOTATE_TXIN = 5036,
WIRE_ONCHAIND_NOTIFY_COIN_MVT = 5037,
};
const char *onchaind_wire_name(int e);
/**
* Determine whether a given message type is defined as a message.
*
* Returns true if the message type is part of the message definitions we have
* generated parsers for, false if it is a custom message that cannot be
* handled internally.
*/
bool onchaind_wire_is_defined(u16 type);
/* WIRE: ONCHAIND_INIT */
/* Begin! Here's the onchain tx which spends funding tx */
u8 *towire_onchaind_init(const tal_t *ctx, const struct shachain *shachain, const struct chainparams *chainparams, struct amount_sat funding_amount_satoshi, struct amount_msat our_msat, const struct pubkey *old_remote_per_commitment_point, const struct pubkey *remote_per_commitment_point, u32 local_to_self_delay, u32 remote_to_self_delay, u32 delayed_to_us_feerate, u32 htlc_feerate, u32 penalty_feerate, struct amount_sat local_dust_limit_satoshi, const struct bitcoin_txid *our_broadcast_txid, const u8 *local_scriptpubkey, const u8 *remote_scriptpubkey, const struct pubkey *ourwallet_pubkey, enum side opener, const struct basepoints *local_basepoints, const struct basepoints *remote_basepoints, const struct tx_parts *tx_parts, u32 locktime, u32 tx_blockheight, u32 reasonable_depth, const struct bitcoin_signature *htlc_signature, u64 num_htlcs, u32 min_possible_feerate, u32 max_possible_feerate, const struct pubkey *possible_remote_per_commit_point, const struct pubkey *local_funding_pubkey, const struct pubkey *remote_funding_pubkey, bool option_static_remotekey, bool option_anchor_outputs, bool is_replay);
bool fromwire_onchaind_init(const tal_t *ctx, const void *p, struct shachain *shachain, const struct chainparams **chainparams, struct amount_sat *funding_amount_satoshi, struct amount_msat *our_msat, struct pubkey *old_remote_per_commitment_point, struct pubkey *remote_per_commitment_point, u32 *local_to_self_delay, u32 *remote_to_self_delay, u32 *delayed_to_us_feerate, u32 *htlc_feerate, u32 *penalty_feerate, struct amount_sat *local_dust_limit_satoshi, struct bitcoin_txid *our_broadcast_txid, u8 **local_scriptpubkey, u8 **remote_scriptpubkey, struct pubkey *ourwallet_pubkey, enum side *opener, struct basepoints *local_basepoints, struct basepoints *remote_basepoints, struct tx_parts **tx_parts, u32 *locktime, u32 *tx_blockheight, u32 *reasonable_depth, struct bitcoin_signature **htlc_signature, u64 *num_htlcs, u32 *min_possible_feerate, u32 *max_possible_feerate, struct pubkey **possible_remote_per_commit_point, struct pubkey *local_funding_pubkey, struct pubkey *remote_funding_pubkey, bool *option_static_remotekey, bool *option_anchor_outputs, bool *is_replay);
/* WIRE: ONCHAIND_HTLC */
/* This is all the HTLCs: one per message */
u8 *towire_onchaind_htlc(const tal_t *ctx, const struct htlc_stub *htlc, bool tell_if_missing, bool tell_immediately);
bool fromwire_onchaind_htlc(const void *p, struct htlc_stub *htlc, bool *tell_if_missing, bool *tell_immediately);
/* WIRE: ONCHAIND_INIT_REPLY */
/* This says we're ready; give us preimages. */
u8 *towire_onchaind_init_reply(const tal_t *ctx);
bool fromwire_onchaind_init_reply(const void *p);
/* WIRE: ONCHAIND_BROADCAST_TX */
/* onchaind->master: Send out a tx. */
u8 *towire_onchaind_broadcast_tx(const tal_t *ctx, const struct bitcoin_tx *tx, enum wallet_tx_type type);
bool fromwire_onchaind_broadcast_tx(const tal_t *ctx, const void *p, struct bitcoin_tx **tx, enum wallet_tx_type *type);
/* WIRE: ONCHAIND_SPENT */
/* master->onchaind: Notifier that an output has been spent by input_num of tx. */
u8 *towire_onchaind_spent(const tal_t *ctx, const struct tx_parts *tx, u32 input_num, u32 blockheight, bool is_replay);
bool fromwire_onchaind_spent(const tal_t *ctx, const void *p, struct tx_parts **tx, u32 *input_num, u32 *blockheight, bool *is_replay);
/* WIRE: ONCHAIND_DEPTH */
/* master->onchaind: We will receive more than one of these */
u8 *towire_onchaind_depth(const tal_t *ctx, const struct bitcoin_txid *txid, u32 depth, bool is_replay);
bool fromwire_onchaind_depth(const void *p, struct bitcoin_txid *txid, u32 *depth, bool *is_replay);
/* WIRE: ONCHAIND_UNWATCH_TX */
/* onchaind->master: We don't want to watch this tx */
u8 *towire_onchaind_unwatch_tx(const tal_t *ctx, const struct bitcoin_txid *txid);
bool fromwire_onchaind_unwatch_tx(const void *p, struct bitcoin_txid *txid);
/* WIRE: ONCHAIND_KNOWN_PREIMAGE */
/* master->onchaind: We know HTLC preimage */
u8 *towire_onchaind_known_preimage(const tal_t *ctx, const struct preimage *preimage, bool is_replay);
bool fromwire_onchaind_known_preimage(const void *p, struct preimage *preimage, bool *is_replay);
/* WIRE: ONCHAIND_EXTRACTED_PREIMAGE */
/* onchaind->master: We discovered HTLC preimage */
u8 *towire_onchaind_extracted_preimage(const tal_t *ctx, const struct preimage *preimage);
bool fromwire_onchaind_extracted_preimage(const void *p, struct preimage *preimage);
/* WIRE: ONCHAIND_MISSING_HTLC_OUTPUT */
/* onchaind->master: this HTLC was missing from commit tx. */
u8 *towire_onchaind_missing_htlc_output(const tal_t *ctx, const struct htlc_stub *htlc);
bool fromwire_onchaind_missing_htlc_output(const void *p, struct htlc_stub *htlc);
/* WIRE: ONCHAIND_HTLC_TIMEOUT */
/* onchaind->master: this HTLC has timed out (after reasonable_depth) */
u8 *towire_onchaind_htlc_timeout(const tal_t *ctx, const struct htlc_stub *htlc);
bool fromwire_onchaind_htlc_timeout(const void *p, struct htlc_stub *htlc);
/* WIRE: ONCHAIND_ALL_IRREVOCABLY_RESOLVED */
/* onchaind->master: this peer can be forgotten */
u8 *towire_onchaind_all_irrevocably_resolved(const tal_t *ctx);
bool fromwire_onchaind_all_irrevocably_resolved(const void *p);
/* WIRE: ONCHAIND_ADD_UTXO */
/* onchaind->master: hey */
u8 *towire_onchaind_add_utxo(const tal_t *ctx, const struct bitcoin_txid *prev_out_tx, u32 prev_out_index, const struct pubkey *per_commit_point, struct amount_sat value, u32 blockheight, const u8 *scriptpubkey);
bool fromwire_onchaind_add_utxo(const tal_t *ctx, const void *p, struct bitcoin_txid *prev_out_tx, u32 *prev_out_index, struct pubkey **per_commit_point, struct amount_sat *value, u32 *blockheight, u8 **scriptpubkey);
/* WIRE: ONCHAIND_DEV_MEMLEAK */
/* master -> onchaind: do you have a memleak? */
u8 *towire_onchaind_dev_memleak(const tal_t *ctx);
bool fromwire_onchaind_dev_memleak(const void *p);
/* WIRE: ONCHAIND_DEV_MEMLEAK_REPLY */
u8 *towire_onchaind_dev_memleak_reply(const tal_t *ctx, bool leak);
bool fromwire_onchaind_dev_memleak_reply(const void *p, bool *leak);
/* WIRE: ONCHAIND_ANNOTATE_TXOUT */
/* Tell the main daemon what we've been watching */
/* that we tracked automatically but only onchaind knows how to classify their */
/* transactions. */
u8 *towire_onchaind_annotate_txout(const tal_t *ctx, const struct bitcoin_txid *txid, u32 outnum, enum wallet_tx_type type);
bool fromwire_onchaind_annotate_txout(const void *p, struct bitcoin_txid *txid, u32 *outnum, enum wallet_tx_type *type);
/* WIRE: ONCHAIND_ANNOTATE_TXIN */
u8 *towire_onchaind_annotate_txin(const tal_t *ctx, const struct bitcoin_txid *txid, u32 innum, enum wallet_tx_type type);
bool fromwire_onchaind_annotate_txin(const void *p, struct bitcoin_txid *txid, u32 *innum, enum wallet_tx_type *type);
/* WIRE: ONCHAIND_NOTIFY_COIN_MVT */
u8 *towire_onchaind_notify_coin_mvt(const tal_t *ctx, const struct chain_coin_mvt *mvt);
bool fromwire_onchaind_notify_coin_mvt(const void *p, struct chain_coin_mvt *mvt);
#endif /* LIGHTNING_ONCHAIND_ONCHAIND_WIREGEN_H */
// SHA256STAMP:exp-0-f2014a3431bb14b19ff6c2e2a273cfe07c58238052a6a18a62e413fc59d9cbf2

583
openingd/openingd_wiregen.c

@ -0,0 +1,583 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the .csv file it was generated from. */
/* Original template can be found at tools/gen/impl_template */
#include <openingd/openingd_wiregen.h>
#include <assert.h>
#include <ccan/array_size/array_size.h>
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/utils.h>
#include <stdio.h>
#ifndef SUPERVERBOSE
#define SUPERVERBOSE(...)
#endif
const char *openingd_wire_name(int e)
{
static char invalidbuf[sizeof("INVALID ") + STR_MAX_CHARS(e)];
switch ((enum openingd_wire)e) {
case WIRE_OPENINGD_INIT: return "WIRE_OPENINGD_INIT";
case WIRE_OPENINGD_GOT_OFFER: return "WIRE_OPENINGD_GOT_OFFER";
case WIRE_OPENINGD_GOT_OFFER_REPLY: return "WIRE_OPENINGD_GOT_OFFER_REPLY";
case WIRE_OPENINGD_FUNDER_REPLY: return "WIRE_OPENINGD_FUNDER_REPLY";
case WIRE_OPENINGD_FUNDER_START: return "WIRE_OPENINGD_FUNDER_START";
case WIRE_OPENINGD_FUNDER_START_REPLY: return "WIRE_OPENINGD_FUNDER_START_REPLY";
case WIRE_OPENINGD_FUNDER_COMPLETE: return "WIRE_OPENINGD_FUNDER_COMPLETE";
case WIRE_OPENINGD_FUNDER_CANCEL: return "WIRE_OPENINGD_FUNDER_CANCEL";
case WIRE_OPENINGD_FUNDER_FAILED: return "WIRE_OPENINGD_FUNDER_FAILED";
case WIRE_OPENINGD_FUNDEE: return "WIRE_OPENINGD_FUNDEE";
case WIRE_OPENINGD_DEV_MEMLEAK: return "WIRE_OPENINGD_DEV_MEMLEAK";
case WIRE_OPENINGD_DEV_MEMLEAK_REPLY: return "WIRE_OPENINGD_DEV_MEMLEAK_REPLY";
}
snprintf(invalidbuf, sizeof(invalidbuf), "INVALID %i", e);
return invalidbuf;
}
bool openingd_wire_is_defined(u16 type)
{
switch ((enum openingd_wire)type) {
case WIRE_OPENINGD_INIT:;
case WIRE_OPENINGD_GOT_OFFER:;
case WIRE_OPENINGD_GOT_OFFER_REPLY:;
case WIRE_OPENINGD_FUNDER_REPLY:;
case WIRE_OPENINGD_FUNDER_START:;
case WIRE_OPENINGD_FUNDER_START_REPLY:;
case WIRE_OPENINGD_FUNDER_COMPLETE:;
case WIRE_OPENINGD_FUNDER_CANCEL:;
case WIRE_OPENINGD_FUNDER_FAILED:;
case WIRE_OPENINGD_FUNDEE:;
case WIRE_OPENINGD_DEV_MEMLEAK:;
case WIRE_OPENINGD_DEV_MEMLEAK_REPLY:;
return true;
}
return false;
}
/* WIRE: OPENINGD_INIT */
u8 *towire_openingd_init(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_features, const struct channel_config *our_config, u32 max_to_self_delay, struct amount_msat min_effective_htlc_capacity_msat, const struct per_peer_state *pps, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, u32 minimum_depth, u32 min_feerate, u32 max_feerate, const u8 *lfeatures, bool option_static_remotekey, bool option_anchor_outputs, const u8 *msg, const struct channel_id *dev_temporary_channel_id, bool dev_fast_gossip)
{
u16 lfeatures_len = tal_count(lfeatures);
u16 len = tal_count(msg);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_OPENINGD_INIT);
/* Which network are we configured for? */
towire_chainparams(&p, chainparams);
towire_feature_set(&p, our_features);
/* Base configuration we'll offer (channel reserve will vary with amount) */
towire_channel_config(&p, our_config);
/* Minimum/maximum configuration values we'll accept */
towire_u32(&p, max_to_self_delay);
towire_amount_msat(&p, min_effective_htlc_capacity_msat);
towire_per_peer_state(&p, pps);
towire_basepoints(&p, our_basepoints);
towire_pubkey(&p, our_funding_pubkey);
/* Constraints in case the other end tries to open a channel. */
towire_u32(&p, minimum_depth);
towire_u32(&p, min_feerate);
towire_u32(&p, max_feerate);
towire_u16(&p, lfeatures_len);
towire_u8_array(&p, lfeatures, lfeatures_len);
towire_bool(&p, option_static_remotekey);
towire_bool(&p, option_anchor_outputs);
/* Optional msg to send. */
towire_u16(&p, len);
towire_u8_array(&p, msg, len);
if (!dev_temporary_channel_id)
towire_bool(&p, false);
else {
towire_bool(&p, true);
towire_channel_id(&p, dev_temporary_channel_id);
}
towire_bool(&p, dev_fast_gossip);
return memcheck(p, tal_count(p));
}
bool fromwire_openingd_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_features, struct channel_config *our_config, u32 *max_to_self_delay, struct amount_msat *min_effective_htlc_capacity_msat, struct per_peer_state **pps, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, u32 *minimum_depth, u32 *min_feerate, u32 *max_feerate, u8 **lfeatures, bool *option_static_remotekey, bool *option_anchor_outputs, u8 **msg, struct channel_id **dev_temporary_channel_id, bool *dev_fast_gossip)
{
u16 lfeatures_len;
u16 len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_OPENINGD_INIT)
return false;
/* Which network are we configured for? */
fromwire_chainparams(&cursor, &plen, chainparams);
*our_features = fromwire_feature_set(ctx, &cursor, &plen);
/* Base configuration we'll offer (channel reserve will vary with amount) */
fromwire_channel_config(&cursor, &plen, our_config);
/* Minimum/maximum configuration values we'll accept */
*max_to_self_delay = fromwire_u32(&cursor, &plen);
*min_effective_htlc_capacity_msat = fromwire_amount_msat(&cursor, &plen);
*pps = fromwire_per_peer_state(ctx, &cursor, &plen);
fromwire_basepoints(&cursor, &plen, our_basepoints);
fromwire_pubkey(&cursor, &plen, our_funding_pubkey);
/* Constraints in case the other end tries to open a channel. */
*minimum_depth = fromwire_u32(&cursor, &plen);
*min_feerate = fromwire_u32(&cursor, &plen);
*max_feerate = fromwire_u32(&cursor, &plen);
lfeatures_len = fromwire_u16(&cursor, &plen);
// 2nd case lfeatures
*lfeatures = lfeatures_len ? tal_arr(ctx, u8, lfeatures_len) : NULL;
fromwire_u8_array(&cursor, &plen, *lfeatures, lfeatures_len);
*option_static_remotekey = fromwire_bool(&cursor, &plen);
*option_anchor_outputs = fromwire_bool(&cursor, &plen);
/* Optional msg to send. */
len = fromwire_u16(&cursor, &plen);
// 2nd case msg
*msg = len ? tal_arr(ctx, u8, len) : NULL;
fromwire_u8_array(&cursor, &plen, *msg, len);
if (!fromwire_bool(&cursor, &plen))
*dev_temporary_channel_id = NULL;
else {
*dev_temporary_channel_id = tal(ctx, struct channel_id);
fromwire_channel_id(&cursor, &plen, *dev_temporary_channel_id);
}
*dev_fast_gossip = fromwire_bool(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: OPENINGD_GOT_OFFER */
/* Openingd->master: they offered channel */
u8 *towire_openingd_got_offer(const tal_t *ctx, struct amount_sat funding_satoshis, struct amount_msat push_msat, struct amount_sat dust_limit_satoshis, struct amount_msat max_htlc_value_in_flight_msat, struct amount_sat channel_reserve_satoshis, struct amount_msat htlc_minimum_msat, u32 feerate_per_kw, u16 to_self_delay, u16 max_accepted_htlcs, u8 channel_flags, const u8 *shutdown_scriptpubkey)
{
u16 shutdown_len = tal_count(shutdown_scriptpubkey);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_OPENINGD_GOT_OFFER);
towire_amount_sat(&p, funding_satoshis);
towire_amount_msat(&p, push_msat);
towire_amount_sat(&p, dust_limit_satoshis);
towire_amount_msat(&p, max_htlc_value_in_flight_msat);
towire_amount_sat(&p, channel_reserve_satoshis);
towire_amount_msat(&p, htlc_minimum_msat);
towire_u32(&p, feerate_per_kw);
towire_u16(&p, to_self_delay);
towire_u16(&p, max_accepted_htlcs);
towire_u8(&p, channel_flags);
towire_u16(&p, shutdown_len);
towire_u8_array(&p, shutdown_scriptpubkey, shutdown_len);
return memcheck(p, tal_count(p));
}
bool fromwire_openingd_got_offer(const tal_t *ctx, const void *p, struct amount_sat *funding_satoshis, struct amount_msat *push_msat, struct amount_sat *dust_limit_satoshis, struct amount_msat *max_htlc_value_in_flight_msat, struct amount_sat *channel_reserve_satoshis, struct amount_msat *htlc_minimum_msat, u32 *feerate_per_kw, u16 *to_self_delay, u16 *max_accepted_htlcs, u8 *channel_flags, u8 **shutdown_scriptpubkey)
{
u16 shutdown_len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_OPENINGD_GOT_OFFER)
return false;
*funding_satoshis = fromwire_amount_sat(&cursor, &plen);
*push_msat = fromwire_amount_msat(&cursor, &plen);
*dust_limit_satoshis = fromwire_amount_sat(&cursor, &plen);
*max_htlc_value_in_flight_msat = fromwire_amount_msat(&cursor, &plen);
*channel_reserve_satoshis = fromwire_amount_sat(&cursor, &plen);
*htlc_minimum_msat = fromwire_amount_msat(&cursor, &plen);
*feerate_per_kw = fromwire_u32(&cursor, &plen);
*to_self_delay = fromwire_u16(&cursor, &plen);
*max_accepted_htlcs = fromwire_u16(&cursor, &plen);
*channel_flags = fromwire_u8(&cursor, &plen);
shutdown_len = fromwire_u16(&cursor, &plen);
// 2nd case shutdown_scriptpubkey
*shutdown_scriptpubkey = shutdown_len ? tal_arr(ctx, u8, shutdown_len) : NULL;
fromwire_u8_array(&cursor, &plen, *shutdown_scriptpubkey, shutdown_len);
return cursor != NULL;
}
/* WIRE: OPENINGD_GOT_OFFER_REPLY */
/* master->openingd: optional rejection message */
u8 *towire_openingd_got_offer_reply(const tal_t *ctx, const wirestring *rejection, const u8 *our_shutdown_scriptpubkey)
{
u16 shutdown_len = tal_count(our_shutdown_scriptpubkey);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_OPENINGD_GOT_OFFER_REPLY);
if (!rejection)
towire_bool(&p, false);
else {
towire_bool(&p, true);
towire_wirestring(&p, rejection);
}
towire_u16(&p, shutdown_len);
towire_u8_array(&p, our_shutdown_scriptpubkey, shutdown_len);
return memcheck(p, tal_count(p));
}
bool fromwire_openingd_got_offer_reply(const tal_t *ctx, const void *p, wirestring **rejection, u8 **our_shutdown_scriptpubkey)
{
u16 shutdown_len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_OPENINGD_GOT_OFFER_REPLY)
return false;
if (!fromwire_bool(&cursor, &plen))
*rejection = NULL;
else {
*rejection = fromwire_wirestring(ctx, &cursor, &plen);
}
shutdown_len = fromwire_u16(&cursor, &plen);
// 2nd case our_shutdown_scriptpubkey
*our_shutdown_scriptpubkey = shutdown_len ? tal_arr(ctx, u8, shutdown_len) : NULL;
fromwire_u8_array(&cursor, &plen, *our_shutdown_scriptpubkey, shutdown_len);
return cursor != NULL;
}
/* WIRE: OPENINGD_FUNDER_REPLY */
/* Openingd->master: we've successfully offered channel. */
/* This gives their sig */
u8 *towire_openingd_funder_reply(const tal_t *ctx, const struct channel_config *their_config, const struct bitcoin_tx *first_commit, const struct penalty_base *pbase, const struct bitcoin_signature *first_commit_sig, const struct per_peer_state *pps, const struct pubkey *revocation_basepoint, const struct pubkey *payment_basepoint, const struct pubkey *htlc_basepoint, const struct pubkey *delayed_payment_basepoint, const struct pubkey *their_per_commit_point, u32 minimum_depth, const struct pubkey *remote_fundingkey, const struct bitcoin_txid *funding_txid, u16 funding_txout, u32 feerate_per_kw, struct amount_sat our_channel_reserve_satoshis, const u8 *shutdown_scriptpubkey)
{
u16 shutdown_len = tal_count(shutdown_scriptpubkey);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_OPENINGD_FUNDER_REPLY);
towire_channel_config(&p, their_config);
towire_bitcoin_tx(&p, first_commit);
if (!pbase)
towire_bool(&p, false);
else {
towire_bool(&p, true);
towire_penalty_base(&p, pbase);
}
towire_bitcoin_signature(&p, first_commit_sig);
towire_per_peer_state(&p, pps);
towire_pubkey(&p, revocation_basepoint);
towire_pubkey(&p, payment_basepoint);
towire_pubkey(&p, htlc_basepoint);
towire_pubkey(&p, delayed_payment_basepoint);
towire_pubkey(&p, their_per_commit_point);
towire_u32(&p, minimum_depth);
towire_pubkey(&p, remote_fundingkey);
towire_bitcoin_txid(&p, funding_txid);
towire_u16(&p, funding_txout);
towire_u32(&p, feerate_per_kw);
towire_amount_sat(&p, our_channel_reserve_satoshis);
towire_u16(&p, shutdown_len);
towire_u8_array(&p, shutdown_scriptpubkey, shutdown_len);
return memcheck(p, tal_count(p));
}
bool fromwire_openingd_funder_reply(const tal_t *ctx, const void *p, struct channel_config *their_config, struct bitcoin_tx **first_commit, struct penalty_base **pbase, struct bitcoin_signature *first_commit_sig, struct per_peer_state **pps, struct pubkey *revocation_basepoint, struct pubkey *payment_basepoint, struct pubkey *htlc_basepoint, struct pubkey *delayed_payment_basepoint, struct pubkey *their_per_commit_point, u32 *minimum_depth, struct pubkey *remote_fundingkey, struct bitcoin_txid *funding_txid, u16 *funding_txout, u32 *feerate_per_kw, struct amount_sat *our_channel_reserve_satoshis, u8 **shutdown_scriptpubkey)
{
u16 shutdown_len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_OPENINGD_FUNDER_REPLY)
return false;
fromwire_channel_config(&cursor, &plen, their_config);
*first_commit = fromwire_bitcoin_tx(ctx, &cursor, &plen);
if (!fromwire_bool(&cursor, &plen))
*pbase = NULL;
else {
*pbase = tal(ctx, struct penalty_base);
fromwire_penalty_base(&cursor, &plen, *pbase);
}
fromwire_bitcoin_signature(&cursor, &plen, first_commit_sig);
*pps = fromwire_per_peer_state(ctx, &cursor, &plen);
fromwire_pubkey(&cursor, &plen, revocation_basepoint);
fromwire_pubkey(&cursor, &plen, payment_basepoint);
fromwire_pubkey(&cursor, &plen, htlc_basepoint);
fromwire_pubkey(&cursor, &plen, delayed_payment_basepoint);
fromwire_pubkey(&cursor, &plen, their_per_commit_point);
*minimum_depth = fromwire_u32(&cursor, &plen);
fromwire_pubkey(&cursor, &plen, remote_fundingkey);
fromwire_bitcoin_txid(&cursor, &plen, funding_txid);
*funding_txout = fromwire_u16(&cursor, &plen);
*feerate_per_kw = fromwire_u32(&cursor, &plen);
*our_channel_reserve_satoshis = fromwire_amount_sat(&cursor, &plen);
shutdown_len = fromwire_u16(&cursor, &plen);
// 2nd case shutdown_scriptpubkey
*shutdown_scriptpubkey = shutdown_len ? tal_arr(ctx, u8, shutdown_len) : NULL;
fromwire_u8_array(&cursor, &plen, *shutdown_scriptpubkey, shutdown_len);
return cursor != NULL;
}
/* WIRE: OPENINGD_FUNDER_START */
/* master->openingd: start channel establishment for a funding tx */
u8 *towire_openingd_funder_start(const tal_t *ctx, struct amount_sat funding_satoshis, struct amount_msat push_msat, const u8 *upfront_shutdown_script, u32 feerate_per_kw, u8 channel_flags)
{
u16 len_upfront = tal_count(upfront_shutdown_script);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_OPENINGD_FUNDER_START);
towire_amount_sat(&p, funding_satoshis);
towire_amount_msat(&p, push_msat);
towire_u16(&p, len_upfront);
towire_u8_array(&p, upfront_shutdown_script, len_upfront);
towire_u32(&p, feerate_per_kw);
towire_u8(&p, channel_flags);
return memcheck(p, tal_count(p));
}
bool fromwire_openingd_funder_start(const tal_t *ctx, const void *p, struct amount_sat *funding_satoshis, struct amount_msat *push_msat, u8 **upfront_shutdown_script, u32 *feerate_per_kw, u8 *channel_flags)
{
u16 len_upfront;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_OPENINGD_FUNDER_START)
return false;
*funding_satoshis = fromwire_amount_sat(&cursor, &plen);
*push_msat = fromwire_amount_msat(&cursor, &plen);
len_upfront = fromwire_u16(&cursor, &plen);
// 2nd case upfront_shutdown_script
*upfront_shutdown_script = len_upfront ? tal_arr(ctx, u8, len_upfront) : NULL;
fromwire_u8_array(&cursor, &plen, *upfront_shutdown_script, len_upfront);
*feerate_per_kw = fromwire_u32(&cursor, &plen);
*channel_flags = fromwire_u8(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: OPENINGD_FUNDER_START_REPLY */
/* openingd->master: send back output script for 2-of-2 funding output */
u8 *towire_openingd_funder_start_reply(const tal_t *ctx, const u8 *scriptpubkey, bool upfront_shutdown_negotiated)
{
u8 script_len = tal_count(scriptpubkey);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_OPENINGD_FUNDER_START_REPLY);
towire_u8(&p, script_len);
towire_u8_array(&p, scriptpubkey, script_len);
towire_bool(&p, upfront_shutdown_negotiated);
return memcheck(p, tal_count(p));
}
bool fromwire_openingd_funder_start_reply(const tal_t *ctx, const void *p, u8 **scriptpubkey, bool *upfront_shutdown_negotiated)
{
u8 script_len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_OPENINGD_FUNDER_START_REPLY)
return false;
script_len = fromwire_u8(&cursor, &plen);
// 2nd case scriptpubkey
*scriptpubkey = script_len ? tal_arr(ctx, u8, script_len) : NULL;
fromwire_u8_array(&cursor, &plen, *scriptpubkey, script_len);
*upfront_shutdown_negotiated = fromwire_bool(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: OPENINGD_FUNDER_COMPLETE */
/* master->openingd: complete channel establishment for a funding */
/* tx that will be paid for by an external wallet */
/* response to this is a normal `openingd_funder_reply` ?? */
u8 *towire_openingd_funder_complete(const tal_t *ctx, const struct bitcoin_txid *funding_txid, u16 funding_txout)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_OPENINGD_FUNDER_COMPLETE);
towire_bitcoin_txid(&p, funding_txid);
towire_u16(&p, funding_txout);
return memcheck(p, tal_count(p));
}
bool fromwire_openingd_funder_complete(const void *p, struct bitcoin_txid *funding_txid, u16 *funding_txout)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_OPENINGD_FUNDER_COMPLETE)
return false;
fromwire_bitcoin_txid(&cursor, &plen, funding_txid);
*funding_txout = fromwire_u16(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: OPENINGD_FUNDER_CANCEL */
/*master->openingd: cancel channel establishment for a funding */
u8 *towire_openingd_funder_cancel(const tal_t *ctx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_OPENINGD_FUNDER_CANCEL);
return memcheck(p, tal_count(p));
}
bool fromwire_openingd_funder_cancel(const void *p)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_OPENINGD_FUNDER_CANCEL)
return false;
return cursor != NULL;
}
/* WIRE: OPENINGD_FUNDER_FAILED */
/* Openingd->master: we failed to negotiation channel */
u8 *towire_openingd_funder_failed(const tal_t *ctx, const wirestring *reason)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_OPENINGD_FUNDER_FAILED);
towire_wirestring(&p, reason);
return memcheck(p, tal_count(p));
}
bool fromwire_openingd_funder_failed(const tal_t *ctx, const void *p, wirestring **reason)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_OPENINGD_FUNDER_FAILED)
return false;
*reason = fromwire_wirestring(ctx, &cursor, &plen);
return cursor != NULL;
}
/* WIRE: OPENINGD_FUNDEE */
/* Openingd->master: they offered channel. */
/* This gives their txid and info */
u8 *towire_openingd_fundee(const tal_t *ctx, const struct channel_config *their_config, const struct bitcoin_tx *first_commit, const struct penalty_base *pbase, const struct bitcoin_signature *first_commit_sig, const struct per_peer_state *pps, const struct pubkey *revocation_basepoint, const struct pubkey *payment_basepoint, const struct pubkey *htlc_basepoint, const struct pubkey *delayed_payment_basepoint, const struct pubkey *their_per_commit_point, const struct pubkey *remote_fundingkey, const struct bitcoin_txid *funding_txid, u16 funding_txout, struct amount_sat funding_satoshis, struct amount_msat push_msat, u8 channel_flags, u32 feerate_per_kw, const u8 *funding_signed_msg, struct amount_sat our_channel_reserve_satoshis, const u8 *local_shutdown_scriptpubkey, const u8 *remote_shutdown_scriptpubkey)
{
u16 msglen = tal_count(funding_signed_msg);
u16 local_shutdown_len = tal_count(local_shutdown_scriptpubkey);
u16 remote_shutdown_len = tal_count(remote_shutdown_scriptpubkey);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_OPENINGD_FUNDEE);
towire_channel_config(&p, their_config);
towire_bitcoin_tx(&p, first_commit);
if (!pbase)
towire_bool(&p, false);
else {
towire_bool(&p, true);
towire_penalty_base(&p, pbase);
}
towire_bitcoin_signature(&p, first_commit_sig);
towire_per_peer_state(&p, pps);
towire_pubkey(&p, revocation_basepoint);
towire_pubkey(&p, payment_basepoint);
towire_pubkey(&p, htlc_basepoint);
towire_pubkey(&p, delayed_payment_basepoint);
towire_pubkey(&p, their_per_commit_point);
towire_pubkey(&p, remote_fundingkey);
towire_bitcoin_txid(&p, funding_txid);
towire_u16(&p, funding_txout);
towire_amount_sat(&p, funding_satoshis);
towire_amount_msat(&p, push_msat);
towire_u8(&p, channel_flags);
towire_u32(&p, feerate_per_kw);
/* The funding signed message: send this and we're committed. */
towire_u16(&p, msglen);
towire_u8_array(&p, funding_signed_msg, msglen);
towire_amount_sat(&p, our_channel_reserve_satoshis);
towire_u16(&p, local_shutdown_len);
towire_u8_array(&p, local_shutdown_scriptpubkey, local_shutdown_len);
towire_u16(&p, remote_shutdown_len);
towire_u8_array(&p, remote_shutdown_scriptpubkey, remote_shutdown_len);
return memcheck(p, tal_count(p));
}
bool fromwire_openingd_fundee(const tal_t *ctx, const void *p, struct channel_config *their_config, struct bitcoin_tx **first_commit, struct penalty_base **pbase, struct bitcoin_signature *first_commit_sig, struct per_peer_state **pps, struct pubkey *revocation_basepoint, struct pubkey *payment_basepoint, struct pubkey *htlc_basepoint, struct pubkey *delayed_payment_basepoint, struct pubkey *their_per_commit_point, struct pubkey *remote_fundingkey, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct amount_sat *funding_satoshis, struct amount_msat *push_msat, u8 *channel_flags, u32 *feerate_per_kw, u8 **funding_signed_msg, struct amount_sat *our_channel_reserve_satoshis, u8 **local_shutdown_scriptpubkey, u8 **remote_shutdown_scriptpubkey)
{
u16 msglen;
u16 local_shutdown_len;
u16 remote_shutdown_len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_OPENINGD_FUNDEE)
return false;
fromwire_channel_config(&cursor, &plen, their_config);
*first_commit = fromwire_bitcoin_tx(ctx, &cursor, &plen);
if (!fromwire_bool(&cursor, &plen))
*pbase = NULL;
else {
*pbase = tal(ctx, struct penalty_base);
fromwire_penalty_base(&cursor, &plen, *pbase);
}
fromwire_bitcoin_signature(&cursor, &plen, first_commit_sig);
*pps = fromwire_per_peer_state(ctx, &cursor, &plen);
fromwire_pubkey(&cursor, &plen, revocation_basepoint);
fromwire_pubkey(&cursor, &plen, payment_basepoint);
fromwire_pubkey(&cursor, &plen, htlc_basepoint);
fromwire_pubkey(&cursor, &plen, delayed_payment_basepoint);
fromwire_pubkey(&cursor, &plen, their_per_commit_point);
fromwire_pubkey(&cursor, &plen, remote_fundingkey);
fromwire_bitcoin_txid(&cursor, &plen, funding_txid);
*funding_txout = fromwire_u16(&cursor, &plen);
*funding_satoshis = fromwire_amount_sat(&cursor, &plen);
*push_msat = fromwire_amount_msat(&cursor, &plen);
*channel_flags = fromwire_u8(&cursor, &plen);
*feerate_per_kw = fromwire_u32(&cursor, &plen);
/* The funding signed message: send this and we're committed. */
msglen = fromwire_u16(&cursor, &plen);
// 2nd case funding_signed_msg
*funding_signed_msg = msglen ? tal_arr(ctx, u8, msglen) : NULL;
fromwire_u8_array(&cursor, &plen, *funding_signed_msg, msglen);
*our_channel_reserve_satoshis = fromwire_amount_sat(&cursor, &plen);
local_shutdown_len = fromwire_u16(&cursor, &plen);
// 2nd case local_shutdown_scriptpubkey
*local_shutdown_scriptpubkey = local_shutdown_len ? tal_arr(ctx, u8, local_shutdown_len) : NULL;
fromwire_u8_array(&cursor, &plen, *local_shutdown_scriptpubkey, local_shutdown_len);
remote_shutdown_len = fromwire_u16(&cursor, &plen);
// 2nd case remote_shutdown_scriptpubkey
*remote_shutdown_scriptpubkey = remote_shutdown_len ? tal_arr(ctx, u8, remote_shutdown_len) : NULL;
fromwire_u8_array(&cursor, &plen, *remote_shutdown_scriptpubkey, remote_shutdown_len);
return cursor != NULL;
}
/* WIRE: OPENINGD_DEV_MEMLEAK */
/* master -> openingd: do you have a memleak? */
u8 *towire_openingd_dev_memleak(const tal_t *ctx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_OPENINGD_DEV_MEMLEAK);
return memcheck(p, tal_count(p));
}
bool fromwire_openingd_dev_memleak(const void *p)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_OPENINGD_DEV_MEMLEAK)
return false;
return cursor != NULL;
}
/* WIRE: OPENINGD_DEV_MEMLEAK_REPLY */
u8 *towire_openingd_dev_memleak_reply(const tal_t *ctx, bool leak)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_OPENINGD_DEV_MEMLEAK_REPLY);
towire_bool(&p, leak);
return memcheck(p, tal_count(p));
}
bool fromwire_openingd_dev_memleak_reply(const void *p, bool *leak)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_OPENINGD_DEV_MEMLEAK_REPLY)
return false;
*leak = fromwire_bool(&cursor, &plen);
return cursor != NULL;
}
// SHA256STAMP:exp-0-a51533cda64c44739e86c8c93cc8f70d5f24b6c7ddb1f5b06684c4b35f58f501

125
openingd/openingd_wiregen.h

@ -0,0 +1,125 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the _csv file it was generated from. */
/* Original template can be found at tools/gen/header_template */
#ifndef LIGHTNING_OPENINGD_OPENINGD_WIREGEN_H
#define LIGHTNING_OPENINGD_OPENINGD_WIREGEN_H
#include <ccan/tal/tal.h>
#include <wire/tlvstream.h>
#include <wire/wire.h>
#include <bitcoin/chainparams.h>
#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>
#include <common/penalty_base.h>
enum openingd_wire {
WIRE_OPENINGD_INIT = 6000,
/* Openingd->master: they offered channel */
WIRE_OPENINGD_GOT_OFFER = 6005,
/* master->openingd: optional rejection message */
WIRE_OPENINGD_GOT_OFFER_REPLY = 6105,
/* Openingd->master: we've successfully offered channel. */
/* This gives their sig */
WIRE_OPENINGD_FUNDER_REPLY = 6101,
/* master->openingd: start channel establishment for a funding tx */
WIRE_OPENINGD_FUNDER_START = 6002,
/* openingd->master: send back output script for 2-of-2 funding output */
WIRE_OPENINGD_FUNDER_START_REPLY = 6102,
/* master->openingd: complete channel establishment for a funding */
/* tx that will be paid for by an external wallet */
/* response to this is a normal `openingd_funder_reply` ?? */
WIRE_OPENINGD_FUNDER_COMPLETE = 6012,
/* master->openingd: cancel channel establishment for a funding */
WIRE_OPENINGD_FUNDER_CANCEL = 6013,
/* Openingd->master: we failed to negotiation channel */
WIRE_OPENINGD_FUNDER_FAILED = 6004,
/* Openingd->master: they offered channel. */
/* This gives their txid and info */
WIRE_OPENINGD_FUNDEE = 6003,
/* master -> openingd: do you have a memleak? */
WIRE_OPENINGD_DEV_MEMLEAK = 6033,
WIRE_OPENINGD_DEV_MEMLEAK_REPLY = 6133,
};
const char *openingd_wire_name(int e);
/**
* Determine whether a given message type is defined as a message.
*
* Returns true if the message type is part of the message definitions we have
* generated parsers for, false if it is a custom message that cannot be
* handled internally.
*/
bool openingd_wire_is_defined(u16 type);
/* WIRE: OPENINGD_INIT */
u8 *towire_openingd_init(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_features, const struct channel_config *our_config, u32 max_to_self_delay, struct amount_msat min_effective_htlc_capacity_msat, const struct per_peer_state *pps, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, u32 minimum_depth, u32 min_feerate, u32 max_feerate, const u8 *lfeatures, bool option_static_remotekey, bool option_anchor_outputs, const u8 *msg, const struct channel_id *dev_temporary_channel_id, bool dev_fast_gossip);
bool fromwire_openingd_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_features, struct channel_config *our_config, u32 *max_to_self_delay, struct amount_msat *min_effective_htlc_capacity_msat, struct per_peer_state **pps, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, u32 *minimum_depth, u32 *min_feerate, u32 *max_feerate, u8 **lfeatures, bool *option_static_remotekey, bool *option_anchor_outputs, u8 **msg, struct channel_id **dev_temporary_channel_id, bool *dev_fast_gossip);
/* WIRE: OPENINGD_GOT_OFFER */
/* Openingd->master: they offered channel */
u8 *towire_openingd_got_offer(const tal_t *ctx, struct amount_sat funding_satoshis, struct amount_msat push_msat, struct amount_sat dust_limit_satoshis, struct amount_msat max_htlc_value_in_flight_msat, struct amount_sat channel_reserve_satoshis, struct amount_msat htlc_minimum_msat, u32 feerate_per_kw, u16 to_self_delay, u16 max_accepted_htlcs, u8 channel_flags, const u8 *shutdown_scriptpubkey);
bool fromwire_openingd_got_offer(const tal_t *ctx, const void *p, struct amount_sat *funding_satoshis, struct amount_msat *push_msat, struct amount_sat *dust_limit_satoshis, struct amount_msat *max_htlc_value_in_flight_msat, struct amount_sat *channel_reserve_satoshis, struct amount_msat *htlc_minimum_msat, u32 *feerate_per_kw, u16 *to_self_delay, u16 *max_accepted_htlcs, u8 *channel_flags, u8 **shutdown_scriptpubkey);
/* WIRE: OPENINGD_GOT_OFFER_REPLY */
/* master->openingd: optional rejection message */
u8 *towire_openingd_got_offer_reply(const tal_t *ctx, const wirestring *rejection, const u8 *our_shutdown_scriptpubkey);
bool fromwire_openingd_got_offer_reply(const tal_t *ctx, const void *p, wirestring **rejection, u8 **our_shutdown_scriptpubkey);
/* WIRE: OPENINGD_FUNDER_REPLY */
/* Openingd->master: we've successfully offered channel. */
/* This gives their sig */
u8 *towire_openingd_funder_reply(const tal_t *ctx, const struct channel_config *their_config, const struct bitcoin_tx *first_commit, const struct penalty_base *pbase, const struct bitcoin_signature *first_commit_sig, const struct per_peer_state *pps, const struct pubkey *revocation_basepoint, const struct pubkey *payment_basepoint, const struct pubkey *htlc_basepoint, const struct pubkey *delayed_payment_basepoint, const struct pubkey *their_per_commit_point, u32 minimum_depth, const struct pubkey *remote_fundingkey, const struct bitcoin_txid *funding_txid, u16 funding_txout, u32 feerate_per_kw, struct amount_sat our_channel_reserve_satoshis, const u8 *shutdown_scriptpubkey);
bool fromwire_openingd_funder_reply(const tal_t *ctx, const void *p, struct channel_config *their_config, struct bitcoin_tx **first_commit, struct penalty_base **pbase, struct bitcoin_signature *first_commit_sig, struct per_peer_state **pps, struct pubkey *revocation_basepoint, struct pubkey *payment_basepoint, struct pubkey *htlc_basepoint, struct pubkey *delayed_payment_basepoint, struct pubkey *their_per_commit_point, u32 *minimum_depth, struct pubkey *remote_fundingkey, struct bitcoin_txid *funding_txid, u16 *funding_txout, u32 *feerate_per_kw, struct amount_sat *our_channel_reserve_satoshis, u8 **shutdown_scriptpubkey);
/* WIRE: OPENINGD_FUNDER_START */
/* master->openingd: start channel establishment for a funding tx */
u8 *towire_openingd_funder_start(const tal_t *ctx, struct amount_sat funding_satoshis, struct amount_msat push_msat, const u8 *upfront_shutdown_script, u32 feerate_per_kw, u8 channel_flags);
bool fromwire_openingd_funder_start(const tal_t *ctx, const void *p, struct amount_sat *funding_satoshis, struct amount_msat *push_msat, u8 **upfront_shutdown_script, u32 *feerate_per_kw, u8 *channel_flags);
/* WIRE: OPENINGD_FUNDER_START_REPLY */
/* openingd->master: send back output script for 2-of-2 funding output */
u8 *towire_openingd_funder_start_reply(const tal_t *ctx, const u8 *scriptpubkey, bool upfront_shutdown_negotiated);
bool fromwire_openingd_funder_start_reply(const tal_t *ctx, const void *p, u8 **scriptpubkey, bool *upfront_shutdown_negotiated);
/* WIRE: OPENINGD_FUNDER_COMPLETE */
/* master->openingd: complete channel establishment for a funding */
/* tx that will be paid for by an external wallet */
/* response to this is a normal `openingd_funder_reply` ?? */
u8 *towire_openingd_funder_complete(const tal_t *ctx, const struct bitcoin_txid *funding_txid, u16 funding_txout);
bool fromwire_openingd_funder_complete(const void *p, struct bitcoin_txid *funding_txid, u16 *funding_txout);
/* WIRE: OPENINGD_FUNDER_CANCEL */
/* master->openingd: cancel channel establishment for a funding */
u8 *towire_openingd_funder_cancel(const tal_t *ctx);
bool fromwire_openingd_funder_cancel(const void *p);
/* WIRE: OPENINGD_FUNDER_FAILED */
/* Openingd->master: we failed to negotiation channel */
u8 *towire_openingd_funder_failed(const tal_t *ctx, const wirestring *reason);
bool fromwire_openingd_funder_failed(const tal_t *ctx, const void *p, wirestring **reason);
/* WIRE: OPENINGD_FUNDEE */
/* Openingd->master: they offered channel. */
/* This gives their txid and info */
u8 *towire_openingd_fundee(const tal_t *ctx, const struct channel_config *their_config, const struct bitcoin_tx *first_commit, const struct penalty_base *pbase, const struct bitcoin_signature *first_commit_sig, const struct per_peer_state *pps, const struct pubkey *revocation_basepoint, const struct pubkey *payment_basepoint, const struct pubkey *htlc_basepoint, const struct pubkey *delayed_payment_basepoint, const struct pubkey *their_per_commit_point, const struct pubkey *remote_fundingkey, const struct bitcoin_txid *funding_txid, u16 funding_txout, struct amount_sat funding_satoshis, struct amount_msat push_msat, u8 channel_flags, u32 feerate_per_kw, const u8 *funding_signed_msg, struct amount_sat our_channel_reserve_satoshis, const u8 *local_shutdown_scriptpubkey, const u8 *remote_shutdown_scriptpubkey);
bool fromwire_openingd_fundee(const tal_t *ctx, const void *p, struct channel_config *their_config, struct bitcoin_tx **first_commit, struct penalty_base **pbase, struct bitcoin_signature *first_commit_sig, struct per_peer_state **pps, struct pubkey *revocation_basepoint, struct pubkey *payment_basepoint, struct pubkey *htlc_basepoint, struct pubkey *delayed_payment_basepoint, struct pubkey *their_per_commit_point, struct pubkey *remote_fundingkey, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct amount_sat *funding_satoshis, struct amount_msat *push_msat, u8 *channel_flags, u32 *feerate_per_kw, u8 **funding_signed_msg, struct amount_sat *our_channel_reserve_satoshis, u8 **local_shutdown_scriptpubkey, u8 **remote_shutdown_scriptpubkey);
/* WIRE: OPENINGD_DEV_MEMLEAK */
/* master -> openingd: do you have a memleak? */
u8 *towire_openingd_dev_memleak(const tal_t *ctx);
bool fromwire_openingd_dev_memleak(const void *p);
/* WIRE: OPENINGD_DEV_MEMLEAK_REPLY */
u8 *towire_openingd_dev_memleak_reply(const tal_t *ctx, bool leak);
bool fromwire_openingd_dev_memleak_reply(const void *p, bool *leak);
#endif /* LIGHTNING_OPENINGD_OPENINGD_WIREGEN_H */
// SHA256STAMP:exp-0-a51533cda64c44739e86c8c93cc8f70d5f24b6c7ddb1f5b06684c4b35f58f501

1645
wallet/db_postgres_sqlgen.c

File diff suppressed because it is too large

1645
wallet/db_sqlite3_sqlgen.c

File diff suppressed because it is too large

1084
wallet/statements_gettextgen.po

File diff suppressed because it is too large

104
wire/common_wiregen.c

@ -0,0 +1,104 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the .csv file it was generated from. */
/* Original template can be found at tools/gen/impl_template */
#include <wire/common_wiregen.h>
#include <assert.h>
#include <ccan/array_size/array_size.h>
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/utils.h>
#include <stdio.h>
#ifndef SUPERVERBOSE
#define SUPERVERBOSE(...)
#endif
const char *common_wire_name(int e)
{
static char invalidbuf[sizeof("INVALID ") + STR_MAX_CHARS(e)];
switch ((enum common_wire)e) {
case WIRE_CUSTOMMSG_IN: return "WIRE_CUSTOMMSG_IN";
case WIRE_CUSTOMMSG_OUT: return "WIRE_CUSTOMMSG_OUT";
}
snprintf(invalidbuf, sizeof(invalidbuf), "INVALID %i", e);
return invalidbuf;
}
bool common_wire_is_defined(u16 type)
{
switch ((enum common_wire)type) {
case WIRE_CUSTOMMSG_IN:;
case WIRE_CUSTOMMSG_OUT:;
return true;
}
return false;
}
/* WIRE: CUSTOMMSG_IN */
/* A custom message that we got from a peer and don't know how to handle */
/* forward it to the master for further handling. */
u8 *towire_custommsg_in(const tal_t *ctx, const u8 *msg)
{
u16 msg_len = tal_count(msg);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_CUSTOMMSG_IN);
towire_u16(&p, msg_len);
towire_u8_array(&p, msg, msg_len);
return memcheck(p, tal_count(p));
}
bool fromwire_custommsg_in(const tal_t *ctx, const void *p, u8 **msg)
{
u16 msg_len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_CUSTOMMSG_IN)
return false;
msg_len = fromwire_u16(&cursor, &plen);
// 2nd case msg
*msg = msg_len ? tal_arr(ctx, u8, msg_len) : NULL;
fromwire_u8_array(&cursor, &plen, *msg, msg_len);
return cursor != NULL;
}
/* WIRE: CUSTOMMSG_OUT */
/* A custom message that the master tells us to send to the peer. */
u8 *towire_custommsg_out(const tal_t *ctx, const u8 *msg)
{
u16 msg_len = tal_count(msg);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_CUSTOMMSG_OUT);
towire_u16(&p, msg_len);
towire_u8_array(&p, msg, msg_len);
return memcheck(p, tal_count(p));
}
bool fromwire_custommsg_out(const tal_t *ctx, const void *p, u8 **msg)
{
u16 msg_len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_CUSTOMMSG_OUT)
return false;
msg_len = fromwire_u16(&cursor, &plen);
// 2nd case msg
*msg = msg_len ? tal_arr(ctx, u8, msg_len) : NULL;
fromwire_u8_array(&cursor, &plen, *msg, msg_len);
return cursor != NULL;
}
// SHA256STAMP:exp-0-dfcb1617f1ac102da12d72fa0d9b3abe6c1183dd3b75a5452e7d4c1ea159478f

45
wire/common_wiregen.h

@ -0,0 +1,45 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the _csv file it was generated from. */
/* Original template can be found at tools/gen/header_template */
#ifndef LIGHTNING_WIRE_COMMON_WIREGEN_H
#define LIGHTNING_WIRE_COMMON_WIREGEN_H
#include <ccan/tal/tal.h>
#include <wire/tlvstream.h>
#include <wire/wire.h>
enum common_wire {
/* A custom message that we got from a peer and don't know how to handle */
/* forward it to the master for further handling. */
WIRE_CUSTOMMSG_IN = 1030,
/* A custom message that the master tells us to send to the peer. */
WIRE_CUSTOMMSG_OUT = 1031,
};
const char *common_wire_name(int e);
/**
* Determine whether a given message type is defined as a message.
*
* Returns true if the message type is part of the message definitions we have
* generated parsers for, false if it is a custom message that cannot be
* handled internally.
*/
bool common_wire_is_defined(u16 type);
/* WIRE: CUSTOMMSG_IN */
/* A custom message that we got from a peer and don't know how to handle */
/* forward it to the master for further handling. */
u8 *towire_custommsg_in(const tal_t *ctx, const u8 *msg);
bool fromwire_custommsg_in(const tal_t *ctx, const void *p, u8 **msg);
/* WIRE: CUSTOMMSG_OUT */
/* A custom message that the master tells us to send to the peer. */
u8 *towire_custommsg_out(const tal_t *ctx, const u8 *msg);
bool fromwire_custommsg_out(const tal_t *ctx, const void *p, u8 **msg);
#endif /* LIGHTNING_WIRE_COMMON_WIREGEN_H */
// SHA256STAMP:exp-0-dfcb1617f1ac102da12d72fa0d9b3abe6c1183dd3b75a5452e7d4c1ea159478f

657
wire/onion_printgen.c

@ -0,0 +1,657 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the .csv file it was generated from. */
#include "wire/onion_printgen.h"
#include <ccan/array_size/array_size.h>
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/utils.h>
#include <inttypes.h>
#include <stdio.h>
void printonion_wire_message(const u8 *msg)
{
switch ((enum onion_wire)fromwire_peektype(msg)) {
case WIRE_INVALID_REALM:
printf("WIRE_INVALID_REALM:\n");
printwire_invalid_realm("invalid_realm", msg);
return;
case WIRE_TEMPORARY_NODE_FAILURE:
printf("WIRE_TEMPORARY_NODE_FAILURE:\n");
printwire_temporary_node_failure("temporary_node_failure", msg);
return;
case WIRE_PERMANENT_NODE_FAILURE:
printf("WIRE_PERMANENT_NODE_FAILURE:\n");
printwire_permanent_node_failure("permanent_node_failure", msg);
return;
case WIRE_REQUIRED_NODE_FEATURE_MISSING:
printf("WIRE_REQUIRED_NODE_FEATURE_MISSING:\n");
printwire_required_node_feature_missing("required_node_feature_missing", msg);
return;
case WIRE_INVALID_ONION_VERSION:
printf("WIRE_INVALID_ONION_VERSION:\n");
printwire_invalid_onion_version("invalid_onion_version", msg);
return;
case WIRE_INVALID_ONION_HMAC:
printf("WIRE_INVALID_ONION_HMAC:\n");
printwire_invalid_onion_hmac("invalid_onion_hmac", msg);
return;
case WIRE_INVALID_ONION_KEY:
printf("WIRE_INVALID_ONION_KEY:\n");
printwire_invalid_onion_key("invalid_onion_key", msg);
return;
case WIRE_TEMPORARY_CHANNEL_FAILURE:
printf("WIRE_TEMPORARY_CHANNEL_FAILURE:\n");
printwire_temporary_channel_failure("temporary_channel_failure", msg);
return;
case WIRE_PERMANENT_CHANNEL_FAILURE:
printf("WIRE_PERMANENT_CHANNEL_FAILURE:\n");
printwire_permanent_channel_failure("permanent_channel_failure", msg);
return;
case WIRE_REQUIRED_CHANNEL_FEATURE_MISSING:
printf("WIRE_REQUIRED_CHANNEL_FEATURE_MISSING:\n");
printwire_required_channel_feature_missing("required_channel_feature_missing", msg);
return;
case WIRE_UNKNOWN_NEXT_PEER:
printf("WIRE_UNKNOWN_NEXT_PEER:\n");
printwire_unknown_next_peer("unknown_next_peer", msg);
return;
case WIRE_AMOUNT_BELOW_MINIMUM:
printf("WIRE_AMOUNT_BELOW_MINIMUM:\n");
printwire_amount_below_minimum("amount_below_minimum", msg);
return;
case WIRE_FEE_INSUFFICIENT:
printf("WIRE_FEE_INSUFFICIENT:\n");
printwire_fee_insufficient("fee_insufficient", msg);
return;
case WIRE_INCORRECT_CLTV_EXPIRY:
printf("WIRE_INCORRECT_CLTV_EXPIRY:\n");
printwire_incorrect_cltv_expiry("incorrect_cltv_expiry", msg);
return;
case WIRE_EXPIRY_TOO_SOON:
printf("WIRE_EXPIRY_TOO_SOON:\n");
printwire_expiry_too_soon("expiry_too_soon", msg);
return;
case WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS:
printf("WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS:\n");
printwire_incorrect_or_unknown_payment_details("incorrect_or_unknown_payment_details", msg);
return;
case WIRE_FINAL_INCORRECT_CLTV_EXPIRY:
printf("WIRE_FINAL_INCORRECT_CLTV_EXPIRY:\n");
printwire_final_incorrect_cltv_expiry("final_incorrect_cltv_expiry", msg);
return;
case WIRE_FINAL_INCORRECT_HTLC_AMOUNT:
printf("WIRE_FINAL_INCORRECT_HTLC_AMOUNT:\n");
printwire_final_incorrect_htlc_amount("final_incorrect_htlc_amount", msg);
return;
case WIRE_CHANNEL_DISABLED:
printf("WIRE_CHANNEL_DISABLED:\n");
printwire_channel_disabled("channel_disabled", msg);
return;
case WIRE_EXPIRY_TOO_FAR:
printf("WIRE_EXPIRY_TOO_FAR:\n");
printwire_expiry_too_far("expiry_too_far", msg);
return;
case WIRE_INVALID_ONION_PAYLOAD:
printf("WIRE_INVALID_ONION_PAYLOAD:\n");
printwire_invalid_onion_payload("invalid_onion_payload", msg);
return;
case WIRE_MPP_TIMEOUT:
printf("WIRE_MPP_TIMEOUT:\n");
printwire_mpp_timeout("mpp_timeout", msg);
return;
}
printf("UNKNOWN: %s\\n", tal_hex(msg, msg));
}
static void printwire_tlv_tlv_payload_amt_to_forward(const char *fieldname, const u8 **cursor, size_t *plen)
{
printf("(msg_name=%s)\n", "amt_to_forward");
printf("amt_to_forward=");
u64 amt_to_forward = fromwire_tu64(cursor, plen);
printwire_u64(tal_fmt(NULL, "%s.amt_to_forward", fieldname), &amt_to_forward);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
}
static void printwire_tlv_tlv_payload_outgoing_cltv_value(const char *fieldname, const u8 **cursor, size_t *plen)
{
printf("(msg_name=%s)\n", "outgoing_cltv_value");
printf("outgoing_cltv_value=");
u32 outgoing_cltv_value = fromwire_tu32(cursor, plen);
printwire_u32(tal_fmt(NULL, "%s.outgoing_cltv_value", fieldname), &outgoing_cltv_value);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
}
static void printwire_tlv_tlv_payload_short_channel_id(const char *fieldname, const u8 **cursor, size_t *plen)
{
printf("(msg_name=%s)\n", "short_channel_id");
printf("short_channel_id=");
struct short_channel_id short_channel_id;
fromwire_short_channel_id(cursor, plen, &short_channel_id);
printwire_short_channel_id(tal_fmt(NULL, "%s.short_channel_id", fieldname), &short_channel_id);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
}
static void printwire_tlv_tlv_payload_payment_data(const char *fieldname, const u8 **cursor, size_t *plen)
{
printf("(msg_name=%s)\n", "payment_data");
printf("payment_secret=");
struct secret payment_secret;
fromwire_secret(cursor, plen, &payment_secret);
printwire_secret(tal_fmt(NULL, "%s.payment_secret", fieldname), &payment_secret);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("total_msat=");
u64 total_msat = fromwire_tu64(cursor, plen);
printwire_u64(tal_fmt(NULL, "%s.total_msat", fieldname), &total_msat);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
}
static const struct tlv_print_record_type print_tlvs_tlv_payload[] = {
{ 2, printwire_tlv_tlv_payload_amt_to_forward },
{ 4, printwire_tlv_tlv_payload_outgoing_cltv_value },
{ 6, printwire_tlv_tlv_payload_short_channel_id },
{ 8, printwire_tlv_tlv_payload_payment_data },
};
void printwire_invalid_realm(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_INVALID_REALM) {
printf("WRONG TYPE?!\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_temporary_node_failure(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_TEMPORARY_NODE_FAILURE) {
printf("WRONG TYPE?!\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_permanent_node_failure(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_PERMANENT_NODE_FAILURE) {
printf("WRONG TYPE?!\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_required_node_feature_missing(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_REQUIRED_NODE_FEATURE_MISSING) {
printf("WRONG TYPE?!\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_invalid_onion_version(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_INVALID_ONION_VERSION) {
printf("WRONG TYPE?!\n");
return;
}
printf("sha256_of_onion=");
struct sha256 sha256_of_onion;
fromwire_sha256(&cursor, &plen, &sha256_of_onion);
printwire_sha256(tal_fmt(NULL, "%s.sha256_of_onion", fieldname), &sha256_of_onion);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_invalid_onion_hmac(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_INVALID_ONION_HMAC) {
printf("WRONG TYPE?!\n");
return;
}
printf("sha256_of_onion=");
struct sha256 sha256_of_onion;
fromwire_sha256(&cursor, &plen, &sha256_of_onion);
printwire_sha256(tal_fmt(NULL, "%s.sha256_of_onion", fieldname), &sha256_of_onion);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_invalid_onion_key(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_INVALID_ONION_KEY) {
printf("WRONG TYPE?!\n");
return;
}
printf("sha256_of_onion=");
struct sha256 sha256_of_onion;
fromwire_sha256(&cursor, &plen, &sha256_of_onion);
printwire_sha256(tal_fmt(NULL, "%s.sha256_of_onion", fieldname), &sha256_of_onion);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_temporary_channel_failure(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_TEMPORARY_CHANNEL_FAILURE) {
printf("WRONG TYPE?!\n");
return;
}
u16 len = fromwire_u16(&cursor, &plen);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("channel_update=");
printwire_u8_array(tal_fmt(NULL, "%s.channel_update", fieldname), &cursor, &plen, len);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_permanent_channel_failure(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_PERMANENT_CHANNEL_FAILURE) {
printf("WRONG TYPE?!\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_required_channel_feature_missing(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_REQUIRED_CHANNEL_FEATURE_MISSING) {
printf("WRONG TYPE?!\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_unknown_next_peer(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_UNKNOWN_NEXT_PEER) {
printf("WRONG TYPE?!\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_amount_below_minimum(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_AMOUNT_BELOW_MINIMUM) {
printf("WRONG TYPE?!\n");
return;
}
printf("htlc_msat=");
struct amount_msat htlc_msat = fromwire_amount_msat(&cursor, &plen);
printwire_amount_msat(tal_fmt(NULL, "%s.htlc_msat", fieldname), &htlc_msat);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
u16 len = fromwire_u16(&cursor, &plen);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("channel_update=");
printwire_u8_array(tal_fmt(NULL, "%s.channel_update", fieldname), &cursor, &plen, len);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_fee_insufficient(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_FEE_INSUFFICIENT) {
printf("WRONG TYPE?!\n");
return;
}
printf("htlc_msat=");
struct amount_msat htlc_msat = fromwire_amount_msat(&cursor, &plen);
printwire_amount_msat(tal_fmt(NULL, "%s.htlc_msat", fieldname), &htlc_msat);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
u16 len = fromwire_u16(&cursor, &plen);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("channel_update=");
printwire_u8_array(tal_fmt(NULL, "%s.channel_update", fieldname), &cursor, &plen, len);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_incorrect_cltv_expiry(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_INCORRECT_CLTV_EXPIRY) {
printf("WRONG TYPE?!\n");
return;
}
printf("cltv_expiry=");
u32 cltv_expiry = fromwire_u32(&cursor, &plen);
printwire_u32(tal_fmt(NULL, "%s.cltv_expiry", fieldname), &cltv_expiry);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
u16 len = fromwire_u16(&cursor, &plen);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("channel_update=");
printwire_u8_array(tal_fmt(NULL, "%s.channel_update", fieldname), &cursor, &plen, len);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_expiry_too_soon(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_EXPIRY_TOO_SOON) {
printf("WRONG TYPE?!\n");
return;
}
u16 len = fromwire_u16(&cursor, &plen);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("channel_update=");
printwire_u8_array(tal_fmt(NULL, "%s.channel_update", fieldname), &cursor, &plen, len);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_incorrect_or_unknown_payment_details(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS) {
printf("WRONG TYPE?!\n");
return;
}
printf("htlc_msat=");
struct amount_msat htlc_msat = fromwire_amount_msat(&cursor, &plen);
printwire_amount_msat(tal_fmt(NULL, "%s.htlc_msat", fieldname), &htlc_msat);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("height=");
u32 height = fromwire_u32(&cursor, &plen);
printwire_u32(tal_fmt(NULL, "%s.height", fieldname), &height);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_final_incorrect_cltv_expiry(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_FINAL_INCORRECT_CLTV_EXPIRY) {
printf("WRONG TYPE?!\n");
return;
}
printf("cltv_expiry=");
u32 cltv_expiry = fromwire_u32(&cursor, &plen);
printwire_u32(tal_fmt(NULL, "%s.cltv_expiry", fieldname), &cltv_expiry);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_final_incorrect_htlc_amount(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_FINAL_INCORRECT_HTLC_AMOUNT) {
printf("WRONG TYPE?!\n");
return;
}
printf("incoming_htlc_amt=");
struct amount_msat incoming_htlc_amt = fromwire_amount_msat(&cursor, &plen);
printwire_amount_msat(tal_fmt(NULL, "%s.incoming_htlc_amt", fieldname), &incoming_htlc_amt);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_channel_disabled(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_CHANNEL_DISABLED) {
printf("WRONG TYPE?!\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_expiry_too_far(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_EXPIRY_TOO_FAR) {
printf("WRONG TYPE?!\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_invalid_onion_payload(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_INVALID_ONION_PAYLOAD) {
printf("WRONG TYPE?!\n");
return;
}
printf("type=");
bigsize type = fromwire_bigsize(&cursor, &plen);
printwire_bigsize(tal_fmt(NULL, "%s.type", fieldname), &type);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("offset=");
u16 offset = fromwire_u16(&cursor, &plen);
printwire_u16(tal_fmt(NULL, "%s.offset", fieldname), &offset);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_mpp_timeout(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_MPP_TIMEOUT) {
printf("WRONG TYPE?!\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printonion_wire_tlv_message(const char *tlv_name, const u8 *msg) {
size_t plen = tal_count(msg);
if (strcmp(tlv_name, "tlv_payload") == 0) {
printwire_tlvs(tlv_name, &msg, &plen, print_tlvs_tlv_payload, ARRAY_SIZE(print_tlvs_tlv_payload));
}
}
// SHA256STAMP:exp-0-fb3c7a1b699d41c2fe76eb380a851fe8aea7a15e7740ce2bfdcb3fcf173a1e8a

61
wire/onion_printgen.h

@ -0,0 +1,61 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the .csv file it was generated from. */
/* Template located at tools/gen/print_header_template */
#ifndef LIGHTNING_WIRE_ONION_PRINTGEN_H
#define LIGHTNING_WIRE_ONION_PRINTGEN_H
#include <ccan/tal/tal.h>
#include <devtools/print_wire.h>
#include <wire/onion_defs.h>
void printonion_wire_message(const u8 *msg);
void printonion_wire_tlv_message(const char *tlv_name, const u8 *msg);
void printwire_invalid_realm(const char *fieldname, const u8 *cursor);
void printwire_temporary_node_failure(const char *fieldname, const u8 *cursor);
void printwire_permanent_node_failure(const char *fieldname, const u8 *cursor);
void printwire_required_node_feature_missing(const char *fieldname, const u8 *cursor);
void printwire_invalid_onion_version(const char *fieldname, const u8 *cursor);
void printwire_invalid_onion_hmac(const char *fieldname, const u8 *cursor);
void printwire_invalid_onion_key(const char *fieldname, const u8 *cursor);
void printwire_temporary_channel_failure(const char *fieldname, const u8 *cursor);
void printwire_permanent_channel_failure(const char *fieldname, const u8 *cursor);
void printwire_required_channel_feature_missing(const char *fieldname, const u8 *cursor);
void printwire_unknown_next_peer(const char *fieldname, const u8 *cursor);
void printwire_amount_below_minimum(const char *fieldname, const u8 *cursor);
void printwire_fee_insufficient(const char *fieldname, const u8 *cursor);
void printwire_incorrect_cltv_expiry(const char *fieldname, const u8 *cursor);
void printwire_expiry_too_soon(const char *fieldname, const u8 *cursor);
void printwire_incorrect_or_unknown_payment_details(const char *fieldname, const u8 *cursor);
void printwire_final_incorrect_cltv_expiry(const char *fieldname, const u8 *cursor);
void printwire_final_incorrect_htlc_amount(const char *fieldname, const u8 *cursor);
void printwire_channel_disabled(const char *fieldname, const u8 *cursor);
void printwire_expiry_too_far(const char *fieldname, const u8 *cursor);
void printwire_invalid_onion_payload(const char *fieldname, const u8 *cursor);
void printwire_mpp_timeout(const char *fieldname, const u8 *cursor);
#endif /* LIGHTNING_WIRE_ONION_PRINTGEN_H */
// SHA256STAMP:exp-0-fb3c7a1b699d41c2fe76eb380a851fe8aea7a15e7740ce2bfdcb3fcf173a1e8a

841
wire/onion_wiregen.c

@ -0,0 +1,841 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the .csv file it was generated from. */
/* Original template can be found at tools/gen/impl_template */
#include <wire/onion_wiregen.h>
#include <assert.h>
#include <ccan/array_size/array_size.h>
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/utils.h>
#include <stdio.h>
#ifndef SUPERVERBOSE
#define SUPERVERBOSE(...)
#endif
const char *onion_wire_name(int e)
{
static char invalidbuf[sizeof("INVALID ") + STR_MAX_CHARS(e)];
switch ((enum onion_wire)e) {
case WIRE_INVALID_REALM: return "WIRE_INVALID_REALM";
case WIRE_TEMPORARY_NODE_FAILURE: return "WIRE_TEMPORARY_NODE_FAILURE";
case WIRE_PERMANENT_NODE_FAILURE: return "WIRE_PERMANENT_NODE_FAILURE";
case WIRE_REQUIRED_NODE_FEATURE_MISSING: return "WIRE_REQUIRED_NODE_FEATURE_MISSING";
case WIRE_INVALID_ONION_VERSION: return "WIRE_INVALID_ONION_VERSION";
case WIRE_INVALID_ONION_HMAC: return "WIRE_INVALID_ONION_HMAC";
case WIRE_INVALID_ONION_KEY: return "WIRE_INVALID_ONION_KEY";
case WIRE_TEMPORARY_CHANNEL_FAILURE: return "WIRE_TEMPORARY_CHANNEL_FAILURE";
case WIRE_PERMANENT_CHANNEL_FAILURE: return "WIRE_PERMANENT_CHANNEL_FAILURE";
case WIRE_REQUIRED_CHANNEL_FEATURE_MISSING: return "WIRE_REQUIRED_CHANNEL_FEATURE_MISSING";
case WIRE_UNKNOWN_NEXT_PEER: return "WIRE_UNKNOWN_NEXT_PEER";
case WIRE_AMOUNT_BELOW_MINIMUM: return "WIRE_AMOUNT_BELOW_MINIMUM";
case WIRE_FEE_INSUFFICIENT: return "WIRE_FEE_INSUFFICIENT";
case WIRE_INCORRECT_CLTV_EXPIRY: return "WIRE_INCORRECT_CLTV_EXPIRY";
case WIRE_EXPIRY_TOO_SOON: return "WIRE_EXPIRY_TOO_SOON";
case WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS: return "WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS";
case WIRE_FINAL_INCORRECT_CLTV_EXPIRY: return "WIRE_FINAL_INCORRECT_CLTV_EXPIRY";
case WIRE_FINAL_INCORRECT_HTLC_AMOUNT: return "WIRE_FINAL_INCORRECT_HTLC_AMOUNT";
case WIRE_CHANNEL_DISABLED: return "WIRE_CHANNEL_DISABLED";
case WIRE_EXPIRY_TOO_FAR: return "WIRE_EXPIRY_TOO_FAR";
case WIRE_INVALID_ONION_PAYLOAD: return "WIRE_INVALID_ONION_PAYLOAD";
case WIRE_MPP_TIMEOUT: return "WIRE_MPP_TIMEOUT";
}
snprintf(invalidbuf, sizeof(invalidbuf), "INVALID %i", e);
return invalidbuf;
}
bool onion_wire_is_defined(u16 type)
{
switch ((enum onion_wire)type) {
case WIRE_INVALID_REALM:;
case WIRE_TEMPORARY_NODE_FAILURE:;
case WIRE_PERMANENT_NODE_FAILURE:;
case WIRE_REQUIRED_NODE_FEATURE_MISSING:;
case WIRE_INVALID_ONION_VERSION:;
case WIRE_INVALID_ONION_HMAC:;
case WIRE_INVALID_ONION_KEY:;
case WIRE_TEMPORARY_CHANNEL_FAILURE:;
case WIRE_PERMANENT_CHANNEL_FAILURE:;
case WIRE_REQUIRED_CHANNEL_FEATURE_MISSING:;
case WIRE_UNKNOWN_NEXT_PEER:;
case WIRE_AMOUNT_BELOW_MINIMUM:;
case WIRE_FEE_INSUFFICIENT:;
case WIRE_INCORRECT_CLTV_EXPIRY:;
case WIRE_EXPIRY_TOO_SOON:;
case WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS:;
case WIRE_FINAL_INCORRECT_CLTV_EXPIRY:;
case WIRE_FINAL_INCORRECT_HTLC_AMOUNT:;
case WIRE_CHANNEL_DISABLED:;
case WIRE_EXPIRY_TOO_FAR:;
case WIRE_INVALID_ONION_PAYLOAD:;
case WIRE_MPP_TIMEOUT:;
return true;
}
return false;
}
struct tlv_tlv_payload *tlv_tlv_payload_new(const tal_t *ctx)
{
/* Initialize everything to NULL. (Quiet, C pedants!) */
struct tlv_tlv_payload *inst = talz(ctx, struct tlv_tlv_payload);
/* Initialized the fields to an empty array. */
inst->fields = tal_arr(inst, struct tlv_field, 0);
return inst;
}
/* TLV_PAYLOAD MSG: amt_to_forward */
static u8 *towire_tlv_tlv_payload_amt_to_forward(const tal_t *ctx, const void *vrecord)
{
const struct tlv_tlv_payload *r = vrecord;
u8 *ptr;
if (!r->amt_to_forward)
return NULL;
ptr = tal_arr(ctx, u8, 0);
towire_tu64(&ptr, *r->amt_to_forward);
return ptr;
}
static void fromwire_tlv_tlv_payload_amt_to_forward(const u8 **cursor, size_t *plen, void *vrecord)
{
struct tlv_tlv_payload *r = vrecord;
r->amt_to_forward = tal(r, u64);
*r->amt_to_forward = fromwire_tu64(cursor, plen);
}
/* TLV_PAYLOAD MSG: outgoing_cltv_value */
static u8 *towire_tlv_tlv_payload_outgoing_cltv_value(const tal_t *ctx, const void *vrecord)
{
const struct tlv_tlv_payload *r = vrecord;
u8 *ptr;
if (!r->outgoing_cltv_value)
return NULL;
ptr = tal_arr(ctx, u8, 0);
towire_tu32(&ptr, *r->outgoing_cltv_value);
return ptr;
}
static void fromwire_tlv_tlv_payload_outgoing_cltv_value(const u8 **cursor, size_t *plen, void *vrecord)
{
struct tlv_tlv_payload *r = vrecord;
r->outgoing_cltv_value = tal(r, u32);
*r->outgoing_cltv_value = fromwire_tu32(cursor, plen);
}
/* TLV_PAYLOAD MSG: short_channel_id */
static u8 *towire_tlv_tlv_payload_short_channel_id(const tal_t *ctx, const void *vrecord)
{
const struct tlv_tlv_payload *r = vrecord;
u8 *ptr;
if (!r->short_channel_id)
return NULL;
ptr = tal_arr(ctx, u8, 0);
towire_short_channel_id(&ptr, r->short_channel_id);
return ptr;
}
static void fromwire_tlv_tlv_payload_short_channel_id(const u8 **cursor, size_t *plen, void *vrecord)
{
struct tlv_tlv_payload *r = vrecord;
r->short_channel_id = tal(r, struct short_channel_id);
fromwire_short_channel_id(cursor, plen, &*r->short_channel_id);
}
/* TLV_PAYLOAD MSG: payment_data */
static u8 *towire_tlv_tlv_payload_payment_data(const tal_t *ctx, const void *vrecord)
{
const struct tlv_tlv_payload *r = vrecord;
u8 *ptr;
if (!r->payment_data)
return NULL;
ptr = tal_arr(ctx, u8, 0);
towire_secret(&ptr, &r->payment_data->payment_secret);
towire_tu64(&ptr, r->payment_data->total_msat);
return ptr;
}
static void fromwire_tlv_tlv_payload_payment_data(const u8 **cursor, size_t *plen, void *vrecord)
{
struct tlv_tlv_payload *r = vrecord;
r->payment_data = tal(r, struct tlv_tlv_payload_payment_data);
fromwire_secret(cursor, plen, &r->payment_data->payment_secret);
r->payment_data->total_msat = fromwire_tu64(cursor, plen);
}
const struct tlv_record_type tlvs_tlv_payload[] = {
{ 2, towire_tlv_tlv_payload_amt_to_forward, fromwire_tlv_tlv_payload_amt_to_forward },
{ 4, towire_tlv_tlv_payload_outgoing_cltv_value, fromwire_tlv_tlv_payload_outgoing_cltv_value },
{ 6, towire_tlv_tlv_payload_short_channel_id, fromwire_tlv_tlv_payload_short_channel_id },
{ 8, towire_tlv_tlv_payload_payment_data, fromwire_tlv_tlv_payload_payment_data },
};
void towire_tlv_payload(u8 **pptr,
const void *record)
{
size_t num_types = 4;
const struct tlv_record_type *types = tlvs_tlv_payload;
if (!record)
return;
for (size_t i = 0; i < num_types; i++) {
u8 *val;
if (i != 0)
assert(types[i].type > types[i-1].type);
val = types[i].towire(NULL, record);
if (!val)
continue;
/* BOLT #1:
*
* The sending node:
...
* - MUST minimally encode `type` and `length`.
*/
towire_bigsize(pptr, types[i].type);
towire_bigsize(pptr, tal_bytelen(val));
towire(pptr, val, tal_bytelen(val));
tal_free(val);
}
}
bool fromwire_tlv_payload(const u8 **cursor, size_t *max, struct tlv_tlv_payload *record)
{
size_t num_types = 4;
const struct tlv_record_type *types = tlvs_tlv_payload;
while (*max > 0) {
struct tlv_field field;
/* BOLT #1:
*
* A `varint` is a variable-length, unsigned integer encoding
* using the [BigSize](#appendix-a-bigsize-test-vectors)
* format
*/
field.numtype = fromwire_bigsize(cursor, max);
/* BOLT #1:
* - if a `type` or `length` is not minimally encoded:
* - MUST fail to parse the `tlv_stream`.
*/
if (!*cursor) {
SUPERVERBOSE("type");
goto fail;
}
field.length = fromwire_bigsize(cursor, max);
/* BOLT #1:
* - if a `type` or `length` is not minimally encoded:
* - MUST fail to parse the `tlv_stream`.
*/
if (!*cursor) {
SUPERVERBOSE("length");
goto fail;
}
/* BOLT #1:
* - if `length` exceeds the number of bytes remaining in the
* message:
* - MUST fail to parse the `tlv_stream`.
*/
if (field.length > *max) {
SUPERVERBOSE("value");
goto fail;
}
field.value = tal_dup_arr(record, u8, *cursor, field.length, 0);
/* BOLT #1:
* - if `type` is known:
* - MUST decode the next `length` bytes using the known
* encoding for `type`.
*/
field.meta = NULL;
for (size_t i = 0; i < num_types; i++) {
if (types[i].type == field.numtype)
field.meta = &types[i];
}
if (field.meta) {
/* Length of message can't exceed 16 bits anyway. */
size_t tlvlen = field.length;
field.meta->fromwire(cursor, &tlvlen, record);
if (!*cursor)
goto fail;
/* BOLT #1:
* - if `length` is not exactly equal to that required
* for the known encoding for `type`:
* - MUST fail to parse the `tlv_stream`.
*/
if (tlvlen != 0) {
SUPERVERBOSE("greater than encoding length");
goto fail;
}
} else {
/* We didn't read from *cursor through a fromwire, so
* update manually. */
*cursor += field.length;
}
/* We've read bytes in ->fromwire, so update max */
*max -= field.length;
tal_arr_expand(&record->fields, field);
}
return true;
fail:
fromwire_fail(cursor, max);
return false;
}
bool tlv_payload_is_valid(const struct tlv_tlv_payload *record, size_t *err_index)
{
size_t numfields = tal_count(record->fields);
bool first = true;
u64 prev_type = 0;
for (int i=0; i<numfields; i++) {
struct tlv_field *f = &record->fields[i];
if (f->numtype % 2 == 0 && f->meta == NULL) {
/* BOLT #1:
* - otherwise, if `type` is unknown:
* - if `type` is even:
* - MUST fail to parse the `tlv_stream`.
* - otherwise, if `type` is odd:
* - MUST discard the next `length` bytes.
*/
SUPERVERBOSE("unknown even");
if (err_index != NULL)
*err_index = i;
return false;
} else if (!first && f->numtype <= prev_type) {
/* BOLT #1:
* - if decoded `type`s are not monotonically-increasing:
* - MUST fail to parse the `tlv_stream`.
*/
if (f->numtype == prev_type)
SUPERVERBOSE("duplicate tlv type");
else
SUPERVERBOSE("invalid ordering");
if (err_index != NULL)
*err_index = i;
return false;
}
first = false;
prev_type = f->numtype;
}
return true;
}
/* WIRE: INVALID_REALM */
u8 *towire_invalid_realm(const tal_t *ctx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_INVALID_REALM);
return memcheck(p, tal_count(p));
}
bool fromwire_invalid_realm(const void *p)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_INVALID_REALM)
return false;
return cursor != NULL;
}
/* WIRE: TEMPORARY_NODE_FAILURE */
u8 *towire_temporary_node_failure(const tal_t *ctx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_TEMPORARY_NODE_FAILURE);
return memcheck(p, tal_count(p));
}
bool fromwire_temporary_node_failure(const void *p)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_TEMPORARY_NODE_FAILURE)
return false;
return cursor != NULL;
}
/* WIRE: PERMANENT_NODE_FAILURE */
u8 *towire_permanent_node_failure(const tal_t *ctx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_PERMANENT_NODE_FAILURE);
return memcheck(p, tal_count(p));
}
bool fromwire_permanent_node_failure(const void *p)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_PERMANENT_NODE_FAILURE)
return false;
return cursor != NULL;
}
/* WIRE: REQUIRED_NODE_FEATURE_MISSING */
u8 *towire_required_node_feature_missing(const tal_t *ctx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_REQUIRED_NODE_FEATURE_MISSING);
return memcheck(p, tal_count(p));
}
bool fromwire_required_node_feature_missing(const void *p)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_REQUIRED_NODE_FEATURE_MISSING)
return false;
return cursor != NULL;
}
/* WIRE: INVALID_ONION_VERSION */
u8 *towire_invalid_onion_version(const tal_t *ctx, const struct sha256 *sha256_of_onion)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_INVALID_ONION_VERSION);
towire_sha256(&p, sha256_of_onion);
return memcheck(p, tal_count(p));
}
bool fromwire_invalid_onion_version(const void *p, struct sha256 *sha256_of_onion)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_INVALID_ONION_VERSION)
return false;
fromwire_sha256(&cursor, &plen, sha256_of_onion);
return cursor != NULL;
}
/* WIRE: INVALID_ONION_HMAC */
u8 *towire_invalid_onion_hmac(const tal_t *ctx, const struct sha256 *sha256_of_onion)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_INVALID_ONION_HMAC);
towire_sha256(&p, sha256_of_onion);
return memcheck(p, tal_count(p));
}
bool fromwire_invalid_onion_hmac(const void *p, struct sha256 *sha256_of_onion)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_INVALID_ONION_HMAC)
return false;
fromwire_sha256(&cursor, &plen, sha256_of_onion);
return cursor != NULL;
}
/* WIRE: INVALID_ONION_KEY */
u8 *towire_invalid_onion_key(const tal_t *ctx, const struct sha256 *sha256_of_onion)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_INVALID_ONION_KEY);
towire_sha256(&p, sha256_of_onion);
return memcheck(p, tal_count(p));
}
bool fromwire_invalid_onion_key(const void *p, struct sha256 *sha256_of_onion)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_INVALID_ONION_KEY)
return false;
fromwire_sha256(&cursor, &plen, sha256_of_onion);
return cursor != NULL;
}
/* WIRE: TEMPORARY_CHANNEL_FAILURE */
u8 *towire_temporary_channel_failure(const tal_t *ctx, const u8 *channel_update)
{
u16 len = tal_count(channel_update);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_TEMPORARY_CHANNEL_FAILURE);
towire_u16(&p, len);
towire_u8_array(&p, channel_update, len);
return memcheck(p, tal_count(p));
}
bool fromwire_temporary_channel_failure(const tal_t *ctx, const void *p, u8 **channel_update)
{
u16 len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_TEMPORARY_CHANNEL_FAILURE)
return false;
len = fromwire_u16(&cursor, &plen);
// 2nd case channel_update
*channel_update = len ? tal_arr(ctx, u8, len) : NULL;
fromwire_u8_array(&cursor, &plen, *channel_update, len);
return cursor != NULL;
}
/* WIRE: PERMANENT_CHANNEL_FAILURE */
u8 *towire_permanent_channel_failure(const tal_t *ctx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_PERMANENT_CHANNEL_FAILURE);
return memcheck(p, tal_count(p));
}
bool fromwire_permanent_channel_failure(const void *p)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_PERMANENT_CHANNEL_FAILURE)
return false;
return cursor != NULL;
}
/* WIRE: REQUIRED_CHANNEL_FEATURE_MISSING */
u8 *towire_required_channel_feature_missing(const tal_t *ctx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_REQUIRED_CHANNEL_FEATURE_MISSING);
return memcheck(p, tal_count(p));
}
bool fromwire_required_channel_feature_missing(const void *p)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_REQUIRED_CHANNEL_FEATURE_MISSING)
return false;
return cursor != NULL;
}
/* WIRE: UNKNOWN_NEXT_PEER */
u8 *towire_unknown_next_peer(const tal_t *ctx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_UNKNOWN_NEXT_PEER);
return memcheck(p, tal_count(p));
}
bool fromwire_unknown_next_peer(const void *p)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_UNKNOWN_NEXT_PEER)
return false;
return cursor != NULL;
}
/* WIRE: AMOUNT_BELOW_MINIMUM */
u8 *towire_amount_below_minimum(const tal_t *ctx, struct amount_msat htlc_msat, const u8 *channel_update)
{
u16 len = tal_count(channel_update);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_AMOUNT_BELOW_MINIMUM);
towire_amount_msat(&p, htlc_msat);
towire_u16(&p, len);
towire_u8_array(&p, channel_update, len);
return memcheck(p, tal_count(p));
}
bool fromwire_amount_below_minimum(const tal_t *ctx, const void *p, struct amount_msat *htlc_msat, u8 **channel_update)
{
u16 len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_AMOUNT_BELOW_MINIMUM)
return false;
*htlc_msat = fromwire_amount_msat(&cursor, &plen);
len = fromwire_u16(&cursor, &plen);
// 2nd case channel_update
*channel_update = len ? tal_arr(ctx, u8, len) : NULL;
fromwire_u8_array(&cursor, &plen, *channel_update, len);
return cursor != NULL;
}
/* WIRE: FEE_INSUFFICIENT */
u8 *towire_fee_insufficient(const tal_t *ctx, struct amount_msat htlc_msat, const u8 *channel_update)
{
u16 len = tal_count(channel_update);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_FEE_INSUFFICIENT);
towire_amount_msat(&p, htlc_msat);
towire_u16(&p, len);
towire_u8_array(&p, channel_update, len);
return memcheck(p, tal_count(p));
}
bool fromwire_fee_insufficient(const tal_t *ctx, const void *p, struct amount_msat *htlc_msat, u8 **channel_update)
{
u16 len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_FEE_INSUFFICIENT)
return false;
*htlc_msat = fromwire_amount_msat(&cursor, &plen);
len = fromwire_u16(&cursor, &plen);
// 2nd case channel_update
*channel_update = len ? tal_arr(ctx, u8, len) : NULL;
fromwire_u8_array(&cursor, &plen, *channel_update, len);
return cursor != NULL;
}
/* WIRE: INCORRECT_CLTV_EXPIRY */
u8 *towire_incorrect_cltv_expiry(const tal_t *ctx, u32 cltv_expiry, const u8 *channel_update)
{
u16 len = tal_count(channel_update);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_INCORRECT_CLTV_EXPIRY);
towire_u32(&p, cltv_expiry);
towire_u16(&p, len);
towire_u8_array(&p, channel_update, len);
return memcheck(p, tal_count(p));
}
bool fromwire_incorrect_cltv_expiry(const tal_t *ctx, const void *p, u32 *cltv_expiry, u8 **channel_update)
{
u16 len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_INCORRECT_CLTV_EXPIRY)
return false;
*cltv_expiry = fromwire_u32(&cursor, &plen);
len = fromwire_u16(&cursor, &plen);
// 2nd case channel_update
*channel_update = len ? tal_arr(ctx, u8, len) : NULL;
fromwire_u8_array(&cursor, &plen, *channel_update, len);
return cursor != NULL;
}
/* WIRE: EXPIRY_TOO_SOON */
u8 *towire_expiry_too_soon(const tal_t *ctx, const u8 *channel_update)
{
u16 len = tal_count(channel_update);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_EXPIRY_TOO_SOON);
towire_u16(&p, len);
towire_u8_array(&p, channel_update, len);
return memcheck(p, tal_count(p));
}
bool fromwire_expiry_too_soon(const tal_t *ctx, const void *p, u8 **channel_update)
{
u16 len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_EXPIRY_TOO_SOON)
return false;
len = fromwire_u16(&cursor, &plen);
// 2nd case channel_update
*channel_update = len ? tal_arr(ctx, u8, len) : NULL;
fromwire_u8_array(&cursor, &plen, *channel_update, len);
return cursor != NULL;
}
/* WIRE: INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS */
u8 *towire_incorrect_or_unknown_payment_details(const tal_t *ctx, struct amount_msat htlc_msat, u32 height)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS);
towire_amount_msat(&p, htlc_msat);
towire_u32(&p, height);
return memcheck(p, tal_count(p));
}
bool fromwire_incorrect_or_unknown_payment_details(const void *p, struct amount_msat *htlc_msat, u32 *height)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS)
return false;
*htlc_msat = fromwire_amount_msat(&cursor, &plen);
*height = fromwire_u32(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: FINAL_INCORRECT_CLTV_EXPIRY */
u8 *towire_final_incorrect_cltv_expiry(const tal_t *ctx, u32 cltv_expiry)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_FINAL_INCORRECT_CLTV_EXPIRY);
towire_u32(&p, cltv_expiry);
return memcheck(p, tal_count(p));
}
bool fromwire_final_incorrect_cltv_expiry(const void *p, u32 *cltv_expiry)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_FINAL_INCORRECT_CLTV_EXPIRY)
return false;
*cltv_expiry = fromwire_u32(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: FINAL_INCORRECT_HTLC_AMOUNT */
u8 *towire_final_incorrect_htlc_amount(const tal_t *ctx, struct amount_msat incoming_htlc_amt)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_FINAL_INCORRECT_HTLC_AMOUNT);
towire_amount_msat(&p, incoming_htlc_amt);
return memcheck(p, tal_count(p));
}
bool fromwire_final_incorrect_htlc_amount(const void *p, struct amount_msat *incoming_htlc_amt)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_FINAL_INCORRECT_HTLC_AMOUNT)
return false;
*incoming_htlc_amt = fromwire_amount_msat(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: CHANNEL_DISABLED */
u8 *towire_channel_disabled(const tal_t *ctx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_CHANNEL_DISABLED);
return memcheck(p, tal_count(p));
}
bool fromwire_channel_disabled(const void *p)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_CHANNEL_DISABLED)
return false;
return cursor != NULL;
}
/* WIRE: EXPIRY_TOO_FAR */
u8 *towire_expiry_too_far(const tal_t *ctx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_EXPIRY_TOO_FAR);
return memcheck(p, tal_count(p));
}
bool fromwire_expiry_too_far(const void *p)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_EXPIRY_TOO_FAR)
return false;
return cursor != NULL;
}
/* WIRE: INVALID_ONION_PAYLOAD */
u8 *towire_invalid_onion_payload(const tal_t *ctx, bigsize type, u16 offset)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_INVALID_ONION_PAYLOAD);
towire_bigsize(&p, type);
towire_u16(&p, offset);
return memcheck(p, tal_count(p));
}
bool fromwire_invalid_onion_payload(const void *p, bigsize *type, u16 *offset)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_INVALID_ONION_PAYLOAD)
return false;
*type = fromwire_bigsize(&cursor, &plen);
*offset = fromwire_u16(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: MPP_TIMEOUT */
u8 *towire_mpp_timeout(const tal_t *ctx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_MPP_TIMEOUT);
return memcheck(p, tal_count(p));
}
bool fromwire_mpp_timeout(const void *p)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_MPP_TIMEOUT)
return false;
return cursor != NULL;
}
// SHA256STAMP:exp-0-fb3c7a1b699d41c2fe76eb380a851fe8aea7a15e7740ce2bfdcb3fcf173a1e8a

211
wire/onion_wiregen.h

@ -0,0 +1,211 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the _csv file it was generated from. */
/* Original template can be found at tools/gen/header_template */
#ifndef LIGHTNING_WIRE_ONION_WIREGEN_H
#define LIGHTNING_WIRE_ONION_WIREGEN_H
#include <ccan/tal/tal.h>
#include <wire/tlvstream.h>
#include <wire/wire.h>
#include <bitcoin/short_channel_id.h>
#include <bitcoin/privkey.h>
#include <common/bigsize.h>
#include <common/amount.h>
#include <common/node_id.h>
#include <bitcoin/block.h>
#include <wire/onion_defs.h>
enum onion_wire {
WIRE_INVALID_REALM = PERM|1,
WIRE_TEMPORARY_NODE_FAILURE = NODE|2,
WIRE_PERMANENT_NODE_FAILURE = PERM|NODE|2,
WIRE_REQUIRED_NODE_FEATURE_MISSING = PERM|NODE|3,
WIRE_INVALID_ONION_VERSION = BADONION|PERM|4,
WIRE_INVALID_ONION_HMAC = BADONION|PERM|5,
WIRE_INVALID_ONION_KEY = BADONION|PERM|6,
WIRE_TEMPORARY_CHANNEL_FAILURE = UPDATE|7,
WIRE_PERMANENT_CHANNEL_FAILURE = PERM|8,
WIRE_REQUIRED_CHANNEL_FEATURE_MISSING = PERM|9,
WIRE_UNKNOWN_NEXT_PEER = PERM|10,
WIRE_AMOUNT_BELOW_MINIMUM = UPDATE|11,
WIRE_FEE_INSUFFICIENT = UPDATE|12,
WIRE_INCORRECT_CLTV_EXPIRY = UPDATE|13,
WIRE_EXPIRY_TOO_SOON = UPDATE|14,
WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS = PERM|15,
WIRE_FINAL_INCORRECT_CLTV_EXPIRY = 18,
WIRE_FINAL_INCORRECT_HTLC_AMOUNT = 19,
WIRE_CHANNEL_DISABLED = UPDATE|20,
WIRE_EXPIRY_TOO_FAR = 21,
WIRE_INVALID_ONION_PAYLOAD = PERM|22,
WIRE_MPP_TIMEOUT = 23,
};
const char *onion_wire_name(int e);
/**
* Determine whether a given message type is defined as a message.
*
* Returns true if the message type is part of the message definitions we have
* generated parsers for, false if it is a custom message that cannot be
* handled internally.
*/
bool onion_wire_is_defined(u16 type);
struct tlv_tlv_payload_payment_data {
struct secret payment_secret;
u64 total_msat;
};
struct tlv_tlv_payload {
/* Raw fields including unknown ones. */
struct tlv_field *fields;
/* TODO The following explicit fields could just point into the
* tlv_field entries above to save on memory. */
u64 *amt_to_forward;
u32 *outgoing_cltv_value;
struct short_channel_id *short_channel_id;
struct tlv_tlv_payload_payment_data *payment_data;
};
struct tlv_tlv_payload *tlv_tlv_payload_new(const tal_t *ctx);
/**
* Deserialize a TLV stream for the tlv_payload namespace.
*
* This function will parse any TLV stream, as long as the type, length and
* value fields are formatted correctly. Fields that are not known in the
* current namespace are stored in the `fields` member. Validity can be
* checked using tlv_payload_is_valid.
*/
bool fromwire_tlv_payload(const u8 **cursor, size_t *max,
struct tlv_tlv_payload * record);
/**
* Serialize a TLV stream for the tlv_payload namespace.
*
* This function only considers known fields from the tlv_payload namespace,
* and will ignore any fields that may be stored in the `fields` member. This
* ensures that the resulting stream is valid according to
* `tlv_payload_is_valid`.
*/
void towire_tlv_payload(u8 **pptr, const void *record);
/**
* Check that the TLV stream is valid.
*
* Enforces the followin validity rules:
* - Types must be in monotonic non-repeating order
* - We must understand all even types
*
* Returns false if an error was detected, otherwise returns true. If err_index
* is non-null and we detect an error it is set to the index of the first error
* detected.
*/
bool tlv_payload_is_valid(const struct tlv_tlv_payload *record,
size_t *err_index);
#define TLVS_TLV_PAYLOAD_ARRAY_SIZE 4
extern const struct tlv_record_type tlvs_tlv_payload[];
/* Define an enum with the constants */
enum tlv_payload_types {
TLV_TLV_PAYLOAD_AMT_TO_FORWARD = 2,
TLV_TLV_PAYLOAD_OUTGOING_CLTV_VALUE = 4,
TLV_TLV_PAYLOAD_SHORT_CHANNEL_ID = 6,
TLV_TLV_PAYLOAD_PAYMENT_DATA = 8,
};
/* WIRE: INVALID_REALM */
u8 *towire_invalid_realm(const tal_t *ctx);
bool fromwire_invalid_realm(const void *p);
/* WIRE: TEMPORARY_NODE_FAILURE */
u8 *towire_temporary_node_failure(const tal_t *ctx);
bool fromwire_temporary_node_failure(const void *p);
/* WIRE: PERMANENT_NODE_FAILURE */
u8 *towire_permanent_node_failure(const tal_t *ctx);
bool fromwire_permanent_node_failure(const void *p);
/* WIRE: REQUIRED_NODE_FEATURE_MISSING */
u8 *towire_required_node_feature_missing(const tal_t *ctx);
bool fromwire_required_node_feature_missing(const void *p);
/* WIRE: INVALID_ONION_VERSION */
u8 *towire_invalid_onion_version(const tal_t *ctx, const struct sha256 *sha256_of_onion);
bool fromwire_invalid_onion_version(const void *p, struct sha256 *sha256_of_onion);
/* WIRE: INVALID_ONION_HMAC */
u8 *towire_invalid_onion_hmac(const tal_t *ctx, const struct sha256 *sha256_of_onion);
bool fromwire_invalid_onion_hmac(const void *p, struct sha256 *sha256_of_onion);
/* WIRE: INVALID_ONION_KEY */
u8 *towire_invalid_onion_key(const tal_t *ctx, const struct sha256 *sha256_of_onion);
bool fromwire_invalid_onion_key(const void *p, struct sha256 *sha256_of_onion);
/* WIRE: TEMPORARY_CHANNEL_FAILURE */
u8 *towire_temporary_channel_failure(const tal_t *ctx, const u8 *channel_update);
bool fromwire_temporary_channel_failure(const tal_t *ctx, const void *p, u8 **channel_update);
/* WIRE: PERMANENT_CHANNEL_FAILURE */
u8 *towire_permanent_channel_failure(const tal_t *ctx);
bool fromwire_permanent_channel_failure(const void *p);
/* WIRE: REQUIRED_CHANNEL_FEATURE_MISSING */
u8 *towire_required_channel_feature_missing(const tal_t *ctx);
bool fromwire_required_channel_feature_missing(const void *p);
/* WIRE: UNKNOWN_NEXT_PEER */
u8 *towire_unknown_next_peer(const tal_t *ctx);
bool fromwire_unknown_next_peer(const void *p);
/* WIRE: AMOUNT_BELOW_MINIMUM */
u8 *towire_amount_below_minimum(const tal_t *ctx, struct amount_msat htlc_msat, const u8 *channel_update);
bool fromwire_amount_below_minimum(const tal_t *ctx, const void *p, struct amount_msat *htlc_msat, u8 **channel_update);
/* WIRE: FEE_INSUFFICIENT */
u8 *towire_fee_insufficient(const tal_t *ctx, struct amount_msat htlc_msat, const u8 *channel_update);
bool fromwire_fee_insufficient(const tal_t *ctx, const void *p, struct amount_msat *htlc_msat, u8 **channel_update);
/* WIRE: INCORRECT_CLTV_EXPIRY */
u8 *towire_incorrect_cltv_expiry(const tal_t *ctx, u32 cltv_expiry, const u8 *channel_update);
bool fromwire_incorrect_cltv_expiry(const tal_t *ctx, const void *p, u32 *cltv_expiry, u8 **channel_update);
/* WIRE: EXPIRY_TOO_SOON */
u8 *towire_expiry_too_soon(const tal_t *ctx, const u8 *channel_update);
bool fromwire_expiry_too_soon(const tal_t *ctx, const void *p, u8 **channel_update);
/* WIRE: INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS */
u8 *towire_incorrect_or_unknown_payment_details(const tal_t *ctx, struct amount_msat htlc_msat, u32 height);
bool fromwire_incorrect_or_unknown_payment_details(const void *p, struct amount_msat *htlc_msat, u32 *height);
/* WIRE: FINAL_INCORRECT_CLTV_EXPIRY */
u8 *towire_final_incorrect_cltv_expiry(const tal_t *ctx, u32 cltv_expiry);
bool fromwire_final_incorrect_cltv_expiry(const void *p, u32 *cltv_expiry);
/* WIRE: FINAL_INCORRECT_HTLC_AMOUNT */
u8 *towire_final_incorrect_htlc_amount(const tal_t *ctx, struct amount_msat incoming_htlc_amt);
bool fromwire_final_incorrect_htlc_amount(const void *p, struct amount_msat *incoming_htlc_amt);
/* WIRE: CHANNEL_DISABLED */
u8 *towire_channel_disabled(const tal_t *ctx);
bool fromwire_channel_disabled(const void *p);
/* WIRE: EXPIRY_TOO_FAR */
u8 *towire_expiry_too_far(const tal_t *ctx);
bool fromwire_expiry_too_far(const void *p);
/* WIRE: INVALID_ONION_PAYLOAD */
u8 *towire_invalid_onion_payload(const tal_t *ctx, bigsize type, u16 offset);
bool fromwire_invalid_onion_payload(const void *p, bigsize *type, u16 *offset);
/* WIRE: MPP_TIMEOUT */
u8 *towire_mpp_timeout(const tal_t *ctx);
bool fromwire_mpp_timeout(const void *p);
#endif /* LIGHTNING_WIRE_ONION_WIREGEN_H */
// SHA256STAMP:exp-0-fb3c7a1b699d41c2fe76eb380a851fe8aea7a15e7740ce2bfdcb3fcf173a1e8a

2040
wire/peer_printgen.c

File diff suppressed because it is too large

74
wire/peer_printgen.h

@ -0,0 +1,74 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the .csv file it was generated from. */
/* Template located at tools/gen/print_header_template */
#ifndef LIGHTNING_WIRE_PEER_PRINTGEN_H
#define LIGHTNING_WIRE_PEER_PRINTGEN_H
#include <ccan/tal/tal.h>
#include <devtools/print_wire.h>
void printpeer_wire_message(const u8 *msg);
void printpeer_wire_tlv_message(const char *tlv_name, const u8 *msg);
void printwire_init(const char *fieldname, const u8 *cursor);
void printwire_error(const char *fieldname, const u8 *cursor);
void printwire_ping(const char *fieldname, const u8 *cursor);
void printwire_pong(const char *fieldname, const u8 *cursor);
void printwire_open_channel(const char *fieldname, const u8 *cursor);
void printwire_accept_channel(const char *fieldname, const u8 *cursor);
void printwire_funding_created(const char *fieldname, const u8 *cursor);
void printwire_funding_signed(const char *fieldname, const u8 *cursor);
void printwire_funding_locked(const char *fieldname, const u8 *cursor);
void printwire_shutdown(const char *fieldname, const u8 *cursor);
void printwire_closing_signed(const char *fieldname, const u8 *cursor);
void printwire_update_add_htlc(const char *fieldname, const u8 *cursor);
void printwire_update_fulfill_htlc(const char *fieldname, const u8 *cursor);
void printwire_update_fail_htlc(const char *fieldname, const u8 *cursor);
void printwire_update_fail_malformed_htlc(const char *fieldname, const u8 *cursor);
void printwire_commitment_signed(const char *fieldname, const u8 *cursor);
void printwire_revoke_and_ack(const char *fieldname, const u8 *cursor);
void printwire_update_fee(const char *fieldname, const u8 *cursor);
void printwire_channel_reestablish(const char *fieldname, const u8 *cursor);
void printwire_announcement_signatures(const char *fieldname, const u8 *cursor);
void printwire_channel_announcement(const char *fieldname, const u8 *cursor);
void printwire_node_announcement(const char *fieldname, const u8 *cursor);
void printwire_channel_update(const char *fieldname, const u8 *cursor);
void printwire_query_short_channel_ids(const char *fieldname, const u8 *cursor);
void printwire_reply_short_channel_ids_end(const char *fieldname, const u8 *cursor);
void printwire_query_channel_range(const char *fieldname, const u8 *cursor);
void printwire_reply_channel_range(const char *fieldname, const u8 *cursor);
void printwire_gossip_timestamp_filter(const char *fieldname, const u8 *cursor);
void printwire_channel_update_checksums(const char *fieldname, const u8 **cursor, size_t *plen);
void printwire_channel_update_timestamps(const char *fieldname, const u8 **cursor, size_t *plen);
#endif /* LIGHTNING_WIRE_PEER_PRINTGEN_H */
// SHA256STAMP:exp-0-12bb4b7e8e380207af3b51bfc2b65997753bc3d37465eed70409a21998b50238

2754
wire/peer_wiregen.c

File diff suppressed because it is too large

599
wire/peer_wiregen.h

@ -0,0 +1,599 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the _csv file it was generated from. */
/* Original template can be found at tools/gen/header_template */
#ifndef LIGHTNING_WIRE_PEER_WIREGEN_H
#define LIGHTNING_WIRE_PEER_WIREGEN_H
#include <ccan/tal/tal.h>
#include <wire/tlvstream.h>
#include <wire/wire.h>
#include <common/channel_id.h>
#include <bitcoin/tx.h>
#include <bitcoin/preimage.h>
#include <bitcoin/short_channel_id.h>
#include <common/node_id.h>
#include <common/bigsize.h>
#include <bitcoin/block.h>
#include <bitcoin/privkey.h>
enum peer_wire {
WIRE_INIT = 16,
WIRE_ERROR = 17,
WIRE_PING = 18,
WIRE_PONG = 19,
WIRE_OPEN_CHANNEL = 32,
WIRE_ACCEPT_CHANNEL = 33,
WIRE_FUNDING_CREATED = 34,
WIRE_FUNDING_SIGNED = 35,
WIRE_FUNDING_LOCKED = 36,
WIRE_SHUTDOWN = 38,
WIRE_CLOSING_SIGNED = 39,
WIRE_UPDATE_ADD_HTLC = 128,
WIRE_UPDATE_FULFILL_HTLC = 130,
WIRE_UPDATE_FAIL_HTLC = 131,
WIRE_UPDATE_FAIL_MALFORMED_HTLC = 135,
WIRE_COMMITMENT_SIGNED = 132,
WIRE_REVOKE_AND_ACK = 133,
WIRE_UPDATE_FEE = 134,
WIRE_CHANNEL_REESTABLISH = 136,
WIRE_ANNOUNCEMENT_SIGNATURES = 259,
WIRE_CHANNEL_ANNOUNCEMENT = 256,
WIRE_NODE_ANNOUNCEMENT = 257,
WIRE_CHANNEL_UPDATE = 258,
WIRE_QUERY_SHORT_CHANNEL_IDS = 261,
WIRE_REPLY_SHORT_CHANNEL_IDS_END = 262,
WIRE_QUERY_CHANNEL_RANGE = 263,
WIRE_REPLY_CHANNEL_RANGE = 264,
WIRE_GOSSIP_TIMESTAMP_FILTER = 265,
};
const char *peer_wire_name(int e);
/**
* Determine whether a given message type is defined as a message.
*
* Returns true if the message type is part of the message definitions we have
* generated parsers for, false if it is a custom message that cannot be
* handled internally.
*/
bool peer_wire_is_defined(u16 type);
struct channel_update_checksums {
u32 checksum_node_id_1;
u32 checksum_node_id_2;
};
struct channel_update_timestamps {
u32 timestamp_node_id_1;
u32 timestamp_node_id_2;
};
struct tlv_n1_tlv3 {
struct pubkey node_id;
struct amount_msat amount_msat_1;
struct amount_msat amount_msat_2;
};
struct tlv_query_short_channel_ids_tlvs_query_flags {
u8 encoding_type;
u8 *encoded_query_flags;
};
struct tlv_reply_channel_range_tlvs_timestamps_tlv {
u8 encoding_type;
u8 *encoded_timestamps;
};
struct tlv_init_tlvs {
/* Raw fields including unknown ones. */
struct tlv_field *fields;
/* TODO The following explicit fields could just point into the
* tlv_field entries above to save on memory. */
struct bitcoin_blkid *networks;
};
struct tlv_n1 {
/* Raw fields including unknown ones. */
struct tlv_field *fields;
/* TODO The following explicit fields could just point into the
* tlv_field entries above to save on memory. */
u64 *tlv1;
struct short_channel_id *tlv2;
struct tlv_n1_tlv3 *tlv3;
u16 *tlv4;
};
struct tlv_n2 {
/* Raw fields including unknown ones. */
struct tlv_field *fields;
/* TODO The following explicit fields could just point into the
* tlv_field entries above to save on memory. */
u64 *tlv1;
u32 *tlv2;
};
struct tlv_open_channel_tlvs {
/* Raw fields including unknown ones. */
struct tlv_field *fields;
/* TODO The following explicit fields could just point into the
* tlv_field entries above to save on memory. */
u8 *upfront_shutdown_script;
};
struct tlv_accept_channel_tlvs {
/* Raw fields including unknown ones. */
struct tlv_field *fields;
/* TODO The following explicit fields could just point into the
* tlv_field entries above to save on memory. */
u8 *upfront_shutdown_script;
};
struct tlv_query_short_channel_ids_tlvs {
/* Raw fields including unknown ones. */
struct tlv_field *fields;
/* TODO The following explicit fields could just point into the
* tlv_field entries above to save on memory. */
struct tlv_query_short_channel_ids_tlvs_query_flags *query_flags;
};
struct tlv_query_channel_range_tlvs {
/* Raw fields including unknown ones. */
struct tlv_field *fields;
/* TODO The following explicit fields could just point into the
* tlv_field entries above to save on memory. */
bigsize *query_option;
};
struct tlv_reply_channel_range_tlvs {
/* Raw fields including unknown ones. */
struct tlv_field *fields;
/* TODO The following explicit fields could just point into the
* tlv_field entries above to save on memory. */
struct tlv_reply_channel_range_tlvs_timestamps_tlv *timestamps_tlv;
struct channel_update_checksums *checksums_tlv;
};
struct tlv_init_tlvs *tlv_init_tlvs_new(const tal_t *ctx);
/**
* Deserialize a TLV stream for the init_tlvs namespace.
*
* This function will parse any TLV stream, as long as the type, length and
* value fields are formatted correctly. Fields that are not known in the
* current namespace are stored in the `fields` member. Validity can be
* checked using init_tlvs_is_valid.
*/
bool fromwire_init_tlvs(const u8 **cursor, size_t *max,
struct tlv_init_tlvs * record);
/**
* Serialize a TLV stream for the init_tlvs namespace.
*
* This function only considers known fields from the init_tlvs namespace,
* and will ignore any fields that may be stored in the `fields` member. This
* ensures that the resulting stream is valid according to
* `init_tlvs_is_valid`.
*/
void towire_init_tlvs(u8 **pptr, const void *record);
/**
* Check that the TLV stream is valid.
*
* Enforces the followin validity rules:
* - Types must be in monotonic non-repeating order
* - We must understand all even types
*
* Returns false if an error was detected, otherwise returns true. If err_index
* is non-null and we detect an error it is set to the index of the first error
* detected.
*/
bool init_tlvs_is_valid(const struct tlv_init_tlvs *record,
size_t *err_index);
struct tlv_n1 *tlv_n1_new(const tal_t *ctx);
/**
* Deserialize a TLV stream for the n1 namespace.
*
* This function will parse any TLV stream, as long as the type, length and
* value fields are formatted correctly. Fields that are not known in the
* current namespace are stored in the `fields` member. Validity can be
* checked using n1_is_valid.
*/
bool fromwire_n1(const u8 **cursor, size_t *max,
struct tlv_n1 * record);
/**
* Serialize a TLV stream for the n1 namespace.
*
* This function only considers known fields from the n1 namespace,
* and will ignore any fields that may be stored in the `fields` member. This
* ensures that the resulting stream is valid according to
* `n1_is_valid`.
*/
void towire_n1(u8 **pptr, const void *record);
/**
* Check that the TLV stream is valid.
*
* Enforces the followin validity rules:
* - Types must be in monotonic non-repeating order
* - We must understand all even types
*
* Returns false if an error was detected, otherwise returns true. If err_index
* is non-null and we detect an error it is set to the index of the first error
* detected.
*/
bool n1_is_valid(const struct tlv_n1 *record,
size_t *err_index);
#define TLVS_N1_ARRAY_SIZE 4
extern const struct tlv_record_type tlvs_n1[];
/* Define an enum with the constants */
enum n1_types {
TLV_N1_TLV1 = 1,
TLV_N1_TLV2 = 2,
TLV_N1_TLV3 = 3,
TLV_N1_TLV4 = 254,
};
struct tlv_n2 *tlv_n2_new(const tal_t *ctx);
/**
* Deserialize a TLV stream for the n2 namespace.
*
* This function will parse any TLV stream, as long as the type, length and
* value fields are formatted correctly. Fields that are not known in the
* current namespace are stored in the `fields` member. Validity can be
* checked using n2_is_valid.
*/
bool fromwire_n2(const u8 **cursor, size_t *max,
struct tlv_n2 * record);
/**
* Serialize a TLV stream for the n2 namespace.
*
* This function only considers known fields from the n2 namespace,
* and will ignore any fields that may be stored in the `fields` member. This
* ensures that the resulting stream is valid according to
* `n2_is_valid`.
*/
void towire_n2(u8 **pptr, const void *record);
/**
* Check that the TLV stream is valid.
*
* Enforces the followin validity rules:
* - Types must be in monotonic non-repeating order
* - We must understand all even types
*
* Returns false if an error was detected, otherwise returns true. If err_index
* is non-null and we detect an error it is set to the index of the first error
* detected.
*/
bool n2_is_valid(const struct tlv_n2 *record,
size_t *err_index);
#define TLVS_N2_ARRAY_SIZE 2
extern const struct tlv_record_type tlvs_n2[];
/* Define an enum with the constants */
enum n2_types {
TLV_N2_TLV1 = 0,
TLV_N2_TLV2 = 11,
};
struct tlv_open_channel_tlvs *tlv_open_channel_tlvs_new(const tal_t *ctx);
/**
* Deserialize a TLV stream for the open_channel_tlvs namespace.
*
* This function will parse any TLV stream, as long as the type, length and
* value fields are formatted correctly. Fields that are not known in the
* current namespace are stored in the `fields` member. Validity can be
* checked using open_channel_tlvs_is_valid.
*/
bool fromwire_open_channel_tlvs(const u8 **cursor, size_t *max,
struct tlv_open_channel_tlvs * record);
/**
* Serialize a TLV stream for the open_channel_tlvs namespace.
*
* This function only considers known fields from the open_channel_tlvs namespace,
* and will ignore any fields that may be stored in the `fields` member. This
* ensures that the resulting stream is valid according to
* `open_channel_tlvs_is_valid`.
*/
void towire_open_channel_tlvs(u8 **pptr, const void *record);
/**
* Check that the TLV stream is valid.
*
* Enforces the followin validity rules:
* - Types must be in monotonic non-repeating order
* - We must understand all even types
*
* Returns false if an error was detected, otherwise returns true. If err_index
* is non-null and we detect an error it is set to the index of the first error
* detected.
*/
bool open_channel_tlvs_is_valid(const struct tlv_open_channel_tlvs *record,
size_t *err_index);
struct tlv_accept_channel_tlvs *tlv_accept_channel_tlvs_new(const tal_t *ctx);
/**
* Deserialize a TLV stream for the accept_channel_tlvs namespace.
*
* This function will parse any TLV stream, as long as the type, length and
* value fields are formatted correctly. Fields that are not known in the
* current namespace are stored in the `fields` member. Validity can be
* checked using accept_channel_tlvs_is_valid.
*/
bool fromwire_accept_channel_tlvs(const u8 **cursor, size_t *max,
struct tlv_accept_channel_tlvs * record);
/**
* Serialize a TLV stream for the accept_channel_tlvs namespace.
*
* This function only considers known fields from the accept_channel_tlvs namespace,
* and will ignore any fields that may be stored in the `fields` member. This
* ensures that the resulting stream is valid according to
* `accept_channel_tlvs_is_valid`.
*/
void towire_accept_channel_tlvs(u8 **pptr, const void *record);
/**
* Check that the TLV stream is valid.
*
* Enforces the followin validity rules:
* - Types must be in monotonic non-repeating order
* - We must understand all even types
*
* Returns false if an error was detected, otherwise returns true. If err_index
* is non-null and we detect an error it is set to the index of the first error
* detected.
*/
bool accept_channel_tlvs_is_valid(const struct tlv_accept_channel_tlvs *record,
size_t *err_index);
struct tlv_query_short_channel_ids_tlvs *tlv_query_short_channel_ids_tlvs_new(const tal_t *ctx);
/**
* Deserialize a TLV stream for the query_short_channel_ids_tlvs namespace.
*
* This function will parse any TLV stream, as long as the type, length and
* value fields are formatted correctly. Fields that are not known in the
* current namespace are stored in the `fields` member. Validity can be
* checked using query_short_channel_ids_tlvs_is_valid.
*/
bool fromwire_query_short_channel_ids_tlvs(const u8 **cursor, size_t *max,
struct tlv_query_short_channel_ids_tlvs * record);
/**
* Serialize a TLV stream for the query_short_channel_ids_tlvs namespace.
*
* This function only considers known fields from the query_short_channel_ids_tlvs namespace,
* and will ignore any fields that may be stored in the `fields` member. This
* ensures that the resulting stream is valid according to
* `query_short_channel_ids_tlvs_is_valid`.
*/
void towire_query_short_channel_ids_tlvs(u8 **pptr, const void *record);
/**
* Check that the TLV stream is valid.
*
* Enforces the followin validity rules:
* - Types must be in monotonic non-repeating order
* - We must understand all even types
*
* Returns false if an error was detected, otherwise returns true. If err_index
* is non-null and we detect an error it is set to the index of the first error
* detected.
*/
bool query_short_channel_ids_tlvs_is_valid(const struct tlv_query_short_channel_ids_tlvs *record,
size_t *err_index);
struct tlv_query_channel_range_tlvs *tlv_query_channel_range_tlvs_new(const tal_t *ctx);
/**
* Deserialize a TLV stream for the query_channel_range_tlvs namespace.
*
* This function will parse any TLV stream, as long as the type, length and
* value fields are formatted correctly. Fields that are not known in the
* current namespace are stored in the `fields` member. Validity can be
* checked using query_channel_range_tlvs_is_valid.
*/
bool fromwire_query_channel_range_tlvs(const u8 **cursor, size_t *max,
struct tlv_query_channel_range_tlvs * record);
/**
* Serialize a TLV stream for the query_channel_range_tlvs namespace.
*
* This function only considers known fields from the query_channel_range_tlvs namespace,
* and will ignore any fields that may be stored in the `fields` member. This
* ensures that the resulting stream is valid according to
* `query_channel_range_tlvs_is_valid`.
*/
void towire_query_channel_range_tlvs(u8 **pptr, const void *record);
/**
* Check that the TLV stream is valid.
*
* Enforces the followin validity rules:
* - Types must be in monotonic non-repeating order
* - We must understand all even types
*
* Returns false if an error was detected, otherwise returns true. If err_index
* is non-null and we detect an error it is set to the index of the first error
* detected.
*/
bool query_channel_range_tlvs_is_valid(const struct tlv_query_channel_range_tlvs *record,
size_t *err_index);
struct tlv_reply_channel_range_tlvs *tlv_reply_channel_range_tlvs_new(const tal_t *ctx);
/**
* Deserialize a TLV stream for the reply_channel_range_tlvs namespace.
*
* This function will parse any TLV stream, as long as the type, length and
* value fields are formatted correctly. Fields that are not known in the
* current namespace are stored in the `fields` member. Validity can be
* checked using reply_channel_range_tlvs_is_valid.
*/
bool fromwire_reply_channel_range_tlvs(const u8 **cursor, size_t *max,
struct tlv_reply_channel_range_tlvs * record);
/**
* Serialize a TLV stream for the reply_channel_range_tlvs namespace.
*
* This function only considers known fields from the reply_channel_range_tlvs namespace,
* and will ignore any fields that may be stored in the `fields` member. This
* ensures that the resulting stream is valid according to
* `reply_channel_range_tlvs_is_valid`.
*/
void towire_reply_channel_range_tlvs(u8 **pptr, const void *record);
/**
* Check that the TLV stream is valid.
*
* Enforces the followin validity rules:
* - Types must be in monotonic non-repeating order
* - We must understand all even types
*
* Returns false if an error was detected, otherwise returns true. If err_index
* is non-null and we detect an error it is set to the index of the first error
* detected.
*/
bool reply_channel_range_tlvs_is_valid(const struct tlv_reply_channel_range_tlvs *record,
size_t *err_index);
/* SUBTYPE: CHANNEL_UPDATE_CHECKSUMS */
void towire_channel_update_checksums(u8 **p, const struct channel_update_checksums *channel_update_checksums);
void fromwire_channel_update_checksums(const u8 **cursor, size_t *plen, struct channel_update_checksums *channel_update_checksums);
/* SUBTYPE: CHANNEL_UPDATE_TIMESTAMPS */
void towire_channel_update_timestamps(u8 **p, const struct channel_update_timestamps *channel_update_timestamps);
void fromwire_channel_update_timestamps(const u8 **cursor, size_t *plen, struct channel_update_timestamps *channel_update_timestamps);
/* WIRE: INIT */
u8 *towire_init(const tal_t *ctx, const u8 *globalfeatures, const u8 *features, const struct tlv_init_tlvs *tlvs);
bool fromwire_init(const tal_t *ctx, const void *p, u8 **globalfeatures, u8 **features, struct tlv_init_tlvs *tlvs);
/* WIRE: ERROR */
u8 *towire_error(const tal_t *ctx, const struct channel_id *channel_id, const u8 *data);
bool fromwire_error(const tal_t *ctx, const void *p, struct channel_id *channel_id, u8 **data);
/* WIRE: PING */
u8 *towire_ping(const tal_t *ctx, u16 num_pong_bytes, const u8 *ignored);
bool fromwire_ping(const tal_t *ctx, const void *p, u16 *num_pong_bytes, u8 **ignored);
/* WIRE: PONG */
u8 *towire_pong(const tal_t *ctx, const u8 *ignored);
bool fromwire_pong(const tal_t *ctx, const void *p, u8 **ignored);
/* WIRE: OPEN_CHANNEL */
u8 *towire_open_channel(const tal_t *ctx, const struct bitcoin_blkid *chain_hash, const struct channel_id *temporary_channel_id, struct amount_sat funding_satoshis, struct amount_msat push_msat, struct amount_sat dust_limit_satoshis, struct amount_msat max_htlc_value_in_flight_msat, struct amount_sat channel_reserve_satoshis, struct amount_msat htlc_minimum_msat, u32 feerate_per_kw, u16 to_self_delay, u16 max_accepted_htlcs, const struct pubkey *funding_pubkey, const struct pubkey *revocation_basepoint, const struct pubkey *payment_basepoint, const struct pubkey *delayed_payment_basepoint, const struct pubkey *htlc_basepoint, const struct pubkey *first_per_commitment_point, u8 channel_flags, const struct tlv_open_channel_tlvs *tlvs);
bool fromwire_open_channel(const void *p, struct bitcoin_blkid *chain_hash, struct channel_id *temporary_channel_id, struct amount_sat *funding_satoshis, struct amount_msat *push_msat, struct amount_sat *dust_limit_satoshis, struct amount_msat *max_htlc_value_in_flight_msat, struct amount_sat *channel_reserve_satoshis, struct amount_msat *htlc_minimum_msat, u32 *feerate_per_kw, u16 *to_self_delay, u16 *max_accepted_htlcs, struct pubkey *funding_pubkey, struct pubkey *revocation_basepoint, struct pubkey *payment_basepoint, struct pubkey *delayed_payment_basepoint, struct pubkey *htlc_basepoint, struct pubkey *first_per_commitment_point, u8 *channel_flags, struct tlv_open_channel_tlvs *tlvs);
/* WIRE: ACCEPT_CHANNEL */
u8 *towire_accept_channel(const tal_t *ctx, const struct channel_id *temporary_channel_id, struct amount_sat dust_limit_satoshis, struct amount_msat max_htlc_value_in_flight_msat, struct amount_sat channel_reserve_satoshis, struct amount_msat htlc_minimum_msat, u32 minimum_depth, u16 to_self_delay, u16 max_accepted_htlcs, const struct pubkey *funding_pubkey, const struct pubkey *revocation_basepoint, const struct pubkey *payment_basepoint, const struct pubkey *delayed_payment_basepoint, const struct pubkey *htlc_basepoint, const struct pubkey *first_per_commitment_point, const struct tlv_accept_channel_tlvs *tlvs);
bool fromwire_accept_channel(const void *p, struct channel_id *temporary_channel_id, struct amount_sat *dust_limit_satoshis, struct amount_msat *max_htlc_value_in_flight_msat, struct amount_sat *channel_reserve_satoshis, struct amount_msat *htlc_minimum_msat, u32 *minimum_depth, u16 *to_self_delay, u16 *max_accepted_htlcs, struct pubkey *funding_pubkey, struct pubkey *revocation_basepoint, struct pubkey *payment_basepoint, struct pubkey *delayed_payment_basepoint, struct pubkey *htlc_basepoint, struct pubkey *first_per_commitment_point, struct tlv_accept_channel_tlvs *tlvs);
/* WIRE: FUNDING_CREATED */
u8 *towire_funding_created(const tal_t *ctx, const struct channel_id *temporary_channel_id, const struct bitcoin_txid *funding_txid, u16 funding_output_index, const secp256k1_ecdsa_signature *signature);
bool fromwire_funding_created(const void *p, struct channel_id *temporary_channel_id, struct bitcoin_txid *funding_txid, u16 *funding_output_index, secp256k1_ecdsa_signature *signature);
/* WIRE: FUNDING_SIGNED */
u8 *towire_funding_signed(const tal_t *ctx, const struct channel_id *channel_id, const secp256k1_ecdsa_signature *signature);
bool fromwire_funding_signed(const void *p, struct channel_id *channel_id, secp256k1_ecdsa_signature *signature);
/* WIRE: FUNDING_LOCKED */
u8 *towire_funding_locked(const tal_t *ctx, const struct channel_id *channel_id, const struct pubkey *next_per_commitment_point);
bool fromwire_funding_locked(const void *p, struct channel_id *channel_id, struct pubkey *next_per_commitment_point);
/* WIRE: SHUTDOWN */
u8 *towire_shutdown(const tal_t *ctx, const struct channel_id *channel_id, const u8 *scriptpubkey);
bool fromwire_shutdown(const tal_t *ctx, const void *p, struct channel_id *channel_id, u8 **scriptpubkey);
/* WIRE: CLOSING_SIGNED */
u8 *towire_closing_signed(const tal_t *ctx, const struct channel_id *channel_id, struct amount_sat fee_satoshis, const secp256k1_ecdsa_signature *signature);
bool fromwire_closing_signed(const void *p, struct channel_id *channel_id, struct amount_sat *fee_satoshis, secp256k1_ecdsa_signature *signature);
/* WIRE: UPDATE_ADD_HTLC */
u8 *towire_update_add_htlc(const tal_t *ctx, const struct channel_id *channel_id, u64 id, struct amount_msat amount_msat, const struct sha256 *payment_hash, u32 cltv_expiry, const u8 onion_routing_packet[1366]);
bool fromwire_update_add_htlc(const void *p, struct channel_id *channel_id, u64 *id, struct amount_msat *amount_msat, struct sha256 *payment_hash, u32 *cltv_expiry, u8 onion_routing_packet[1366]);
/* WIRE: UPDATE_FULFILL_HTLC */
u8 *towire_update_fulfill_htlc(const tal_t *ctx, const struct channel_id *channel_id, u64 id, const struct preimage *payment_preimage);
bool fromwire_update_fulfill_htlc(const void *p, struct channel_id *channel_id, u64 *id, struct preimage *payment_preimage);
/* WIRE: UPDATE_FAIL_HTLC */
u8 *towire_update_fail_htlc(const tal_t *ctx, const struct channel_id *channel_id, u64 id, const u8 *reason);
bool fromwire_update_fail_htlc(const tal_t *ctx, const void *p, struct channel_id *channel_id, u64 *id, u8 **reason);
/* WIRE: UPDATE_FAIL_MALFORMED_HTLC */
u8 *towire_update_fail_malformed_htlc(const tal_t *ctx, const struct channel_id *channel_id, u64 id, const struct sha256 *sha256_of_onion, u16 failure_code);
bool fromwire_update_fail_malformed_htlc(const void *p, struct channel_id *channel_id, u64 *id, struct sha256 *sha256_of_onion, u16 *failure_code);
/* WIRE: COMMITMENT_SIGNED */
u8 *towire_commitment_signed(const tal_t *ctx, const struct channel_id *channel_id, const secp256k1_ecdsa_signature *signature, const secp256k1_ecdsa_signature *htlc_signature);
bool fromwire_commitment_signed(const tal_t *ctx, const void *p, struct channel_id *channel_id, secp256k1_ecdsa_signature *signature, secp256k1_ecdsa_signature **htlc_signature);
/* WIRE: REVOKE_AND_ACK */
u8 *towire_revoke_and_ack(const tal_t *ctx, const struct channel_id *channel_id, const struct secret *per_commitment_secret, const struct pubkey *next_per_commitment_point);
bool fromwire_revoke_and_ack(const void *p, struct channel_id *channel_id, struct secret *per_commitment_secret, struct pubkey *next_per_commitment_point);
/* WIRE: UPDATE_FEE */
u8 *towire_update_fee(const tal_t *ctx, const struct channel_id *channel_id, u32 feerate_per_kw);
bool fromwire_update_fee(const void *p, struct channel_id *channel_id, u32 *feerate_per_kw);
/* WIRE: CHANNEL_REESTABLISH */
u8 *towire_channel_reestablish(const tal_t *ctx, const struct channel_id *channel_id, u64 next_commitment_number, u64 next_revocation_number, const struct secret *your_last_per_commitment_secret, const struct pubkey *my_current_per_commitment_point);
bool fromwire_channel_reestablish(const void *p, struct channel_id *channel_id, u64 *next_commitment_number, u64 *next_revocation_number, struct secret *your_last_per_commitment_secret, struct pubkey *my_current_per_commitment_point);
/* WIRE: ANNOUNCEMENT_SIGNATURES */
u8 *towire_announcement_signatures(const tal_t *ctx, const struct channel_id *channel_id, const struct short_channel_id *short_channel_id, const secp256k1_ecdsa_signature *node_signature, const secp256k1_ecdsa_signature *bitcoin_signature);
bool fromwire_announcement_signatures(const void *p, struct channel_id *channel_id, struct short_channel_id *short_channel_id, secp256k1_ecdsa_signature *node_signature, secp256k1_ecdsa_signature *bitcoin_signature);
/* WIRE: CHANNEL_ANNOUNCEMENT */
u8 *towire_channel_announcement(const tal_t *ctx, const secp256k1_ecdsa_signature *node_signature_1, const secp256k1_ecdsa_signature *node_signature_2, const secp256k1_ecdsa_signature *bitcoin_signature_1, const secp256k1_ecdsa_signature *bitcoin_signature_2, const u8 *features, const struct bitcoin_blkid *chain_hash, const struct short_channel_id *short_channel_id, const struct node_id *node_id_1, const struct node_id *node_id_2, const struct pubkey *bitcoin_key_1, const struct pubkey *bitcoin_key_2);
bool fromwire_channel_announcement(const tal_t *ctx, const void *p, secp256k1_ecdsa_signature *node_signature_1, secp256k1_ecdsa_signature *node_signature_2, secp256k1_ecdsa_signature *bitcoin_signature_1, secp256k1_ecdsa_signature *bitcoin_signature_2, u8 **features, struct bitcoin_blkid *chain_hash, struct short_channel_id *short_channel_id, struct node_id *node_id_1, struct node_id *node_id_2, struct pubkey *bitcoin_key_1, struct pubkey *bitcoin_key_2);
/* WIRE: NODE_ANNOUNCEMENT */
u8 *towire_node_announcement(const tal_t *ctx, const secp256k1_ecdsa_signature *signature, const u8 *features, u32 timestamp, const struct node_id *node_id, const u8 rgb_color[3], const u8 alias[32], const u8 *addresses);
bool fromwire_node_announcement(const tal_t *ctx, const void *p, secp256k1_ecdsa_signature *signature, u8 **features, u32 *timestamp, struct node_id *node_id, u8 rgb_color[3], u8 alias[32], u8 **addresses);
/* WIRE: CHANNEL_UPDATE */
u8 *towire_channel_update(const tal_t *ctx, const secp256k1_ecdsa_signature *signature, const struct bitcoin_blkid *chain_hash, const struct short_channel_id *short_channel_id, u32 timestamp, u8 message_flags, u8 channel_flags, u16 cltv_expiry_delta, struct amount_msat htlc_minimum_msat, u32 fee_base_msat, u32 fee_proportional_millionths);
bool fromwire_channel_update(const void *p, secp256k1_ecdsa_signature *signature, struct bitcoin_blkid *chain_hash, struct short_channel_id *short_channel_id, u32 *timestamp, u8 *message_flags, u8 *channel_flags, u16 *cltv_expiry_delta, struct amount_msat *htlc_minimum_msat, u32 *fee_base_msat, u32 *fee_proportional_millionths);
/* WIRE: QUERY_SHORT_CHANNEL_IDS */
u8 *towire_query_short_channel_ids(const tal_t *ctx, const struct bitcoin_blkid *chain_hash, const u8 *encoded_short_ids, const struct tlv_query_short_channel_ids_tlvs *tlvs);
bool fromwire_query_short_channel_ids(const tal_t *ctx, const void *p, struct bitcoin_blkid *chain_hash, u8 **encoded_short_ids, struct tlv_query_short_channel_ids_tlvs *tlvs);
/* WIRE: REPLY_SHORT_CHANNEL_IDS_END */
u8 *towire_reply_short_channel_ids_end(const tal_t *ctx, const struct bitcoin_blkid *chain_hash, u8 full_information);
bool fromwire_reply_short_channel_ids_end(const void *p, struct bitcoin_blkid *chain_hash, u8 *full_information);
/* WIRE: QUERY_CHANNEL_RANGE */
u8 *towire_query_channel_range(const tal_t *ctx, const struct bitcoin_blkid *chain_hash, u32 first_blocknum, u32 number_of_blocks, const struct tlv_query_channel_range_tlvs *tlvs);
bool fromwire_query_channel_range(const void *p, struct bitcoin_blkid *chain_hash, u32 *first_blocknum, u32 *number_of_blocks, struct tlv_query_channel_range_tlvs *tlvs);
/* WIRE: REPLY_CHANNEL_RANGE */
u8 *towire_reply_channel_range(const tal_t *ctx, const struct bitcoin_blkid *chain_hash, u32 first_blocknum, u32 number_of_blocks, u8 full_information, const u8 *encoded_short_ids, const struct tlv_reply_channel_range_tlvs *tlvs);
bool fromwire_reply_channel_range(const tal_t *ctx, const void *p, struct bitcoin_blkid *chain_hash, u32 *first_blocknum, u32 *number_of_blocks, u8 *full_information, u8 **encoded_short_ids, struct tlv_reply_channel_range_tlvs *tlvs);
/* WIRE: GOSSIP_TIMESTAMP_FILTER */
u8 *towire_gossip_timestamp_filter(const tal_t *ctx, const struct bitcoin_blkid *chain_hash, u32 first_timestamp, u32 timestamp_range);
bool fromwire_gossip_timestamp_filter(const void *p, struct bitcoin_blkid *chain_hash, u32 *first_timestamp, u32 *timestamp_range);
/* WIRE: CHANNEL_UPDATE_OPTION_CHANNEL_HTLC_MAX */
u8 *towire_channel_update_option_channel_htlc_max(const tal_t *ctx, const secp256k1_ecdsa_signature *signature, const struct bitcoin_blkid *chain_hash, const struct short_channel_id *short_channel_id, u32 timestamp, u8 message_flags, u8 channel_flags, u16 cltv_expiry_delta, struct amount_msat htlc_minimum_msat, u32 fee_base_msat, u32 fee_proportional_millionths, struct amount_msat htlc_maximum_msat);
bool fromwire_channel_update_option_channel_htlc_max(const void *p, secp256k1_ecdsa_signature *signature, struct bitcoin_blkid *chain_hash, struct short_channel_id *short_channel_id, u32 *timestamp, u8 *message_flags, u8 *channel_flags, u16 *cltv_expiry_delta, struct amount_msat *htlc_minimum_msat, u32 *fee_base_msat, u32 *fee_proportional_millionths, struct amount_msat *htlc_maximum_msat);
#endif /* LIGHTNING_WIRE_PEER_WIREGEN_H */
// SHA256STAMP:exp-0-12bb4b7e8e380207af3b51bfc2b65997753bc3d37465eed70409a21998b50238
Loading…
Cancel
Save