core-lightning/wallet
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 Use dedicated type for error codes 2020-01-31 06:02:47 +00:00
.gitignore wallet: Create and manage a sqlite3 database for the wallet 2017-06-06 09:16:10 +09:30
db_common.h db: Track the data_version in the database 2020-01-02 14:12:59 -06:00
db_postgres.c db: Implement postgres driver primitives 2019-09-22 02:03:43 +00:00
db_sqlite3.c db: Move remainder of the sqlite3 into the apropriate file 2019-09-22 02:03:43 +00:00
db.c common: add struct onionreply 2020-01-23 16:17:42 +10:30
db.h common: add struct onionreply 2020-01-23 16:17:42 +10:30
invoices.c wallet: add invoice features into db. 2019-11-24 23:33:17 +00:00
invoices.h wallet: add invoice features into db. 2019-11-24 23:33:17 +00:00
Makefile wallet/Makefile: fix dependency line. 2019-11-28 11:50:13 +01:00
txfilter.c elements: Fix transaction handling for elements transactions 2019-10-03 04:32:57 +00:00
txfilter.h pubkey: rename PUBKEY_DER_LEN to PUBKEY_CMPR_LEN. 2019-04-09 12:37:16 -07:00
wallet.c common: use struct onionreply. 2020-01-23 16:17:42 +10:30
wallet.h common: use struct onionreply. 2020-01-23 16:17:42 +10:30
walletrpc.c Add the missing space between "if" and "(" 2020-01-06 12:57:59 +01:00
walletrpc.h Use expected LIGHTNING_DIR_FILE_H define 2018-03-25 23:54:21 +00:00