db: Create table for HTLCs

Also added a small warning to one of the used enums not to reorder or
insert values. They'd break the update path.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker 2017-09-01 15:54:41 +02:00 committed by Rusty Russell
parent a4967d74f1
commit 3dda72c885
2 changed files with 23 additions and 0 deletions

View File

@ -2,6 +2,10 @@
#define LIGHTNING_COMMON_HTLC_STATE_H
#include "config.h"
/*
* /!\ The generated enum values are used in the database, DO NOT
* reorder or insert new values (appending at the end is ok) /!\
*/
enum htlc_state {
/* When we add a new htlc, it goes in this order. */
SENT_ADD_HTLC,

View File

@ -92,6 +92,25 @@ char *dbmigrations[] = {
" max_accepted_htlcs INTEGER,"
" PRIMARY KEY (id)"
");",
"CREATE TABLE channel_htlcs ("
" id INTEGER,"
" channel_id INTEGER REFERENCES channels(id) ON DELETE CASCADE,"
" channel_htlc_id INTEGER,"
" direction INTEGER,"
" origin_htlc INTEGER,"
" msatoshi INTEGER,"
" ctlv_expiry INTEGER,"
" payment_hash BLOB,"
" payment_key BLOB,"
" routing_onion BLOB,"
" failuremsg BLOB,"
" malformed_onion INTEGER,"
" hstate INTEGER,"
" shared_secret BLOB,"
" preimage BLOB,"
" PRIMARY KEY (id),"
" UNIQUE (channel_id, channel_htlc_id, direction)"
");",
NULL,
};