core-lightning/wire
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
..
test wire: perform corruption test on init_msg. 2019-12-13 16:36:40 +01:00
common_wire_csv wire: Add common messages that are independent of daemons 2020-01-28 23:50:52 +01:00
extracted_onion_wire_csv Protocol: make var_onion, payment_secret and basic_mpp non-EXPERIMENTAL. 2019-12-12 22:16:03 +01:00
extracted_peer_wire_csv connectd: add network to init message 2019-11-29 21:17:08 +01:00
fromwire.c Use dedicated type for error codes 2020-01-31 06:02:47 +00:00
Makefile wire: Add common messages that are independent of daemons 2020-01-28 23:50:52 +01:00
onion_defs.h wire: add onion_defs.h to bolt-check, update quote. 2018-09-13 17:38:13 -07:00
peer_wire.c common/gossip_store: handle timestamp filtering. 2019-06-04 01:29:39 +00:00
peer_wire.h chainparams: Move the BOLT2 quote to the chainparams where we set it 2018-09-14 21:18:11 +02:00
tlvstream.h wire: Remove unused fromwire_tlvs 2019-12-03 00:37:15 +00:00
towire.c Use dedicated type for error codes 2020-01-31 06:02:47 +00:00
wire_io.c Remove tal_len, use tal_count() or tal_bytelen(). 2018-07-30 11:31:17 +02:00
wire_io.h gossipd: make more compact getchannels entries. 2019-04-09 12:37:16 -07:00
wire_sync.c Remove tal_len, use tal_count() or tal_bytelen(). 2018-07-30 11:31:17 +02:00
wire_sync.h wire_sync_write: support take() 2017-06-27 10:25:53 +09:30
wire.h Use dedicated type for error codes 2020-01-31 06:02:47 +00:00