core-lightning/connectd/connect_wire.csv
Vasil Dimov 55173a56b7 Use dedicated type for error codes
Before this patch we used `int` for error codes. The problem with
`int` is that we try to pass it to/from wire and the size of `int` is
not defined by the standard. So a sender with 4-byte `int` would write
4 bytes to the wire and a receiver with 2-byte `int` (for example) would
read just 2 bytes from the wire.

To resolve this:

* Introduce an error code type with a known size:
  `typedef s32 errcode_t`.

* Change all error code macros to constants of type `errcode_t`.
  Constants also play better with gdb - it would visualize the name of
  the constant instead of the numeric value.

* Change all functions that take error codes to take the new type
  `errcode_t` instead of `int`.

* Introduce towire / fromwire functions to send / receive the newly added
  type `errcode_t` and use it instead of `towire_int()`.

In addition:

* Remove the now unneeded `towire_int()`.

* Replace a hardcoded error code `-2` with a new constant
  `INVOICE_EXPIRED_DURING_WAIT` (903).

Changelog-Changed: The waitinvoice command would now return error code 903 to designate that the invoice expired during wait, instead of the previous -2
2020-01-31 06:02:47 +00:00

69 lines
2.6 KiB
Plaintext

#include <common/cryptomsg.h>
#include <common/per_peer_state.h>
#include <common/wireaddr.h>
#include <lightningd/gossip_msg.h>
msgtype,connectctl_init,2000
msgdata,connectctl_init,chainparams,chainparams,
msgdata,connectctl_init,id,node_id,
msgdata,connectctl_init,num_wireaddrs,u16,
msgdata,connectctl_init,wireaddrs,wireaddr_internal,num_wireaddrs
msgdata,connectctl_init,listen_announce,enum addr_listen_announce,num_wireaddrs
msgdata,connectctl_init,tor_proxyaddr,?wireaddr,
msgdata,connectctl_init,use_tor_proxy_always,bool,
msgdata,connectctl_init,dev_allow_localhost,bool,
msgdata,connectctl_init,use_dns,bool,
msgdata,connectctl_init,tor_password,wirestring,
msgdata,connectctl_init,use_v3_autotor,bool,
# Connectd->master, here are the addresses I bound, can announce.
msgtype,connectctl_init_reply,2100
msgdata,connectctl_init_reply,num_bindings,u16,
msgdata,connectctl_init_reply,bindings,wireaddr_internal,num_bindings
msgdata,connectctl_init_reply,num_announcable,u16,
msgdata,connectctl_init_reply,announcable,wireaddr,num_announcable
# Activate the connect daemon, so others can connect.
msgtype,connectctl_activate,2025
# Do we listen?
msgdata,connectctl_activate,listen,bool,
# Connectd->master, I am ready.
msgtype,connectctl_activate_reply,2125
# connectd->master: disconnect this peer please (due to reconnect).
msgtype,connect_reconnected,2112
msgdata,connect_reconnected,id,node_id,
# Master -> connectd: connect to a peer.
msgtype,connectctl_connect_to_peer,2001
msgdata,connectctl_connect_to_peer,id,node_id,
msgdata,connectctl_connect_to_peer,seconds_waited,u32,
msgdata,connectctl_connect_to_peer,addrhint,?wireaddr_internal,
# Connectd->master: connect failed.
msgtype,connectctl_connect_failed,2020
msgdata,connectctl_connect_failed,id,node_id,
msgdata,connectctl_connect_failed,failcode,errcode_t,
msgdata,connectctl_connect_failed,failreason,wirestring,
msgdata,connectctl_connect_failed,seconds_to_delay,u32,
msgdata,connectctl_connect_failed,addrhint,?wireaddr_internal,
# Connectd -> master: we got a peer. Three fds: peer, gossip and gossip_store
msgtype,connect_peer_connected,2002
msgdata,connect_peer_connected,id,node_id,
msgdata,connect_peer_connected,addr,wireaddr_internal,
msgdata,connect_peer_connected,pps,per_peer_state,
msgdata,connect_peer_connected,flen,u16,
msgdata,connect_peer_connected,features,u8,flen
# master -> connectd: peer has disconnected.
msgtype,connectctl_peer_disconnected,2015
msgdata,connectctl_peer_disconnected,id,node_id,
# master -> connectd: do you have a memleak?
msgtype,connect_dev_memleak,2033
msgtype,connect_dev_memleak_reply,2133
msgdata,connect_dev_memleak_reply,leak,bool,